From 87854c81f51d112aee0b04525bb1b84e0eab8ed5 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 21 Dec 2019 16:19:22 -0800 Subject: [PATCH] Allow C++ standard to be passed to CHECK_CXX_SOURCE_COMPILES Work around the issue in CMake where C++ standard doesn't get propagated to CHECK_CXX_SOURCE_COMPILES. Also correctly check for std::make_unique; the define was missing from the config.h header. --- cmake/ConfigureChecks.cmake | 6 ++++++ config_cmake.h.in | 3 +++ 2 files changed, 9 insertions(+) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 901c743ba..4d1de9cad 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -4,6 +4,12 @@ # `wcstod_l` is a GNU-extension, sometimes hidden behind GNU-related defines. # This is the case for at least Cygwin and Newlib. LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1) + + +# Work around the fact that cmake does not propagate the language standard flag into +# the CHECK_CXX_SOURCE_COMPILES function. See CMake issue #16456. +LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}") + IF(APPLE) INCLUDE(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY) diff --git a/config_cmake.h.in b/config_cmake.h.in index ea7e90820..471094269 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -127,6 +127,9 @@ /* Define to 1 if the _nl_msg_cat_cntr symbol is exported. */ #cmakedefine HAVE__NL_MSG_CAT_CNTR 1 +/* Define to 1 if std::make_unique is available. */ +#cmakedefine HAVE_STD__MAKE_UNIQUE 1 + /* Define to 1 if the _sys_errs array is available. */ #cmakedefine HAVE__SYS__ERRS 1