From a2a5ca91a1899edfe392a937a527b796c459df87 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 23 Nov 2017 16:44:11 +0100 Subject: [PATCH] Unify CGAL_HEADER_ONLY and CGAL_HEADER_ONLY_STEP_2 --- Installation/CGALConfig.cmake | 2 +- Installation/CMakeLists.txt | 17 +++++++++++------ .../CGALConfig_binary_header_only.cmake.in | 5 +++++ Installation/include/CGAL/config.h | 2 +- Installation/lib/cmake/CGAL/CGALConfig.cmake | 6 +++--- Installation/src/CGAL/CMakeLists.txt | 4 ++-- Installation/src/CMakeLists.txt | 15 +++++++-------- 7 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 Installation/cmake/modules/CGALConfig_binary_header_only.cmake.in diff --git a/Installation/CGALConfig.cmake b/Installation/CGALConfig.cmake index 075a14aea6e..8b228bdf3eb 100644 --- a/Installation/CGALConfig.cmake +++ b/Installation/CGALConfig.cmake @@ -1,5 +1,5 @@ # -# This file points to the CGALConfig.cmake for a pure header-only +# This file points to the CGALConfig.cmake for a header-only # CGAL installation. # diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 01180ae9785..c09766ab359 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -36,7 +36,7 @@ if(CMAKE_MAJOR_VERSION GREATER 2) # In header only mode, we use INTERFACE libraries, which was introduced in cmake 3.0. # Thus this option is only enabled for cmake >= 3.0. - if (CGAL_HEADER_ONLY OR CGAL_HEADER_ONLY_STEP_2) + if (CGAL_HEADER_ONLY) set(CGAL_HEADER_ONLY TRUE CACHE BOOL "Enable cgal header only" FORCE) add_definitions(-DCGAL_HEADER_ONLY) endif() @@ -666,7 +666,7 @@ option( CGAL_ENABLE_PRECONFIG "Select to allow to preconfiguration of external l # this; e.g. in MPFI/RS in Algebraic_kernel_d. For these cases CGAL # and the example/test must be configured with MPFI (just one is not sufficient) -if(NOT CGAL_HEADER_ONLY_STEP_2) +if(NOT CGAL_HEADER_ONLY) include(CGAL_SetupDependencies) endif() @@ -678,7 +678,7 @@ message("== Detect external libraries (DONE) ==\n") # #-------------------------------------------------------------------------------------------------- -if(NOT CGAL_HEADER_ONLY_STEP_2) +if(NOT CGAL_HEADER_ONLY) # The variables set are the #defines expected by compiler_config.h # Note: CMake will not notice when files are added or removed # but this is probably OK for the installation procedure. @@ -740,7 +740,7 @@ endif() message("== Write compiler_config.h (DONE) ==\n") -endif(NOT CGAL_HEADER_ONLY_STEP_2) +endif(NOT CGAL_HEADER_ONLY) #-------------------------------------------------------------------------------------------------- # @@ -847,7 +847,12 @@ if (CGAL_BRANCH_BUILD AND CGAL_REPORT_DUPLICATE_FILES ) endif() -create_CGALconfig_files() +if(NOT CGAL_HEADER_ONLY) + create_CGALconfig_files() +else() + configure_file("${CGAL_MODULES_DIR}/CGALConfig_binary_header_only.cmake.in" + "${CMAKE_BINARY_DIR}/CGALConfig.cmake" @ONLY) +endif() #-------------------------------------------------------------------------------------------------- # @@ -892,7 +897,7 @@ if ( ZLIB_IN_AUXILIARY ) endif() -if(NOT CGAL_HEADER_ONLY_STEP_2) +if(NOT CGAL_HEADER_ONLY) install(FILES ${CMAKE_BINARY_DIR}/CGALConfigVersion.cmake ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake diff --git a/Installation/cmake/modules/CGALConfig_binary_header_only.cmake.in b/Installation/cmake/modules/CGALConfig_binary_header_only.cmake.in new file mode 100644 index 00000000000..474864c0b7e --- /dev/null +++ b/Installation/cmake/modules/CGALConfig_binary_header_only.cmake.in @@ -0,0 +1,5 @@ +# +# This file points to the CGALConfig.cmake for header-only CGAL. +# + +include(@CGAL_INSTALLATION_PACKAGE_DIR@/lib/cmake/CGAL/CGALConfig.cmake) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 7247444e46d..f2d44b9d9f4 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -139,7 +139,7 @@ // platform specific workaround flags (CGAL_CFG_...) //----------------------------------------------------------------------// -#if CGAL_HEADER_ONLY_STEP_2 +#if CGAL_HEADER_ONLY # include # if(BOOST_MSVC) # include diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index b84e4029cd2..ca5e2a90004 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -1,12 +1,12 @@ # -# This file is the CGALConfig.cmake for a pure header-only CGAL installation +# This file is the CGALConfig.cmake for a header-only CGAL installation # if(CGALConfig_included) return() endif() -message(STATUS "Using pure header-only CGAL") +message(STATUS "Using header-only CGAL") set(CGALConfig_included TRUE) @@ -105,7 +105,7 @@ foreach(cgal_lib ${CGAL_LIBRARIES}) endforeach() target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY=1) -target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY_STEP_2=1) + # # diff --git a/Installation/src/CGAL/CMakeLists.txt b/Installation/src/CGAL/CMakeLists.txt index 55ab4627631..cf661e93fa7 100644 --- a/Installation/src/CGAL/CMakeLists.txt +++ b/Installation/src/CGAL/CMakeLists.txt @@ -10,8 +10,8 @@ endif() CGAL_setup_CGAL_dependencies(CGAL ${keyword}) -if(CGAL_HEADER_ONLY_STEP_2) - target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY_STEP_2=1) +if(CGAL_HEADER_ONLY) + target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY=1) endif() if(NOT CGAL_DISABLE_GMP) diff --git a/Installation/src/CMakeLists.txt b/Installation/src/CMakeLists.txt index 3f0a2f5da59..f9a8b35c9c3 100644 --- a/Installation/src/CMakeLists.txt +++ b/Installation/src/CMakeLists.txt @@ -94,15 +94,14 @@ function (collect_cgal_library LIBRARY_NAME ADDITIONAL_FILES) install(EXPORT ${LIBRARY_NAME}Exports DESTINATION "${CGAL_INSTALL_CMAKE_DIR}" NAMESPACE CGAL::) + + # We have to call configure_file twice to force double expansion of variables. + configure_file("${CGAL_MODULES_DIR}/CGALLibConfig.cmake.in" + "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" @ONLY) + configure_file("${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" + "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" @ONLY) + install(FILES "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" DESTINATION ${CGAL_INSTALL_CMAKE_DIR}) endif() - - # We have to call configure_file twice to force double expansion of variables. - configure_file("${CGAL_MODULES_DIR}/CGALLibConfig.cmake.in" - "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" @ONLY) - configure_file("${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" - "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" @ONLY) - install(FILES "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}LibConfig.cmake" DESTINATION ${CGAL_INSTALL_CMAKE_DIR}) - endfunction() function( configure_component DIR COMPONENT )