librealsense2 cmakelist
时间: 2023-10-01 12:02:21 浏览: 36
在使用librealsense2库时,你可以创建一个CMakeLists.txt文件来配置和构建你的项目。下面是一个示例的CMakeLists.txt文件来使用librealsense2库:
```
cmake_minimum_required(VERSION 3.5)
project(YourProjectName)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Find librealsense2 installed package
find_package(realsense2 REQUIRED)
# Add your source files
add_executable(YourExecutableName your_source_files.cpp)
# Link against librealsense2 library
target_link_libraries(YourExecutableName ${realsense2_LIBRARY})
```
你需要将上述示例中的"YourProjectName"替换为你项目的名称,"YourExecutableName"替换为你要生成的可执行文件的名称,并将"your_source_files.cpp"替换为你的源代码文件。
确保已经安装了librealsense2库,并在CMake配置文件中使用`find_package(realsense2 REQUIRED)`来找到安装的库。
然后,使用`target_link_libraries(YourExecutableName ${realsense2_LIBRARY})`来将librealsense2库链接到你的可执行文件。
这只是一个简单的示例,你可能需要根据你的具体项目需求进行调整。