From 9b988404bfa0ce124a507e805148fb056cf0d855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 13:51:40 +0200 Subject: [PATCH 1/7] Set CMP0054 to NEW We set it to new by removing the code that sets it to OLD. --- Installation/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 27c24ca7dff..0da4a11cfc8 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -24,7 +24,7 @@ endif() if(POLICY CMP0054) # http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html # See the discussion https://github.com/CGAL/cgal/issues/189 - cmake_policy(SET CMP0054 OLD) + cmake_policy(SET CMP0054 NEW) endif() From 5cf0951577a027c7a5ac0d923f626fa96aee33a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:13:00 +0200 Subject: [PATCH 2/7] Whitespace fixes --- Installation/CMakeLists.txt | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 0da4a11cfc8..c3d0623657e 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -522,14 +522,12 @@ message("== Set up flags (DONE) ==\n") message("== Detect external libraries ==") -macro( add_config_flag flag ) - - if ( ${flag} ) - file( APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "#define ${flag} 1\n\n") +macro(add_config_flag flag) + if(${flag}) + file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "#define ${flag} 1\n\n") else() - file( APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//#define ${flag} 1\n\n") + file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//#define ${flag} 1\n\n") endif() - endmacro() # this is the place to tell which external libs are supporting @@ -694,13 +692,13 @@ endforeach() cache_set(CONFIG_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -add_config_flag( CGAL_USE_GMP ) -add_config_flag( CGAL_USE_MPFR ) -add_config_flag( CGAL_USE_GMPXX ) -add_config_flag( CGAL_USE_LEDA ) -add_config_flag( CGAL_USE_MPFI ) -add_config_flag( CGAL_USE_RS ) -add_config_flag( CGAL_USE_NTL ) +add_config_flag(CGAL_USE_GMP) +add_config_flag(CGAL_USE_MPFR) +add_config_flag(CGAL_USE_GMPXX) +add_config_flag(CGAL_USE_LEDA) +add_config_flag(CGAL_USE_MPFI) +add_config_flag(CGAL_USE_RS) +add_config_flag(CGAL_USE_NTL) add_config_flag( CGAL_BUILD_SHARED_LIBS ) From 8e5f8877658ac93a367511146a8cfb9ac14fb08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:15:05 +0200 Subject: [PATCH 3/7] Prevent triggering of CMP0054 CMAKE_CXX_COMPILER_ID can expand to the string MSVC, which is also a variable name which has been expanded by before CMP0054 has been introduced. This would lead to a bug *if* we would MATCHES against the string "MSVC", but only triggers a warning. Also quote some implicit string in a MATCHES for style reasons. --- Installation/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index c3d0623657e..8376cea1e99 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -430,7 +430,7 @@ if( MSVC ) endif() -if( "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro ) +if( "\"${CMAKE_CXX_COMPILER_ID}\"" MATCHES "SunPro" ) message( STATUS "Using SunPro compiler, using STLPort 4." ) uniquely_add_flags( CGAL_CXX_FLAGS "-features=extensions;-library=stlport4;-D_GNU_SOURCE" ) @@ -950,7 +950,7 @@ if( WITH_CPACK AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) endif() - if(${CPACK_SYSTEM_NAME} MATCHES Windows) + if(${CPACK_SYSTEM_NAME} MATCHES "Windows") if(CMAKE_CL_64) set(CPACK_SYSTEM_NAME win64-${CMAKE_SYSTEM_PROCESSOR}) else() From de403e8cc44e5036e9dacbcab087f8d0bb5e729b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:17:25 +0200 Subject: [PATCH 4/7] Always run the config tests The code tried to prevent running the config tests to often by caching their values and only rerunning them when the CMAKE_CXX_FLAGS change. While this is smart it only buys us a few seconds and is not actually correct. One of those bugs could be triggered through linker flags or debug flags as well and just checking CMAKE_CXX_FLAGS is far from enough. To be on the safe side we accept the extra configuration-time (which is usually also minimized by using compiler caches). This also removes a warning caused by CMake policy CMP0054. --- Installation/CMakeLists.txt | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 8376cea1e99..0d6e2dbe8c6 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -669,25 +669,18 @@ file( WRITE ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//\n// compiler_ cache_get(CONFIG_CXX_FLAGS) foreach(config_test_cpp ${all_config_tests}) - - # Test's name is .cpp's base name - get_filename_component(config_test_name ${config_test_cpp} NAME_WE) - - # Compile and run ${config_test_cpp}. Exit code is stored in ${config_test_name}. - if( RUNNING_CGAL_AUTO_TEST OR "${config_test_name}" MATCHES "^${config_test_name}$" OR NOT ${CONFIG_CXX_FLAGS} STREQUAL ${CMAKE_CXX_FLAGS}) + # Test's name is .cpp's base name + get_filename_component(config_test_name ${config_test_cpp} NAME_WE) - CHECK_CXX_FILE_RUNS(${config_test_cpp} ${config_test_name} ${config_test_name}) + # Compile and run ${config_test_cpp}. Exit code is stored in ${config_test_name}. + CHECK_CXX_FILE_RUNS(${config_test_cpp} ${config_test_name} ${config_test_name}) + if(${config_test_name}) + set(${config_test_name} 0) + else() + set(${config_test_name} 1) + endif() - if ( ${config_test_name} ) - cache_set ( ${config_test_name} 0 ) - else() - cache_set ( ${config_test_name} 1 ) - endif() - - endif() - - add_config_flag( ${config_test_name} ${config_test_name} ) - + add_config_flag(${config_test_name} ${config_test_name}) endforeach() cache_set(CONFIG_CXX_FLAGS ${CMAKE_CXX_FLAGS}) From e598d67ba617cb2bce52ebca10d81381ba1cdbc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:23:24 +0200 Subject: [PATCH 5/7] CONFIG_CXX_FLAGS is no longer used --- Installation/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 0d6e2dbe8c6..f850702a808 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -666,8 +666,6 @@ list( SORT all_config_tests ) file( WRITE ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//\n// compiler_config.h is included by CGAL headers to load the needed compiler settings.\n//\n// DO NOT EDIT compiler_config.h. It is generated by CMake.\n//\n\n") -cache_get(CONFIG_CXX_FLAGS) - foreach(config_test_cpp ${all_config_tests}) # Test's name is .cpp's base name get_filename_component(config_test_name ${config_test_cpp} NAME_WE) @@ -683,8 +681,6 @@ foreach(config_test_cpp ${all_config_tests}) add_config_flag(${config_test_name} ${config_test_name}) endforeach() -cache_set(CONFIG_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - add_config_flag(CGAL_USE_GMP) add_config_flag(CGAL_USE_MPFR) add_config_flag(CGAL_USE_GMPXX) From f0fad560f643d3478f62acf71026abd531ac7a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:28:35 +0200 Subject: [PATCH 6/7] Remove unnecessary add_config_flag call This call to add_config_flag has no effect. It is made before the file(WRITE ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h ...) which overwrites the contents of the file. This is surely a bug, because ${CGAL_EXT_LIB_${lib}_PREFIX} expands to things like GMP or MPFR which would be really bad defines. --- Installation/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index f850702a808..fbb8b25caad 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -610,10 +610,6 @@ foreach (lib ${CGAL_SUPPORTING_3RD_PARTY_LIBRARIES}) option(WITH_${lib} "Select external library ${lib}" OFF) endif() - if (WITH_${lib}) - add_config_flag( ${CGAL_EXT_LIB_${lib}_PREFIX} ) - endif() - endforeach() #-------------------------------------------------------------------------------------------------- From dea9451c539eee7350d6885a47928ae2283ad7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 5 Aug 2015 14:31:50 +0200 Subject: [PATCH 7/7] Move the add_config_flag macro to where it is used --- Installation/CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index fbb8b25caad..f489f95477d 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -522,14 +522,6 @@ message("== Set up flags (DONE) ==\n") message("== Detect external libraries ==") -macro(add_config_flag flag) - if(${flag}) - file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "#define ${flag} 1\n\n") - else() - file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//#define ${flag} 1\n\n") - endif() -endmacro() - # this is the place to tell which external libs are supporting # Remarks: # External libs Qt3 and Qt34are configured when Qt3 or Qt5 as lib of cgal are required @@ -656,11 +648,18 @@ message("== Detect external libraries (DONE) ==\n") message("== Write compiler_config.h ==") +macro(add_config_flag flag) + if(${flag}) + file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "#define ${flag} 1\n\n") + else() + file(APPEND ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//#define ${flag} 1\n\n") + endif() +endmacro() + file(GLOB all_config_tests "${CGAL_INSTALLATION_PACKAGE_DIR}/config/testfiles/*.cpp") +list(SORT all_config_tests) -list( SORT all_config_tests ) - -file( WRITE ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//\n// compiler_config.h is included by CGAL headers to load the needed compiler settings.\n//\n// DO NOT EDIT compiler_config.h. It is generated by CMake.\n//\n\n") +file(WRITE ${CMAKE_BINARY_DIR}/include/CGAL/compiler_config.h "//\n// compiler_config.h is included by CGAL headers to load the needed compiler settings.\n//\n// DO NOT EDIT compiler_config.h. It is generated by CMake.\n//\n\n") foreach(config_test_cpp ${all_config_tests}) # Test's name is .cpp's base name