mirror of https://github.com/CGAL/cgal
Speed improvement with CGAL_HEADER_ONLY and WITH_{tests|examples}..
When `CGAL_HEADER_ONLY` and `WITH_{examples|tests|demos}`, then only
the first call to `find_package(CGAL)` does the job. The subsequent
calls return very fast, by caching the results in global properties.
This commit is contained in:
parent
c17e0497ae
commit
de1753566b
|
|
@ -805,6 +805,16 @@ cache_get(CGAL_3RD_PARTY_LIBRARIES_DIRS)
|
|||
|
||||
add_subdirectory(src)
|
||||
|
||||
#
|
||||
# Variables used when WITH_{demos|examples|tests} are TRUE, and
|
||||
# CGAL_HEADER_ONLY=ON
|
||||
#
|
||||
set(CGAL_USE_FILE ${CGAL_MODULES_DIR}/UseCGAL.cmake)
|
||||
get_property(CGAL_FOUND GLOBAL PROPERTY CGAL_FOUND)
|
||||
get_property(CGAL_Core_FOUND GLOBAL PROPERTY CGAL_Core_FOUND)
|
||||
get_property(CGAL_ImageIO_FOUND GLOBAL PROPERTY CGAL_ImageIO_FOUND)
|
||||
get_property(CGAL_Qt5_FOUND GLOBAL PROPERTY CGAL_Qt5_FOUND)
|
||||
|
||||
#
|
||||
# Repeat some problems
|
||||
#
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/CGAL_SetupBoost.cmake)
|
|||
# Set to `TRUE` if the dependencies of CGAL were found.
|
||||
if(Boost_FOUND)
|
||||
set(CGAL_FOUND TRUE)
|
||||
set_property(GLOBAL PROPERTY CGAL_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
#.rst:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ if(NOT CGAL_DISABLE_GMP)
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/CGAL_SetupGMP.cmake)
|
||||
if(GMP_FOUND)
|
||||
set(CGAL_Core_FOUND TRUE)
|
||||
set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -52,18 +53,19 @@ endif()
|
|||
# keyword, or ``PUBLIC`` otherwise.
|
||||
#
|
||||
|
||||
# See the release notes of CGAL-4.10: CGAL_Core now requires
|
||||
# Boost.Thread, with all compilers but MSVC.
|
||||
if (NOT MSVC)
|
||||
find_package( Boost 1.48 REQUIRED thread system )
|
||||
endif()
|
||||
|
||||
function(CGAL_setup_CGAL_Core_dependencies target)
|
||||
if(ARGV1 STREQUAL INTERFACE)
|
||||
set(keyword INTERFACE)
|
||||
else()
|
||||
set(keyword PUBLIC)
|
||||
endif()
|
||||
|
||||
# See the release notes of CGAL-4.10: CGAL_Core now requires
|
||||
# Boost.Thread, with all compilers but MSVC.
|
||||
if (NOT MSVC)
|
||||
find_package( Boost 1.48 REQUIRED thread system )
|
||||
endif()
|
||||
|
||||
use_CGAL_GMP_support(CGAL_Core ${keyword})
|
||||
target_compile_definitions(${target} ${keyword} CGAL_USE_CORE=1)
|
||||
target_link_libraries( CGAL_Core ${keyword} CGAL::CGAL ${Boost_LIBRARIES})
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ endif(ZLIB_FOUND)
|
|||
set( CGAL_ImageIO_BASENAME CGAL_ImageIO)
|
||||
|
||||
set(CGAL_ImageIO_FOUND TRUE)
|
||||
set_property(GLOBAL PROPERTY CGAL_ImageIO_FOUND TRUE)
|
||||
|
||||
function(CGAL_setup_CGAL_ImageIO_dependencies target)
|
||||
if(ARGV1 STREQUAL INTERFACE)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ endif()
|
|||
#
|
||||
if(NOT CGAL_Qt5_MISSING_DEPS)
|
||||
set(CGAL_Qt5_FOUND TRUE)
|
||||
set_property(GLOBAL PROPERTY CGAL_Qt5_FOUND TRUE)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CGAL_Qt5_moc_and_resource_files.cmake)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,43 @@
|
|||
# This file is the CGALConfig.cmake for a header-only CGAL installation
|
||||
#
|
||||
|
||||
if(CGALConfig_included)
|
||||
# For UseCGAL.cmake
|
||||
set( CGAL_REQUESTED_COMPONENTS ${CGAL_FIND_COMPONENTS} )
|
||||
|
||||
set(CGAL_LIBRARIES CGAL)
|
||||
|
||||
if(CGAL_BUILDING_LIBS)
|
||||
foreach(comp ${CGAL_FIND_COMPONENTS})
|
||||
if(CGAL_${comp}_FOUND)
|
||||
list(APPEND CGAL_LIBRARIES CGAL_${comp})
|
||||
endif()
|
||||
endforeach()
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(comp ${CGAL_FIND_COMPONENTS})
|
||||
if(NOT comp MATCHES "Core|ImageIO|Qt5")
|
||||
message(FATAL_ERROR "The requested CGAL component ${comp} does not exist!")
|
||||
endif()
|
||||
list(APPEND CGAL_LIBRARIES CGAL_${comp})
|
||||
endforeach()
|
||||
|
||||
set(CGALConfig_all_targets_are_defined TRUE)
|
||||
foreach(cgal_lib ${CGAL_LIBRARIES})
|
||||
if(NOT WITH_${cgal_lib})
|
||||
set(CGALConfig_all_targets_are_defined FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
if(CGALConfig_all_targets_are_defined)
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Using header-only CGAL")
|
||||
|
||||
set(CGALConfig_included TRUE)
|
||||
|
||||
get_filename_component(CGAL_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
set(CGAL_HEADER_ONLY TRUE)
|
||||
|
||||
set( CGAL_REQUESTED_COMPONENTS ${CGAL_FIND_COMPONENTS} )
|
||||
|
||||
# Save the current source directory. That variable can be changed by
|
||||
# a `CMakeLists.txt`, for `CMakeLists.txt` files that are created in
|
||||
# the binary directory.
|
||||
|
|
@ -76,14 +99,6 @@ list(APPEND CMAKE_MODULE_PATH ${CGAL_MODULES_DIR})
|
|||
include( ${CGAL_MODULES_DIR}/CGAL_SCM.cmake )
|
||||
CGAL_detect_git(${CGAL_CONFIG_DIR}/../../../..)
|
||||
|
||||
set(CGAL_LIBRARIES CGAL)
|
||||
foreach(comp ${CGAL_FIND_COMPONENTS})
|
||||
if(NOT comp MATCHES "Core|ImageIO|Qt5")
|
||||
message(FATAL_ERROR "The requested CGAL component ${comp} does not exist!")
|
||||
endif()
|
||||
list(APPEND CGAL_LIBRARIES CGAL_${comp})
|
||||
endforeach()
|
||||
|
||||
#
|
||||
# Search for all dependencies
|
||||
#
|
||||
|
|
@ -91,6 +106,10 @@ foreach(cgal_lib ${CGAL_LIBRARIES})
|
|||
include(CGAL_Setup${cgal_lib}Dependencies)
|
||||
endforeach()
|
||||
|
||||
# this include has to be after the loop that includes the
|
||||
# `CGAL_Setup${cgal_lib}Dependencies` files
|
||||
include(CGAL_setup_target_dependencies)
|
||||
|
||||
#
|
||||
# Define the CGAL targets and theirs CGAL:: aliases
|
||||
#
|
||||
|
|
@ -101,21 +120,13 @@ foreach(cgal_lib ${CGAL_LIBRARIES})
|
|||
if(NOT TARGET CGAL::${cgal_lib})
|
||||
add_library(CGAL::${cgal_lib} ALIAS ${cgal_lib})
|
||||
endif()
|
||||
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_LIBRARIES})
|
||||
if(${cgal_lib}_FOUND)
|
||||
if(${cgal_lib} STREQUAL CGAL)
|
||||
target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY=1)
|
||||
endif()
|
||||
CGAL_setup_target_dependencies(${cgal_lib} INTERFACE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
target_compile_definitions(CGAL INTERFACE CGAL_HEADER_ONLY=1)
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue