fix(CPM.cmake): work around FetchContent failure for cmake < 3.17#506
Open
Anton3 wants to merge 1 commit into
Open
fix(CPM.cmake): work around FetchContent failure for cmake < 3.17#506Anton3 wants to merge 1 commit into
Anton3 wants to merge 1 commit into
Conversation
TheLartians
requested changes
Sep 17, 2023
TheLartians
left a comment
Member
There was a problem hiding this comment.
Hey thanks for the issue and accompanying fix! Would it make sense to also add a test case for this, so we don't accidentally break it in the future?
Comment on lines
+50
to
+51
| get_directory_property(hasParent PARENT_DIRECTORY) | ||
| if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY OR ${hasParent}) |
Member
There was a problem hiding this comment.
Could you add a comment above this explaining what issue this check fixes?
Also I feel some parenthesis could be useful around the NOT expression as I'm confused by CMake's operator precedence.
| if(CPM_DIRECTORY) | ||
| if(${CMAKE_VERSION} VERSION_LESS "3.17.0") | ||
| get_directory_property(hasParent PARENT_DIRECTORY) | ||
| if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY OR ${hasParent}) |
Member
There was a problem hiding this comment.
Additionally the test cases seem to fail if hasParent is an empty string.
1: CMake Error at /home/runner/work/CPM.cmake/CPM.cmake/cmake/CPM.cmake:51 (if):
1: if given arguments:
1:
1: "NOT" "CPM_DIRECTORY" "STREQUAL" "CPM_CURRENT_DIRECTORY" "OR"
1:
1: Unknown arguments specified
1: Call Stack (most recent call first):
It should be fixable by adding quotation marks.
Suggested change
| if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY OR ${hasParent}) | |
| if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY OR "${hasParent}") |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #505