From 08a42cf35b94b147eb4ac3b499bb32a1cf970358 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 11 Oct 2019 11:00:29 +0200 Subject: [PATCH] Fix the detection of CGAL_ROOT On Debian, CMake files are in `/usr/local/lib/x86_64-linux-gnu/cmake/CGAL/` are our previous heuristic fails. --- Installation/CMakeLists.txt | 3 +++ .../CGAL/CGALConfig-installation-dirs.cmake.in | 1 + Installation/lib/cmake/CGAL/CGALConfig.cmake | 16 +++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 Installation/lib/cmake/CGAL/CGALConfig-installation-dirs.cmake.in 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