IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.42k stars 4.8k forks source link

FetchContent compatibility? #13043

Closed panpawel88 closed 3 days ago

panpawel88 commented 1 week ago

Hello,

I wanted to add Realsense library as a dependency to my project. Realsense library is added by FetchContent cmake feature. However cmake generation fails on my side.

Here is my simple CMakeLists.txt file:

cmake_minimum_required(VERSION 3.28)
project(realsense_test)

include(FetchContent)

FetchContent_Declare(
        librealsense
        GIT_REPOSITORY "https://github.com/IntelRealSense/librealsense"
        GIT_TAG "8dab5816bef30d56bc185c21132892fe41fbc146"
)

FetchContent_MakeAvailable(librealsense)

set(CMAKE_CXX_STANDARD 17)

add_executable(realsense_test main.cpp)
target_link_libraries(realsense_test librealsense)

Error log:

// ...
CMake Error at cmake-build-debug/_deps/librealsense-src/tools/CMakeLists.txt:28 (include):
  include could not find requested file:

    /home/pawel/CLionProjects/realsense-test/CMake/opengl_config.cmake
// ...

Correct path for opengl_config.cmake is /home/pawel/CLionProjects/realsense-test/cmake-build-debug/_deps/librealsense-src/CMake/opengl_config.cmake.

Is Realsense library compatible with FetchContent? In https://github.com/IntelRealSense/librealsense/issues/12150 somebody wanted to clone with FetchContent, so I would expect that it should be working.

MartyG-RealSense commented 1 week ago

Hi @panpawel88 Installing RealSense with FetchContent is also discussed at the link below.

https://stackoverflow.com/questions/56593161/cmake-fetchcontent-does-not-copy-libraries

In their solution they fetch realsense2 instead of librealsense.

MartyG-RealSense commented 4 days ago

Hi @panpawel88 Do you require further assistance with this case, please? Thanks!

panpawel88 commented 3 days ago

Hello @MartyG-RealSense ,

I couldn't get it working by FetchContent, but I've added realsense dependency by using vcpkg. My issue is solved.

Thanks

MartyG-RealSense commented 3 days ago

You are very welcome. Thanks very much for the update. As you have achieved a solution, I will close this case. Thanks again!