Use any user-specified CMAKE_CXX_FLAGS in CheckCXXSourceCompiles(). Change-Id: I5816e3b65d8d273c76bf19c475f8fafd9f9bd7a1
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7406fca..0174824 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -450,13 +450,18 @@ list(APPEND CERES_COMPILE_OPTIONS CERES_NO_THREADS) endif (OPENMP) +# Initialise CMAKE_REQUIRED_FLAGS used by CheckCXXSourceCompiles with the +# contents of CMAKE_CXX_FLAGS such that if the user has passed extra flags +# they are used when discovering shared_ptr/unordered_map. +set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) + include(CheckCXXCompilerFlag) check_cxx_compiler_flag("-std=c++11" COMPILER_HAS_CXX11_FLAG) if (CXX11 AND COMPILER_HAS_CXX11_FLAG) # Update CMAKE_REQUIRED_FLAGS used by CheckCXXSourceCompiles to include # -std=c++11 s/t we will detect the C++11 versions of unordered_map & # shared_ptr if they exist. - set(CMAKE_REQUIRED_FLAGS -std=c++11) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") endif (CXX11 AND COMPILER_HAS_CXX11_FLAG) # Set the Ceres compile definitions for the unordered_map configuration.