-
Notifications
You must be signed in to change notification settings - Fork 5k
CMake Compatibility with FetchContent #13311
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
CMake Compatibility with FetchContent #13311
Conversation
… FetchContent() compatibility
|
Hi @mprat Question, just based on a really quick look:
So, for example, in a file like This evaluated to the |
Not quite - the If you want to get rid of this ambiguity, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates CMake configuration to improve compatibility with FetchContent by replacing CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR. This change ensures that when librealsense is used as a dependency via CMake's FetchContent framework, the build system correctly references the project's source directory rather than the parent project's directory.
- Replace
CMAKE_SOURCE_DIRwithPROJECT_SOURCE_DIRacross multiple CMakeLists.txt files - Update include directory paths for Python wrappers, PCL wrappers, C# bindings, and examples
- Modify CMake include statements for OpenGL configuration
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wrappers/python/CMakeLists.txt | Updates include directories for pybackend2 target to use PROJECT_SOURCE_DIR |
| wrappers/pcl/pcl/CMakeLists.txt | Updates GLFW include directory path for rs-pcl target |
| wrappers/pcl/pcl-color/CMakeLists.txt | Updates GLFW include directory path for rs-pcl-color target |
| wrappers/csharp/Intel.RealSense/CMakeLists.txt | Updates Unity bindings directory reference |
| tools/CMakeLists.txt | Updates OpenGL configuration include path |
| src/gl/CMakeLists.txt | Updates OpenGL configuration include path |
| examples/CMakeLists.txt | Updates OpenGL configuration include path |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
|
Can one of the admins verify this patch? |
|
I've fixed the conflicts with the latest base; I am starting a new project with |
|
@mprat I will try to help you with that. |
|
@mprat since we see no reggresion in our CI I will help and merge it. |

To allow for projects using CMake's
FetchContentframework, instances ofCMAKE_SOURCE_DIRshould be replaced withPROJECT_SOURCE_DIR.FetchContentusesadd_subdirectory()under the cmake hood, and usingCMAKE_SOURCE_DIRcannot be set manually; it is set as the parent project source directory. For correctadd_subdirectory()cmake builds usinglibrealsenseas a dependency, these should be changed toPROJECT_SOURCE_DIR.