Skip to content

Commit

Permalink
Simplified local-package with TODO for allowing as extension-point
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigHutchinson committed Mar 8, 2023
1 parent 8f58d23 commit 68a0f74
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -611,18 +611,16 @@ function(CPMAddPackage)
return()
endif()

# Check for ENV overide for local package-source when not already defined. NOTE: Uses a recursive
# CPMAddPackage call where `CPM_${CPM_ARGS_NAME}_SOURCE` == "" which causes first if-case to stop
# recusrion
if(CPM_${CPM_ARGS_NAME}_SOURCE)
file(TO_CMAKE_PATH "${CPM_${CPM_ARGS_NAME}_SOURCE}" PACKAGE_SOURCE)
elseif(DEFINED ENV{CPM_${CPM_ARGS_NAME}_SOURCE})
file(TO_CMAKE_PATH "$ENV{CPM_${CPM_ARGS_NAME}_SOURCE}" PACKAGE_SOURCE)
# @TODO Allow this as from a user-extension point for locating package source e.g. Check for ENV
# overide for local package-source
if(NOT DEFINED CPM_${CPM_ARGS_NAME}_SOURCE AND DEFINED ENV{CPM_${CPM_ARGS_NAME}_SOURCE})
file(TO_CMAKE_PATH $ENV{CPM_${CPM_ARGS_NAME}_SOURCE} CPM_${CPM_ARGS_NAME}_SOURCE)
endif()

# Check for manual overrides
if(NOT CPM_ARGS_FORCE AND NOT "${PACKAGE_SOURCE}" STREQUAL "")
set(CPM_${CPM_ARGS_NAME}_SOURCE "") # Assign empty to prevent recursion
if(NOT CPM_ARGS_FORCE AND NOT "${CPM_${CPM_ARGS_NAME}_SOURCE}" STREQUAL "")
set(PACKAGE_SOURCE ${CPM_${CPM_ARGS_NAME}_SOURCE})
set(CPM_${CPM_ARGS_NAME}_SOURCE "")
CPMAddPackage(
NAME "${CPM_ARGS_NAME}"
SOURCE_DIR "${PACKAGE_SOURCE}"
Expand Down

0 comments on commit 68a0f74

Please sign in to comment.