cmake: robustify base path in local file reference#22187
Closed
vszakats wants to merge 1 commit into
Closed
Conversation
To make the macro find this file also when used elsewhere than the root `CMakeLists.txt`.
There was a problem hiding this comment.
Pull request overview
This PR updates the curl_internal_test() CMake macro to reference CurlTests.c via the project’s top-level source directory, so the macro continues to work even when invoked from CMake files in subdirectories (not just the root CMakeLists.txt).
Changes:
- Update the
try_compile()source path incurl_internal_test()fromCMAKE_CURRENT_SOURCE_DIRtoPROJECT_SOURCE_DIRto make theCurlTests.creference stable across call sites.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vszakats
added a commit
that referenced
this pull request
Jun 26, 2026
Use `PROJECT_SOURCE_DIR` for these files, replacing `CMAKE_CURRENT_SOURCE_DIR`, to make it consistent with rest of CMake sources and to reflect that the locations of these files are fixed and do not depend on the CMake source location referencing them. Exception: keep as-is before calling `project()`, which is where `PROJECT_SOURCE_DIR` is initialized. Ref: https://cmake.org/cmake/help/v3.18/command/project.html Follow-up to #22187 Follow-up to 9126eb5 #15331 Closes #22188
vszakats
added a commit
that referenced
this pull request
Jun 26, 2026
- drop `generated` subdir, move these files to build root. To move them next to CPack and other config files, and to avoid a subdirectory for only 2 files. Follow-up to 6932849 #2849 - add 'Consumed variables' comment for `CMake/cmake_uninstall.in.cmake`. - move generated `cmake_uninstall.cmake` to the build root directory (from `CMake/`). To: - avoid creating a `CMake` subdirectory within the build directory with this single file in it. - move it next to its `cmake_install.cmake` counterpart. - move it next to `install_manifest.txt` which it relies on. Follow-up to 27e2a47 - Use `PROJECT_SOURCE_DIR` for these files, replacing `CMAKE_CURRENT_SOURCE_DIR`, to make it consistent with rest of CMake sources, and to reduce ambiguity in `CMake/cmake_uninstall.in.cmake` template. Follow-up to 8198e38 #22188 Follow-up to 4839029 #22187 Follow-up to 9126eb5 #15331 Closes #22192
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.
To make the macro find this file also when used elsewhere than the root
CMakeLists.txt. Current code only uses it from the root.Follow-up to 88c17d5