Skip to content

Commit 4605d32

Browse files
CPM_DIRECTORY always stores absolute non symlink paths (#379)
* CPM_DIRECTORY always stores absolute non symlink paths When CPM is brought into a project via downloading it will be placed in the build directory. When the build directory is a symlink the CPM_DIRECTORY value will hold the symlink value. This means that trying to run CMake via the real build directory will cause CPM to fail since it considers the current CMAKE_CURRENT_LIST_DIR to be different and will early exit. This resolves the issue be always getting CMake to resolve symlinks before comparing paths for CPM_DIRECTORY. * Refactor logic based on PR review
1 parent ede6045 commit 4605d32

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmake/CPM.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
3030

3131
set(CURRENT_CPM_VERSION 1.0.0-development-version)
3232

33+
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
3334
if(CPM_DIRECTORY)
34-
if(NOT CPM_DIRECTORY STREQUAL CMAKE_CURRENT_LIST_DIR)
35+
if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY)
3536
if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION)
3637
message(
3738
AUTHOR_WARNING
@@ -93,7 +94,7 @@ set(CPM_VERSION
9394
CACHE INTERNAL ""
9495
)
9596
set(CPM_DIRECTORY
96-
${CMAKE_CURRENT_LIST_DIR}
97+
${CPM_CURRENT_DIRECTORY}
9798
CACHE INTERNAL ""
9899
)
99100
set(CPM_FILE

0 commit comments

Comments
 (0)