Merge pull request #3 from existedinnettw/fix/webots

fix: update CMakeLists to use existing source paths for backward version support
This commit is contained in:
existedinnettw 2026-05-22 11:58:37 +08:00 committed by GitHub
commit 82b5994be3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 8 deletions

View File

@ -65,8 +65,13 @@ set(WEBOTS_CONTROLLER_C_PLUGIN_SOURCES dynamic_library.c html_robot_window.c
set(WEBOTS_CONTROLLER_C_SOURCES ${WEBOTS_CONTROLLER_C_CORE_SOURCES}) set(WEBOTS_CONTROLLER_C_SOURCES ${WEBOTS_CONTROLLER_C_CORE_SOURCES})
list(APPEND WEBOTS_CONTROLLER_C_SOURCES ${WEBOTS_CONTROLLER_C_PLUGIN_SOURCES}) list(APPEND WEBOTS_CONTROLLER_C_SOURCES ${WEBOTS_CONTROLLER_C_PLUGIN_SOURCES})
set(WEBOTS_CONTROLLER_C_SOURCE_PATHS)
list(TRANSFORM WEBOTS_CONTROLLER_C_SOURCES PREPEND "${WEBOTS_CONTROLLER_C_SOURCE_DIR}/") foreach(_src IN LISTS WEBOTS_CONTROLLER_C_SOURCES)
set(_candidate "${WEBOTS_CONTROLLER_C_SOURCE_DIR}/${_src}")
if(EXISTS "${_candidate}")
list(APPEND WEBOTS_CONTROLLER_C_SOURCE_PATHS "${_candidate}")
endif()
endforeach()
if(MSVC) if(MSVC)
find_package(Git REQUIRED) find_package(Git REQUIRED)
@ -88,11 +93,17 @@ if(MSVC)
message(FATAL_ERROR "Failed to apply MSVC controller C source patch") message(FATAL_ERROR "Failed to apply MSVC controller C source patch")
endif() endif()
list(TRANSFORM WEBOTS_CONTROLLER_C_SOURCES set(_msvc_source_paths)
REPLACE "^${WEBOTS_CONTROLLER_C_SOURCE_DIR}" "${WEBOTS_CONTROLLER_MSVC_SOURCE_DIR}") foreach(_src IN LISTS WEBOTS_CONTROLLER_C_SOURCES)
set(_candidate "${WEBOTS_CONTROLLER_MSVC_SOURCE_DIR}/${_src}")
if(EXISTS "${_candidate}")
list(APPEND _msvc_source_paths "${_candidate}")
endif()
endforeach()
set(WEBOTS_CONTROLLER_C_SOURCE_PATHS ${_msvc_source_paths})
endif() endif()
add_library(webots_controller ${WEBOTS_CONTROLLER_C_SOURCES}) add_library(webots_controller ${WEBOTS_CONTROLLER_C_SOURCE_PATHS})
add_library(webots-controller::webots_controller ALIAS webots_controller) add_library(webots-controller::webots_controller ALIAS webots_controller)
add_library(webots-controller::Controller ALIAS webots_controller) add_library(webots-controller::Controller ALIAS webots_controller)

View File

@ -37,12 +37,18 @@ set(WEBOTS_CONTROLLER_CPP_SOURCES
TouchSensor.cpp TouchSensor.cpp
VacuumGripper.cpp) VacuumGripper.cpp)
list(TRANSFORM WEBOTS_CONTROLLER_CPP_SOURCES PREPEND "${WEBOTS_CONTROLLER_CPP_SOURCE_DIR}/") set(WEBOTS_CONTROLLER_CPP_SOURCE_PATHS)
foreach(_src IN LISTS WEBOTS_CONTROLLER_CPP_SOURCES)
set(_candidate "${WEBOTS_CONTROLLER_CPP_SOURCE_DIR}/${_src}")
if(EXISTS "${_candidate}")
list(APPEND WEBOTS_CONTROLLER_CPP_SOURCE_PATHS "${_candidate}")
endif()
endforeach()
file(GLOB_RECURSE WEBOTS_CONTROLLER_CPP_PUBLIC_HEADERS CONFIGURE_DEPENDS file(GLOB_RECURSE WEBOTS_CONTROLLER_CPP_PUBLIC_HEADERS CONFIGURE_DEPENDS
"${WEBOTS_REPO_SOURCE_DIR}/include/controller/cpp/webots/*.hpp") "${WEBOTS_REPO_SOURCE_DIR}/include/controller/cpp/webots/*.hpp")
add_library(webots_cpp_controller ${WEBOTS_CONTROLLER_CPP_SOURCES}) add_library(webots_cpp_controller ${WEBOTS_CONTROLLER_CPP_SOURCE_PATHS})
add_library(webots-controller::webots_cpp_controller ALIAS add_library(webots-controller::webots_cpp_controller ALIAS
webots_cpp_controller) webots_cpp_controller)
add_library(webots-controller::CppController ALIAS webots_cpp_controller) add_library(webots-controller::CppController ALIAS webots_cpp_controller)