CGALConfig.cmake: resolve symlinks before computing CGAL_CONFIG_DIR (fix #8521)#9390
Open
RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
Open
CGALConfig.cmake: resolve symlinks before computing CGAL_CONFIG_DIR (fix #8521)#9390RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
RajdeepKushwaha5 wants to merge 1 commit intoCGAL:mainfrom
Conversation
CGAL#8521) On distributions such as Arch Linux and Fedora where /lib is a symlink to /usr/lib, CMAKE_CURRENT_LIST_FILE may be reported as /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 when CGAL is properly installed. Fix: resolve the real path of CMAKE_CURRENT_LIST_FILE before extracting the directory. Use file(REAL_PATH) when available (CMake >= 3.19), with a get_filename_component(... REALPATH) fallback for CMake 3.15-3.18.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CGAL’s installed CMake package configuration on systems where /lib is a symlink to /usr/lib (e.g., Arch/Fedora), ensuring CGAL_ROOT is computed from the resolved (real) path of CMAKE_CURRENT_LIST_FILE so CGAL_FOUND is set correctly.
Changes:
- Resolve symlinks for
CMAKE_CURRENT_LIST_FILEbefore derivingCGAL_CONFIG_DIR. - Use
file(REAL_PATH)on CMake ≥ 3.19, with aget_filename_component(... REALPATH)fallback for older supported CMake versions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
On distributions such as Arch Linux and Fedora where
/libis a symlink to/usr/lib,CMAKE_CURRENT_LIST_FILEmay resolve to/lib/cmake/CGAL/CGALConfig.cmake. The subsequent chain ofget_filename_component(... DIRECTORY)calls then walks up through the symlink path, producingCGAL_ROOT=/instead of/usr, and the existence check forinclude/CGAL/config.hfails — even though CGAL is properly installed.Fix: resolve the real path of
CMAKE_CURRENT_LIST_FILEbefore extracting the directory. Usesfile(REAL_PATH)when available (CMake >= 3.19), with aget_filename_component(... REALPATH)fallback for CMake 3.15–3.18.Reproducer (from @lrineau's comment):
Release Management
file(REAL_PATH)from CMake 3.19) #8521