From 690df2f9de31fa2d4770ce6d417153532ddb120a Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 13 Jul 2016 09:15:38 -0500 Subject: [PATCH] CMake: Also include the link interface in the sanity checks --- ....cmake => macro_check_compiler_setup.cmake} | 18 ++++++++++++------ cmake/setup_compiler_flags.cmake | 8 +++++--- cmake/setup_finalize.cmake | 8 +++++--- 3 files changed, 22 insertions(+), 12 deletions(-) rename cmake/macros/{macro_check_compiler_flags.cmake => macro_check_compiler_setup.cmake} (71%) diff --git a/cmake/macros/macro_check_compiler_flags.cmake b/cmake/macros/macro_check_compiler_setup.cmake similarity index 71% rename from cmake/macros/macro_check_compiler_flags.cmake rename to cmake/macros/macro_check_compiler_setup.cmake index 6261c8e3e9..69f813613a 100644 --- a/cmake/macros/macro_check_compiler_flags.cmake +++ b/cmake/macros/macro_check_compiler_setup.cmake @@ -15,20 +15,25 @@ # # Usage: -# CHECK_COMPILER_FLAGS(_compiler_flags_variable _linker_flags_variable _var) +# CHECK_COMPILER_SETUP( +# _compiler_flags_variable _linker_flags_variable _var +# [libraries] +# ) # # This macro tries to compile and link a simple "int main(){ return 0; } # with the given set of compiler and flags provided in -# _compiler_flags_variable and _linker_flags_variable. If the test is -# succesful the variable ${_var} is set to true, otherwise to false. +# _compiler_flags_variable and _linker_flags_variable and an optional list +# of libraries to link against. If the test is succesful the variable +# ${_var} is set to true, otherwise to false. # -MACRO(CHECK_COMPILER_FLAGS _compiler_flags_variable _linker_flags_variable _var) +MACRO(CHECK_COMPILER_SETUP _compiler_flags_variable _linker_flags_variable _var) # # Rerun this test if flags have changed: # IF(NOT "${${_compiler_flags_variable}}" STREQUAL "${CACHED_${_var}_${_compiler_flags_variable}}" - OR NOT "${${_linker_flags_variable}}" STREQUAL "${CACHED_${_var}_${_linker_flags_variable}}") + OR NOT "${${_linker_flags_variable}}" STREQUAL "${CACHED_${_var}_${_linker_flags_variable}}" + OR NOT "${ARGN}" STREQUAL "${CACHED_${_var}_ARGN}") UNSET(${_var} CACHE) ENDIF() @@ -38,9 +43,10 @@ MACRO(CHECK_COMPILER_FLAGS _compiler_flags_variable _linker_flags_variable _var) SET(CACHED_${_var}_${_linker_flags_variable} "${${_linker_flags_variable}}" CACHE INTERNAL "" FORCE ) + SET(CACHED_${_var}_ARGN "${ARGN}" CACHE INTERNAL "" FORCE) SET(CMAKE_REQUIRED_FLAGS ${${_compiler_flags_variable}}) - SET(CMAKE_REQUIRED_LIBRARIES ${${_linker_flags_variable}}) + SET(CMAKE_REQUIRED_LIBRARIES ${${_linker_flags_variable}} ${ARGN}) CHECK_CXX_SOURCE_COMPILES("int main(){ return 0; }" ${_var}) RESET_CMAKE_REQUIRED() diff --git a/cmake/setup_compiler_flags.cmake b/cmake/setup_compiler_flags.cmake index cbe4ee2ad1..12c5a10c0e 100644 --- a/cmake/setup_compiler_flags.cmake +++ b/cmake/setup_compiler_flags.cmake @@ -75,15 +75,17 @@ FOREACH(build ${DEAL_II_BUILD_TYPES}) SET(_cxx_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}") SET(_linker_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}") - CHECK_COMPILER_FLAGS(_cxx_flags_${build} _linker_flags_${build} + CHECK_COMPILER_SETUP(_cxx_flags_${build} _linker_flags_${build} DEAL_II_HAVE_USABLE_USER_FLAGS_${build} + ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}} ) IF(NOT DEAL_II_HAVE_USABLE_USER_FLAGS_${build}) MESSAGE(FATAL_ERROR " Configuration error: Cannot compile with the user supplied flags: - CXX flags (${build}): ${_cxx_flags_${build}} - LD flags (${build}): ${_linker_flags_${build}} + CXX flags (${build}): ${_cxx_flags_${build}} + LD flags (${build}): ${_linker_flags_${build}} + LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}} Please check the CMake variables DEAL_II_CXX_FLAGS, DEAL_II_CXX_FLAGS_${build}, DEAL_II_LINKER_FLAGS, DEAL_II_CXX_FLAGS_${build} diff --git a/cmake/setup_finalize.cmake b/cmake/setup_finalize.cmake index 59dcb2f83a..2b7d97703c 100644 --- a/cmake/setup_finalize.cmake +++ b/cmake/setup_finalize.cmake @@ -87,16 +87,18 @@ FOREACH(build ${DEAL_II_BUILD_TYPES}) SET(_cxx_flags_${build} "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}") SET(_linker_flags_${build} "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}") - CHECK_COMPILER_FLAGS(_cxx_flags_${build} _linker_flags_${build} + CHECK_COMPILER_SETUP(_cxx_flags_${build} _linker_flags_${build} DEAL_II_HAVE_USABLE_FLAGS_${build} + ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}} ) IF(NOT DEAL_II_HAVE_USABLE_FLAGS_${build}) MESSAGE(FATAL_ERROR " Configuration error: Cannot compile a test program with the final set of compiler and linker flags: - CXX flags (${build}): ${_final_cxx_flags_${build}} - LD flags (${build}): ${_final_linker_flags_${build}} + CXX flags (${build}): ${_cxx_flags_${build}} + LD flags (${build}): ${_linker_flags_${build}} + LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}} \n\n" ) ENDIF() -- 2.39.5