Fix: CMAKE_MODULE_PATH contents is being overriden with -D contents, not merged with #2946
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.
Current code defines the CMAKE_MODULE_PATH as a cache variable[1]. As a result, if one passes the
-DCMAKE_MODULE_PATH=<something>
to the cmake invocation, its contents override the paths to netcdf-bundled cmake modules. Based on code and attempt to use Shell-PATH-like expansion, it looks as unintended behavior. Moreover, it's quite common in CI/CD systems to pass extra cmake module paths (e.g., we have to do so for AWS SDKs, on which netcdf depends optionally). This tiny fix replaces that withlist(APPEND)
which adds paths to netcdf-provided modules to the user-passed -DCMAKE_MODULE_PATH. At the same time, if user doesn't passes this variable - the previous behavior is preserved, as netcdf paths will be added to that CMAKE_MODULE_PATH currently holds (if netcdf is built as standalone project and not as a subproject of our project - it's an empty list).References:
[1]
netcdf-c/CMakeLists.txt
Line 21 in d694d38