-
Notifications
You must be signed in to change notification settings - Fork 190
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
feature: allow URI to use shorthand syntax with additional options #617
base: master
Are you sure you want to change the base?
Conversation
8686474
to
82b650b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks a lot for this alternative implementation and thanks for your patience, as I'm quite busy these days! I personally much prefer this alternative to the other PR, as it looks much cleaner and is not mixing different ways to pass arguments (I know it's a common CMake style, so this is a very subjective take). I was hoping to hear some input from @iboB on this, but I think he is very busy as well.
Important difference to #546, it does not set EXCLUDE_FROM_ALL;YES;SYSTEM;YES;
Can you elaborate what the advantage is? I think I it would be intuitive for both CPMAddPackage("gh:nlohmann/[email protected]")
and CPMAddPackage(URI "gh:nlohmann/[email protected]")
to work the same way, so IMO both versions should set the same flags.
Sorry again for taking so long to respond. I have some more time during the holidays, so happy to help get this merged asap.
I think I found the answer in the other PR:
I see your concern, though I feel it's quite easy to understand in the docs:
|
PR #546 basic idea was, take the "short hand" syntax and allow extended options. I will adjust this PR accordingly |
This allows to combine the shorthand syntax with URI and additional arguments: ``` CPMAddPackage(URI "gh:nlohmann/[email protected]" OPTIONS "JSON_BUildTests OFF") ``` This is much shorter than the longer syntax way of writing: ``` CPMAddPackage( NAME nlohmann_json VERSION 3.9.1 GITHUB_REPOSITORY nlohmann/json OPTIONS "JSON_BuildTests OFF" ) ```
82b650b
to
1cb8a5a
Compare
This new version automatically sets I added another note below the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates! I really like how it's turning out. There are some small stylistic and documentation issues left and then I'm happy to merge this!
@@ -65,6 +65,7 @@ Afterwards, any targets defined in the dependency can be used directly. | |||
|
|||
```cmake | |||
CPMAddPackage( | |||
URI # shorthand including repo, name, version and tag (see shorthand syntax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the extra docs! Tbh I'm not sure if it won't be confusing that we show URI
here, but also NAME
and VERSION
as only one or the other should be specified. Maybe we can leave it out here and keep this section as before to make it more obvious that the shorthand syntax is a way to replace the name and source info?
CPMAddPackage(URI "gh:nlohmann/[email protected]" | ||
OPTIONS "JSON_BuildTests OFF" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the formatting consistent with the other examples.
CPMAddPackage(URI "gh:nlohmann/[email protected]" | |
OPTIONS "JSON_BuildTests OFF" | |
) | |
CPMAddPackage( | |
URI "gh:nlohmann/[email protected]" | |
OPTIONS "JSON_BuildTests OFF" | |
) |
@@ -112,6 +115,13 @@ CPMAddPackage("https://example.com/my-package-1.2.3.zip#MD5=68e20f674a48be38d60e | |||
CPMAddPackage("https://example.com/[email protected]") | |||
``` | |||
|
|||
Additionally, the shorthand syntax can be used with the long version, using the `URI` specifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make it more clear that the new syntax allows for specifying additional arguments with the shorthand syntax:
Additionally, the shorthand syntax can be used with the long version, using the `URI` specifier. | |
Additionally, if needed, extra arguments can be provided by using the shorthand syntax with the `URI` specifier. |
elseif(argnLength GREATER 1 AND "${ARGV0}" STREQUAL "URI") | ||
list(REMOVE_AT ARGN 0 1) # remove "URI gh:<...>@version#tag" | ||
cpm_parse_add_package_single_arg("${ARGV1}" ARGV0) | ||
|
||
set(ARGN "${ARGV0};EXCLUDE_FROM_ALL;YES;SYSTEM;YES;${ARGN}") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either make it clear in the docs that URI
can only be used as a first argument or alternatively, we can just add URI
to the oneValueArgs
and call cpm_parse_add_package_single_arg
if CPM_ARGS_URI
is defined.
# we should end up with two executables | ||
# * simple - the simple example from adder | ||
# * using-adder - for this project | ||
# ...and notably no test for adder, which must be disabled from the option override from above | ||
assert_equal ['simple', 'test-adding', 'using-adder'], exes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs to be changed, as we are now expecting the tests to be built.
exes = Dir[exe_dir + '/**/*'].filter { | ||
# on multi-configuration generators (like Visual Studio) the executables will be in bin/<Config> | ||
# also filter-out other artifacts like .pdb or .dsym | ||
!File.directory?(_1) && File.stat(_1).executable? | ||
}.map { | ||
# remove .exe extension if any (there will be one on Windows) | ||
File.basename(_1, '.exe') | ||
}.sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very important, but this code is now duplicated three times in the test case. Could it be more readable if we turn this it into a method and call it three times?
(This is an alternative to PR #546 )
This allows to combine the shorthand syntax by using URI with additional arguments:
This is much shorter than the longer syntax way of writing:
Important difference to #546, it does not setEXCLUDE_FROM_ALL;YES;SYSTEM;YES;