Skip to content

Commit cabec72

Browse files
authored
CGALConfig.cmake: resolve symlinks before computing CGAL_CONFIG_DIR (fix #8521) (#9390)
## Summary of Changes On distributions such as Arch Linux and Fedora where `/lib` is a symlink to `/usr/lib`, `CMAKE_CURRENT_LIST_FILE` may resolve to `/lib/cmake/CGAL/CGALConfig.cmake`. The subsequent chain of `get_filename_component(... DIRECTORY)` calls then walks up through the symlink path, producing `CGAL_ROOT=/` instead of `/usr`, and the existence check for `include/CGAL/config.h` fails — even though CGAL is properly installed. **Fix:** resolve the real path of `CMAKE_CURRENT_LIST_FILE` before extracting the directory. Uses `file(REAL_PATH)` when available (CMake >= 3.19), with a `get_filename_component(... REALPATH)` fallback for CMake 3.15–3.18. Reproducer (from @lrineau's comment): ``` CGAL_DIR=/lib/cmake/CGAL cmake . -B build # → CGAL_FOUND=FALSE, even though CGAL is installed ``` ## Release Management * Affected package(s): Installation * Issue(s) solved (if any): fix #8521 * License and copyright ownership: same as CGAL
2 parents 5c2ca80 + 80aec6e commit cabec72

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Installation/lib/cmake/CGAL/CGALConfig.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
# This file is the CGALConfig.cmake for a header-only CGAL installation
33
#
44

5+
cmake_minimum_required(VERSION 3.22...3.31)
6+
57
# For CGAL_CreateSingleSourceCGALProgram.cmake
68
set( CGAL_REQUESTED_COMPONENTS ${CGAL_FIND_COMPONENTS} )
79

810
set(CGAL_LIBRARIES CGAL)
911

10-
get_filename_component(CGAL_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
12+
# Resolve symlinks before extracting the directory so that the subsequent
13+
# DIRECTORY walk produces a correct CGAL_ROOT (e.g. /lib -> /usr/lib on
14+
# Arch Linux). See https://github.com/CGAL/cgal/issues/8521
15+
file(REAL_PATH "${CMAKE_CURRENT_LIST_FILE}" _cgal_config_realpath)
16+
get_filename_component(CGAL_CONFIG_DIR "${_cgal_config_realpath}" DIRECTORY)
1117

1218
function(cgal_detect_branch_build VAR_NAME)
1319
if(IS_DIRECTORY ${CGAL_CONFIG_DIR}/../../../../Installation/package_info/Installation/)

0 commit comments

Comments
 (0)