Skip to content

Commit

Permalink
CPM_DIRECTORY always stores absolute non symlink paths (#379)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
robertmaynard authored Jul 31, 2022
1 parent ede6045 commit 4605d32
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

set(CURRENT_CPM_VERSION 1.0.0-development-version)

get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
if(CPM_DIRECTORY)
if(NOT CPM_DIRECTORY STREQUAL CMAKE_CURRENT_LIST_DIR)
if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY)
if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION)
message(
AUTHOR_WARNING
Expand Down Expand Up @@ -93,7 +94,7 @@ set(CPM_VERSION
CACHE INTERNAL ""
)
set(CPM_DIRECTORY
${CMAKE_CURRENT_LIST_DIR}
${CPM_CURRENT_DIRECTORY}
CACHE INTERNAL ""
)
set(CPM_FILE
Expand Down

0 comments on commit 4605d32

Please sign in to comment.