1+ cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
2+
3+ include (${CPM_PATH} /CPM.cmake)
4+ include (${CPM_PATH} /testing.cmake)
5+
6+ # Intercept underlying `FetchContent_Declare`
7+ function (FetchContent_Declare)
8+ set_property (GLOBAL PROPERTY last_FetchContent_Declare_ARGN "${ARGN} " )
9+ endfunction ()
10+ cpm_declare_fetch( PACKAGE VERSION INFO EMPTY "" ANOTHER )
11+
12+ # TEST:`cpm_declare_fetch` shall forward empty arguments
13+ get_property (last_FetchContent_Declare_ARGN GLOBAL PROPERTY last_FetchContent_Declare_ARGN)
14+ assert_equal("${last_FetchContent_Declare_ARGN} " "PACKAGE;EMPTY;;ANOTHER" )
15+
16+ # TEST:`CPMDeclarePackage` shall store all including empty
17+ CPMDeclarePackage( FOO EMPTY "" ANOTHER )
18+ assert_equal("${CPM_DECLARATION_FOO} " "EMPTY;;ANOTHER" )
19+
20+ # Stub the actual fetch
21+ set (fibonacci_POPULATED YES )
22+ set (fibonacci_SOURCE_DIR "." )
23+ set (fibonacci_BINARY_DIR "." )
24+ macro (FetchContent_GetProperties)
25+ endmacro ()
26+
27+ # TEST:`CPMAddPackage` shall call `FetchContent_declare` with unmodified
28+ # arguments including any Empty-string arguments
29+ CPMAddPackage(
30+ NAME fibonacci
31+ GIT_REPOSITORY https://github.com/cpm-cmake/testpack-fibonacci.git
32+ VERSION 1.2.3
33+ EMPTY_OPTION ""
34+ COMMAND_WITH_EMPTY_ARG foo "" bar
35+ )
36+ get_property (last_FetchContent_Declare_ARGN GLOBAL PROPERTY last_FetchContent_Declare_ARGN)
37+ assert_equal("${last_FetchContent_Declare_ARGN} "
38+ "fibonacci;EMPTY_OPTION;;COMMAND_WITH_EMPTY_ARG;foo;;bar;GIT_REPOSITORY;https://github.com/cpm-cmake/testpack-fibonacci.git;GIT_TAG;v1.2.3" )
39+
40+ # Intercept underlying `cpm_add_package_multi_arg`
41+ function (cpm_add_package_multi_arg)
42+ set_property (GLOBAL PROPERTY last_cpm_add_package_multi_arg_ARGN "${ARGN} " )
43+ endfunction ()
44+
45+ # TEST: CPM Module file shall store all arguments including empty strings
46+ include (${CPM_MODULE_PATH} /Findfibonacci.cmake)
47+ get_property (last_cpm_add_package_multi_arg_ARGN GLOBAL PROPERTY last_cpm_add_package_multi_arg_ARGN)
48+ assert_equal("${last_cpm_add_package_multi_arg_ARGN} "
49+ "NAME;fibonacci;GIT_REPOSITORY;https://github.com/cpm-cmake/testpack-fibonacci.git;VERSION;1.2.3;EMPTY_OPTION;;COMMAND_WITH_EMPTY_ARG;foo;;bar" )
50+
51+ # remove generated files
52+ file (REMOVE_RECURSE ${CPM_MODULE_PATH} )
53+ file (REMOVE ${CPM_PACKAGE_LOCK_FILE} )
0 commit comments