fix: update CMakeLists to use existing source paths for backward version support

This commit is contained in:
insleker 2026-05-22 11:55:44 +08:00
parent ded13c428f
commit 81417b57d6
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})
list(APPEND WEBOTS_CONTROLLER_C_SOURCES ${WEBOTS_CONTROLLER_C_PLUGIN_SOURCES})
list(TRANSFORM WEBOTS_CONTROLLER_C_SOURCES PREPEND "${WEBOTS_CONTROLLER_C_SOURCE_DIR}/")
set(WEBOTS_CONTROLLER_C_SOURCE_PATHS)
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)
find_package(Git REQUIRED)
@ -88,11 +93,17 @@ if(MSVC)
message(FATAL_ERROR "Failed to apply MSVC controller C source patch")
endif()
list(TRANSFORM WEBOTS_CONTROLLER_C_SOURCES
REPLACE "^${WEBOTS_CONTROLLER_C_SOURCE_DIR}" "${WEBOTS_CONTROLLER_MSVC_SOURCE_DIR}")
set(_msvc_source_paths)
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()
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::Controller ALIAS webots_controller)

View File

@ -37,12 +37,18 @@ set(WEBOTS_CONTROLLER_CPP_SOURCES
TouchSensor.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
"${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
webots_cpp_controller)
add_library(webots-controller::CppController ALIAS webots_cpp_controller)
@ -77,4 +83,4 @@ install(
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
FILE_SET webots_cpp_headers
DESTINATION "include/controller/cpp")
DESTINATION "include/controller/cpp")