diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 51c8abdaeca..0bf3e4b575d 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -928,7 +928,10 @@ if(NOT CGAL_HEADER_ONLY) ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) else() + configure_file(${CMAKE_CURRENT_LIST_DIR}/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in + ${CMAKE_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake) install(FILES + ${CMAKE_BINARY_DIR}/config/CGALConfig-installation-dirs.cmake ${CMAKE_CURRENT_LIST_DIR}/lib/cmake/CGAL/CGALConfig.cmake DESTINATION ${CGAL_INSTALL_CMAKE_DIR} ) endif() diff --git a/Installation/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in b/Installation/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in new file mode 100644 index 00000000000..81ca96bb586 --- /dev/null +++ b/Installation/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in @@ -0,0 +1 @@ +set(CGAL_ROOT @CMAKE_INSTALL_PREFIX@) diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 2d3f7790135..497e706ed83 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -43,15 +43,17 @@ if(BRANCH_BUILD) endif() endforeach() else() - set(CGAL_ROOT ${CGAL_CONFIG_DIR}) - get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY) - if(NOT EXISTS ${CGAL_ROOT}/include/CGAL/config.h) + include(${CGAL_CONFIG_DIR}/CGALConfig-installation-dirs.cmake OPTIONAL RESULT_VARIABLE _has_installation_dirs) + if(NOT _has_installation_dirs) + set(CGAL_ROOT ${CGAL_CONFIG_DIR}) get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY) + if(NOT EXISTS ${CGAL_ROOT}/include/CGAL/config.h) + get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY) + endif() + if(NOT EXISTS ${CGAL_ROOT}/include/CGAL/config.h) + get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY) + endif() endif() - if(NOT EXISTS ${CGAL_ROOT}/include/CGAL/config.h) - get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY) - endif() - # not BRANCH_BUILD: it can be an installed CGAL, or the tarball layout if(EXISTS ${CGAL_CONFIG_DIR}/CGAL_add_test.cmake) # installed CGAL