-
Notifications
You must be signed in to change notification settings - Fork 224
Preserving forwarding of empty string arguments using placeholder strings #699
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
Open
TheLartians
wants to merge
27
commits into
master
Choose a base branch
from
lars/preserve_empty_strings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b70460a
Test forwarding of arguments to `FetchCOntent_Declare`
CraigHutchinson cbe5144
Preserving forwarding of empty string arguments
CraigHutchinson b847af6
Support EVAL CODE on CMake <3.18
CraigHutchinson 5c1ce67
Fix docs typo
CraigHutchinson f4fd660
Maintain key-value CMake formatting
CraigHutchinson a49358e
refactor empty argument passing to not require eval
TheLartians 6b5cd6f
add removed test cases
TheLartians 6b49fcf
Merge branch 'master' of https://github.com/cpm-cmake/CPM.cmake into …
TheLartians 2eb31c5
Merge branch 'master' of https://github.com/cpm-cmake/CPM.cmake into …
TheLartians 0bc3c83
ensure to unset undefined variables
TheLartians e406086
revert back to parsing into the correct prefix
TheLartians 151b472
eval seems to be needed after all
TheLartians d6f2b26
add comment for cpm_cmake_eval
TheLartians 20bd8c4
support whitespaces in test artefact removal
TheLartians b3b716f
use list functions in encoding / decoding
TheLartians d5c2595
support arbitrary CURRENT_LIST_DIR paths
TheLartians ae615ba
support forwarding the __CPM_EMPTY_ARG string
TheLartians 4a34fbb
explicitly test for GIT_SUBMODULES
TheLartians 35d1103
quote the eval paths
TheLartians 9a98a0a
move the bracket argument quoting to a helper function
TheLartians fe174e3
remove escape escaping and update test case
TheLartians d6e38c0
quote CMAKE_CURRENT_LIST_DIR
TheLartians 658fcc4
add cpm_ prefix and fix typo in cpm_quote_as_bracket_string_literal
TheLartians 899b0c8
escape and unescape escape characters
TheLartians 396512e
Merge branch 'master' of https://github.com/cpm-cmake/CPM.cmake into …
TheLartians 89208f7
Merge branch 'master' of https://github.com/cpm-cmake/CPM.cmake into …
TheLartians dfca5f2
Merge branch 'master' into lars/preserve_empty_strings
TheLartians File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||
|
|
||
| include(${CPM_PATH}/CPM.cmake) | ||
| include(${CPM_PATH}/testing.cmake) | ||
|
|
||
| set(input "a;;b;c;;;;d\\ef;g;;__CPM_EMPTY_ARG;") | ||
| cpm_encode_empty_arguments("${input}" encoded) | ||
| foreach(arg IN LISTS encoded) | ||
| assert_not_equal("${arg}" "") | ||
| endforeach() | ||
| cpm_decode_empty_arguments("${encoded}" decoded) | ||
| assert_equal("${decoded}" "${input}") | ||
|
|
||
| # ignore source cache if set | ||
| set(CPM_SOURCE_CACHE "") | ||
|
|
||
| # Intercept underlying `FetchContent_Declare` | ||
| function(FetchContent_Declare) | ||
| set_property(GLOBAL PROPERTY last_FetchContent_Declare_ARGN "${ARGN}") | ||
| set_property( | ||
| GLOBAL PROPERTY last_FetchContent_Declare_CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_DIR}" | ||
| ) | ||
| endfunction() | ||
| cpm_declare_fetch(PACKAGE VERSION INFO EMPTY "" ANOTHER) | ||
|
|
||
| # TEST:`cpm_declare_fetch` shall forward empty arguments | ||
| get_property(last_FetchContent_Declare_ARGN GLOBAL PROPERTY last_FetchContent_Declare_ARGN) | ||
| assert_equal("${last_FetchContent_Declare_ARGN}" "PACKAGE;VERSION;INFO;EMPTY;;ANOTHER") | ||
| get_property( | ||
| last_FetchContent_Declare_CMAKE_CURRENT_LIST_DIR GLOBAL | ||
| PROPERTY last_FetchContent_Declare_CMAKE_CURRENT_LIST_DIR | ||
| ) | ||
| assert_equal("${last_FetchContent_Declare_CMAKE_CURRENT_LIST_DIR}" "${CMAKE_CURRENT_LIST_DIR}") | ||
|
|
||
| # TEST:`CPMDeclarePackage` shall store all including empty | ||
| CPMDeclarePackage(FOO EMPTY "" ANOTHER) | ||
| assert_equal("${CPM_DECLARATION_FOO}" "EMPTY;;ANOTHER") | ||
|
|
||
| # Stub the actual fetch | ||
| set(fibonacci_POPULATED YES) | ||
| set(fibonacci_SOURCE_DIR ".") | ||
| set(fibonacci_BINARY_DIR ".") | ||
| macro(FetchContent_GetProperties) | ||
|
|
||
| endmacro() | ||
|
|
||
| # TEST:`CPMAddPackage` shall call `FetchContent_declare` with unmodified arguments including any | ||
| # Empty-string arguments | ||
| CPMAddPackage( | ||
| NAME fibonacci | ||
| GIT_REPOSITORY https://github.com/cpm-cmake/testpack-fibonacci.git GIT_SUBMODULES "" | ||
| VERSION 1.2.3 EMPTY_OPTION "" COMMAND_WITH_EMPTY_ARG foo "" bar | ||
| ) | ||
| get_property(last_FetchContent_Declare_ARGN GLOBAL PROPERTY last_FetchContent_Declare_ARGN) | ||
| assert_equal( | ||
| "${last_FetchContent_Declare_ARGN}" | ||
| "fibonacci;GIT_SUBMODULES;;EMPTY_OPTION;;COMMAND_WITH_EMPTY_ARG;foo;;bar;GIT_REPOSITORY;https://github.com/cpm-cmake/testpack-fibonacci.git;GIT_TAG;v1.2.3" | ||
| ) | ||
|
|
||
| # Intercept underlying `cpm_add_package_multi_arg` | ||
| function(CPMAddPackage) | ||
| set_property(GLOBAL PROPERTY last_cpmaddpackage_argn "${ARGN}") | ||
| endfunction() | ||
|
|
||
| # TEST: CPM Module file shall store all arguments including empty strings | ||
| include(${CPM_MODULE_PATH}/Findfibonacci.cmake) | ||
|
|
||
| get_property(last_cpmaddpackage_argn GLOBAL PROPERTY last_cpmaddpackage_argn) | ||
| assert_equal( | ||
| "${last_cpmaddpackage_argn}" | ||
| "NAME;fibonacci;GIT_REPOSITORY;https://github.com/cpm-cmake/testpack-fibonacci.git;GIT_SUBMODULES;;VERSION;1.2.3;EMPTY_OPTION;;COMMAND_WITH_EMPTY_ARG;foo;;bar" | ||
| ) | ||
|
|
||
| # remove generated files | ||
| file(REMOVE_RECURSE "${CPM_MODULE_PATH}") | ||
| file(REMOVE "${CPM_PACKAGE_LOCK_FILE}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.