Skip to content
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 additional arguments after shorthand syntax #546

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SGSSGene
Copy link
Contributor

@SGSSGene SGSSGene commented Mar 11, 2024

This allows to combine the shorthand syntax with additional arguments:

CPMAddPackage("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"
)

@TheLartians TheLartians requested a review from iboB March 12, 2024 18:13
Copy link
Member

@TheLartians TheLartians left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the PR! In general I like the idea of mixing the short syntax with additional arguments and think this is a good approach in doing so. Could you perhaps add an integration test case for this?

Also I'm not sure but it could be that the cmake-format config might need to be updated for this new syntax.

README.md Outdated Show resolved Hide resolved
@SGSSGene
Copy link
Contributor Author

Hey, thanks for the PR! In general I like the idea of mixing the short syntax with additional arguments and think this is a good approach in doing so. Could you perhaps add an integration test case for this?

Also I'm not sure but it could be that the cmake-format config might need to be updated for this new syntax.

Yes, there are a few things that need to be updated. I wanted to discuss, if there is any chance on success before investing to much time.
I will look through everything and update this PR

@SGSSGene SGSSGene marked this pull request as draft March 12, 2024 18:28
@SGSSGene SGSSGene force-pushed the feat/shorthand_with_options branch 2 times, most recently from 4eaa26b to 1dfebcd Compare March 26, 2024 10:21
@SGSSGene SGSSGene marked this pull request as ready for review March 26, 2024 10:37
@SGSSGene SGSSGene requested a review from TheLartians March 26, 2024 10:40
Copy link
Member

@TheLartians TheLartians left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the changes look good, just want to make sure that the test actually does what it should. One thing that I notice from the readme changes is that having a mix of single + named arguments looks quite inconsistent and therefore harder to read.

How would you feel if we instead make a compromise by introducing a URI argument that takes the role of the single argument instead?

This would allow us to do

CPMAddPackage(
  URI "gh:nlohmann/[email protected]"
  OPTIONS "JSON_BuildTests OFF"
)

Instead of

CPMAddPackage("gh:nlohmann/[email protected]"
  OPTIONS "JSON_BuildTests OFF"
)

To me this looks much nicer, even though I know CMake itself likes to use this mix of syntax. Of course, using only the single argument syntax should continue to be valid.


create_with_commit_sha.()
update_to_version_1.()
update_with_option_off_and_build.()
update_with_option_off_and_build_with_shorthand_syntax.()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like having this run as part of a larger test makes reasoning about the test itself difficult. Do you think you could move checking the shorthand extra arguments into its own isolated test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👍

@SGSSGene
Copy link
Contributor Author

SGSSGene commented Apr 14, 2024

Thanks, the changes look good, just want to make sure that the test actually does what it should. One thing that I notice from the readme changes is that having a mix of single + named arguments looks quite inconsistent and therefore harder to read.

How would you feel if we instead make a compromise by introducing a URI argument that takes the role of the single argument instead?

This would allow us to do

CPMAddPackage(
  URI "gh:nlohmann/[email protected]"
  OPTIONS "JSON_BuildTests OFF"
)

Instead of

CPMAddPackage("gh:nlohmann/[email protected]"
  OPTIONS "JSON_BuildTests OFF"
)

To me this looks much nicer, even though I know CMake itself likes to use this mix of syntax. Of course, using only the single argument syntax should continue to be valid.

I am not so sure of the URI idea. My biased view:
Pro:

  • It does look nice.

Con:

  • Not easy extendible from shorthand syntax, my main idea was that I can just slap on further 'OPTIONS', with this I also need to add a URI
  • Harder to document. Currently we have two cases: 1. normal usage, 2. shorthand syntax. With URI we kind of have to split the 'normal usage' into two cases. I don't see how this can be documented in any understandable way. (Assuming we don't delete the 2. shorthand syntax)
  • Also I think it is harder to implement (not so sure about this)

I like to think about it similar to how target_link_libraries works. First I set a free given parameter, and than I add all the other with PRIVATE,PUBLIC or INTERFACE.

@SGSSGene SGSSGene force-pushed the feat/shorthand_with_options branch from 26478df to 668fb00 Compare June 16, 2024 19:38
@Richardk2n
Copy link

Gentleman, how is this coming along?
Is there anything preventing this from getting merged other than the URI or not URI question?

@SGSSGene
Copy link
Contributor Author

The question of URI or not URI is up to @TheLartians . Both is fine to me, @TheLartians needs to decide what he would like.

The only big stopper for the URI idea for me is, I think URI is a bad keyword, since it is not a URI?!
Any argument for saying it is a URI or an alternative keyword would be helpful.

This allows to combine the shorthand syntax with additional arguments:
```
CPMAddPackage("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"
)
```
@SGSSGene
Copy link
Contributor Author

SGSSGene commented Nov 7, 2024

@TheLartians : I created a alternative version, with an explicit URI #617.
The version with URI also does not set "EXCLUDE_FROM_ALL;YES;SYSTEM;YES;" by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants