parsing error
ScottBailey opened this issue · comments
It looks like the arguments sent to cmake_parse_args
are incorrect.
I believe the following code:
set(oneValueArgs
NAME
FORCE
VERSION
GIT_TAG
DOWNLOAD_ONLY
GITHUB_REPOSITORY
GITLAB_REPOSITORY
BITBUCKET_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
FIND_PACKAGE_ARGUMENTS
NO_CACHE
SYSTEM
GIT_SHALLOW
EXCLUDE_FROM_ALL
SOURCE_SUBDIR
)
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
could look something more like this:
set(oneValueArgs
NAME
VERSION
GIT_TAG
GITHUB_REPOSITORY
GITLAB_REPOSITORY
BITBUCKET_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
FIND_PACKAGE_ARGUMENTS
SOURCE_SUBDIR
)
set(optionArgs SYSTEM NO_CACHE GIT_SHALLOW DOWNLOAD_ONLY FORCE)
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
cmake_parse_arguments(CPM_ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
I'm finding this defect with this:
PMAddPackage(
NAME glew
URL https://github.com/Perlmint/glew-cmake/archive/refs/tags/glew-cmake-2.2.0.tar.gz
URL_HASH SHA256=cdd82afba80f7cf34548cf5c902240d6721ec5a27ec9e075851b4a3a79ec6907
SYSTEM
PATCH_COMMAND
"${PATCH_EXE}" -p1 < "${CMAKE_CURRENT_LIST_DIR}/glew_install_fix.patch"
OPTIONS
"glew-cmake_BUILD_SHARED Off"
"ONLY_LIBS On"
)
My current workaround is to set "SYSTEM SYS"; however, I'm pretty sure this is broken, too.
EDIT: corrected an assumption with further testing.
That does sound and look reasonable, thanks for the report! I don't have time to look into it atm but am happy to review any PR addressing this.
That does sound and look reasonable, thanks for the report! I don't have time to look into it atm but am happy to review any PR addressing this.
I think it's a super easy fix. If you have a "good first issue" label, this could go there, otherwise I will get to it as soon as I can.
Good point! One potential issue I see however is that this might break backwards compatibility as the previous parameters will now be treated as new arguments, so it could make sense to restrict this to the actually broken arguments like SYSTEM
. Also having an integration test would be great to avoid future regressions.
Good point! One potential issue I see however is that this might break backwards compatibility as the previous parameters will now be treated as new arguments, so it could make sense to restrict this to the actually broken arguments like
SYSTEM
. Also having an integration test would be great to avoid future regressions.
I think it's a real risk that there are projects out there with workarounds that will misbehave once this is fixed. I am one, for example. None the less, I believe fixing this is "The Right thing to do." Furthermore, I hope that anyone building a release has CPM pinned to specific version - which I've done in my own project. This also is the right thing to do.
I listed other optionArgs
that looked, at first glance, like they might suffer the same defect as SYSTEM
. Whoever updates this should evaluate that.
And OF COURSE we should have regression tests!!! When I was writing this I was thinking about how that might be done. :-)
I might be able to get to this on Friday.
Great, looking forward!
After further investigation and testing, I have concluded that this is working as designed. IF I were to suggest a change here it could be additional documentation and/or, possibly, a sanity check of CPM_ARG_*
values. Neither are strictly necessary, though, and I will close this as works as designed.
Thanks for the update! Just to be sure I understand correctly, the flags like SYSTEM
etc are actually working correctly, however feel unintuitive as they are one-value arguments here as opposed to the option arguments used by related CMake functions?
@TheLartians Correct. This was a user RTFM error on my part. Sorry.