Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect FETCHCONTENT_BASE_DIR if set by a user #244

Merged
merged 2 commits into from
Apr 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,12 @@ function(CPMAddPackage)
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${download_directory})
if(EXISTS ${download_directory})
# avoid FetchContent modules to improve performance
set(${CPM_ARGS_NAME}_BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/${lower_case_name}-build)
if(DEFINED FETCHCONTENT_BASE_DIR)
# respect FETCHCONTENT_BASE_DIR if set
set(${CPM_ARGS_NAME}_BINARY_DIR ${FETCHCONTENT_BASE_DIR}/${lower_case_name}-build)
else()
set(${CPM_ARGS_NAME}_BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/${lower_case_name}-build)
endif()
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
set(${CPM_ARGS_NAME}_ADDED YES)
set(${CPM_ARGS_NAME}_SOURCE_DIR ${download_directory})
cpm_add_subdirectory(
Expand All @@ -546,7 +551,12 @@ function(CPMAddPackage)
endif()

# remove timestamps so CMake will re-download the dependency
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/${lower_case_name}-subbuild)
if(DEFINED FETCHCONTENT_BASE_DIR)
# respect FETCHCONTENT_BASE_DIR if set
file(REMOVE_RECURSE ${FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild)
else()
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/${lower_case_name}-subbuild)
endif()
set(PACKAGE_INFO "${PACKAGE_INFO} to ${download_directory}")
endif()
endif()
Expand Down