File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
i18n/en/docusaurus-plugin-content-docs/current/proj_man Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,11 @@ sources:
9595## CMake 集成
9696
9797自动同步的所有模块会被下载到 ` Modules/ ` 目录。
98- 只需在你的工程 ` CMakeLists.txt ` 中加入如下代码即可自动包含所有模块:
98+ 需通过设置 XROBOT_MODULES_DIR 变量,让 LibXR 自动发现并加载模块。
9999
100100``` cmake
101101# 添加 XRobot Modules
102- include(${CMAKE_CURRENT_LIST_DIR }/Modules/CMakeLists.txt )
102+ set(XROBOT_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR }/Modules" )
103103```
104104
105105别忘了把LibXR也包含进来!
@@ -109,8 +109,11 @@ include(${CMAKE_CURRENT_LIST_DIR}/Modules/CMakeLists.txt)
109109project(xrobot_mod_test CXX)
110110set(CMAKE_CXX_STANDARD 17)
111111add_executable(xr_test main.cpp)
112+
113+ # 在add_subdirectory之前
114+ set(XROBOT_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Modules/)
112115add_subdirectory(libxr)
116+
113117target_include_directories(xr_test PUBLIC $<TARGET_PROPERTY:xr,INTERFACE_INCLUDE_DIRECTORIES> ${CMAKE_SOURCE_DIR}/User)
114118target_link_libraries(xr_test PUBLIC xr)
115- include(Modules/CMakeLists.txt)
116119```
Original file line number Diff line number Diff line change @@ -95,11 +95,11 @@ sources:
9595## CMake Integration
9696
9797All fetched modules are stored under the ` Modules/ ` directory.
98- To include them in your CMake project, simply add:
98+ You need to set the XROBOT_MODULES_DIR variable so that LibXR can automatically discover and load the modules.
9999
100100``` cmake
101- # Include XRobot Modules
102- include(${CMAKE_CURRENT_LIST_DIR }/Modules/CMakeLists.txt )
101+ # Add XRobot Modules
102+ set(XROBOT_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR }/Modules" )
103103```
104104
105105Don't forget to include LibXR too!
@@ -109,8 +109,15 @@ Don't forget to include LibXR too!
109109project(xrobot_mod_test CXX)
110110set(CMAKE_CXX_STANDARD 17)
111111add_executable(xr_test main.cpp)
112+
113+ # Set before add_subdirectory
114+ set(XROBOT_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Modules/)
112115add_subdirectory(libxr)
113- target_include_directories(xr_test PUBLIC $<TARGET_PROPERTY:xr,INTERFACE_INCLUDE_DIRECTORIES> ${CMAKE_SOURCE_DIR}/User)
116+
117+ target_include_directories(xr_test PUBLIC
118+ $<TARGET_PROPERTY:xr,INTERFACE_INCLUDE_DIRECTORIES>
119+ ${CMAKE_SOURCE_DIR}/User
120+ )
121+
114122target_link_libraries(xr_test PUBLIC xr)
115- include(Modules/CMakeLists.txt)
116123```
You can’t perform that action at this time.
0 commit comments