Skip to content

Commit

Permalink
Fix download_command by declaring it a multi-value option (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLartians committed Sep 18, 2023
1 parent 52ee7c9 commit 16c6a3b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ function(CPMAddPackage)
BITBUCKET_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
DOWNLOAD_COMMAND
FIND_PACKAGE_ARGUMENTS
NO_CACHE
SYSTEM
Expand All @@ -537,7 +536,7 @@ function(CPMAddPackage)
SOURCE_SUBDIR
)

set(multiValueArgs URL OPTIONS)
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)

cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")

Expand Down Expand Up @@ -1098,13 +1097,12 @@ function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT)
GITLAB_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
DOWNLOAD_COMMAND
FIND_PACKAGE_ARGUMENTS
NO_CACHE
SYSTEM
GIT_SHALLOW
)
set(multiValueArgs OPTIONS)
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

foreach(oneArgName ${oneValueArgs})
Expand Down
25 changes: 25 additions & 0 deletions test/integration/test_download_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative './lib'

# Tests using a multi-argumenet download command to fetch a dependency

class DownloadCommand < IntegrationTest

def test_fetch_dependency_using_download_command
prj = make_project from_template: 'using-adder'

prj.create_lists_from_default_template package: <<~PACK
set(DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/_deps/testpack-adder-src)
CPMAddPackage(
NAME testpack-adder
SOURCE_DIR ${DOWNLOAD_DIR}
DOWNLOAD_COMMAND git clone --depth 1 --branch v1.0.0 https://github.com/cpm-cmake/testpack-adder.git ${DOWNLOAD_DIR}
OPTIONS "ADDER_BUILD_TESTS OFF"
)
PACK

# configure with unpopulated cache
assert_success prj.configure
assert_success prj.build
end

end

0 comments on commit 16c6a3b

Please sign in to comment.