From 16c6a3b0af39c2ac8fb6f97e056a745d862ca191 Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Mon, 18 Sep 2023 15:37:35 +0200 Subject: [PATCH] Fix download_command by declaring it a multi-value option (#473) --- cmake/CPM.cmake | 6 ++---- test/integration/test_download_command.rb | 25 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 test/integration/test_download_command.rb diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 8d0be4c7..854b9343 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -528,7 +528,6 @@ function(CPMAddPackage) BITBUCKET_REPOSITORY GIT_REPOSITORY SOURCE_DIR - DOWNLOAD_COMMAND FIND_PACKAGE_ARGUMENTS NO_CACHE SYSTEM @@ -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}") @@ -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}) diff --git a/test/integration/test_download_command.rb b/test/integration/test_download_command.rb new file mode 100644 index 00000000..e1999658 --- /dev/null +++ b/test/integration/test_download_command.rb @@ -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