From fa0d681c23ff5d6e401b88edd659fa01c96317f0 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Sun, 11 Sep 2016 12:05:04 +0200 Subject: [PATCH] Simplify and fix CGALConfig.cmake for header-only2 --- .../CGAL_setup_target_dependencies.cmake | 17 +++++++++++ Installation/lib/cmake/CGAL/CGALConfig.cmake | 30 +++++++++++-------- 2 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 Installation/cmake/modules/CGAL_setup_target_dependencies.cmake diff --git a/Installation/cmake/modules/CGAL_setup_target_dependencies.cmake b/Installation/cmake/modules/CGAL_setup_target_dependencies.cmake new file mode 100644 index 00000000000..a763cbc7480 --- /dev/null +++ b/Installation/cmake/modules/CGAL_setup_target_dependencies.cmake @@ -0,0 +1,17 @@ +function(CGAL_setup_target_dependencies target) + if(ARGV1 STREQUAL INTERFACE) + set(keyword INTERFACE) + else() + set(keyword PUBLIC) + endif() + + if(${target} STREQUAL CGAL) + CGAL_setup_CGAL_dependencies(${target} ${keyword}) + elseif(${target} STREQUAL CGAL_Core) + CGAL_setup_CGAL_Core_dependencies(${target} ${keyword}) + elseif(${target} STREQUAL CGAL_ImageIO) + CGAL_setup_CGAL_Core_dependencies(${target} ${keyword}) + elseif(${target} STREQUAL CGAL_Qt5) + CGAL_setup_CGAL_Qt5_dependencies(${target} ${keyword}) + endif() +endfunction() diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index ed380055885..46024cb6dc7 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -2,6 +2,9 @@ # This file is the CGALConfig.cmake for a pure header-only CGAL installion # +#set(CGAL_Boost_USE_STATIC_LIBS ON) +set(CGAL_AUTO_LINK_ENABLED) + if(CGALConfig_included) return() endif() @@ -68,26 +71,29 @@ include( ${CGAL_MODULES_DIR}/CGAL_SetupCGALDependencies.cmake ) # Define the CGAL targets and theirs CGAL:: aliases # foreach(cgal_lib CGAL CGAL_Core CGAL_ImageIO CGAL_Qt5) - set(${cgal_lib}_FOUND TRUE) - add_library(${cgal_lib} INTERFACE) - add_library(CGAL::${cgal_lib} ALIAS ${cgal_lib}) - if(NOT ${cgal_lib} STREQUAL CGAL_Core) - include( ${CGAL_MODULES_DIR}/CGAL_Setup${cgal_lib}Dependencies.cmake ) + if(${cgal_lib}_FOUND) + add_library(${cgal_lib} INTERFACE) + add_library(CGAL::${cgal_lib} ALIAS ${cgal_lib}) + include(CGAL_Setup${cgal_lib}Dependencies) endif() endforeach() + +# this include has to be after the loop that includes the +# `CGAL_Setup${cgal_lib}Dependencies` files +include(CGAL_setup_target_dependencies) + +foreach(cgal_lib CGAL CGAL_Core CGAL_ImageIO CGAL_Qt5) + if(${cgal_lib}_FOUND) + CGAL_setup_target_dependencies(${cgal_lib} INTERFACE) + endif() +endforeach() + target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY=1) target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY_STEP_2=1) -target_include_directories(CGAL INTERFACE ${CGAL_INCLUDE_DIRS}) -CGAL_setup_CGAL_dependencies(CGAL INTERFACE) -CGAL_setup_CGAL_Qt5_dependencies(CGAL_Qt5 INTERFACE) -target_link_libraries( CGAL_Core INTERFACE CGAL::CGAL ) -CGAL_setup_CGAL_ImageIO_dependencies(CGAL_ImageIO INTERFACE) # # # -include(Use_CGAL_Qt5_headers) - include(${CGAL_MODULES_DIR}/CGAL_CreateSingleSourceCGALProgram.cmake) include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake)