Fix the *installed* header-only CGALConfig.cmake

The previous installed version of `CGALConfig.cmake`, when
`CGAL_HEADER_ONLY` is true, was hard-coding a path `../../../`,
relative to the location of itself. It might be that the CMake modules
are not installed in a sub-directory with three components, relatively
to the prefix.

That way of doing it buggy. And that triggered issue with the cgal
port in vcpkg:

  https://github.com/Microsoft/vcpkg/pull/5734

This patch is just another hack: it hardcodes that the relative path
can be any of:

  - `../`,
  - `../../`, or
  - `../../../`.
This commit is contained in:
Laurent Rineau 2019-03-19 16:49:31 +01:00
parent 43d1948396
commit 4782ea1665
1 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,7 @@ function(cgal_detect_branch_build VAR_NAME)
endif()
endfunction()
set(CGAL_FOUND FALSE)
cgal_detect_branch_build(BRANCH_BUILD)
if(BRANCH_BUILD)
set(CGAL_ROOT ${CGAL_CONFIG_DIR})
@ -44,8 +45,12 @@ if(BRANCH_BUILD)
else()
set(CGAL_ROOT ${CGAL_CONFIG_DIR})
get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY)
get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY)
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()
# not BRANCH_BUILD: it can be an installed CGAL, or the tarball layout
if(EXISTS ${CGAL_CONFIG_DIR}/CGAL_add_test.cmake)