feat: update test_package cmake install process
This commit is contained in:
parent
c25f13adb4
commit
eb5c8024d5
|
|
@ -69,5 +69,5 @@ Testing/
|
||||||
.cache/
|
.cache/
|
||||||
|
|
||||||
# user
|
# user
|
||||||
/CMakeUserPresets.json
|
**/CMakeUserPresets.json
|
||||||
|
/test_package/bin
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(webots_controller VERSION 0.1.0 LANGUAGES C CXX)
|
project(webots_controller LANGUAGES C CXX)
|
||||||
|
|
||||||
option(WEBOTS_CONTROLLER_NO_PLUGINS "Disable runtime plugin loading (dlopen/LoadLibrary paths)." ON)
|
option(WEBOTS_CONTROLLER_NO_PLUGINS "Disable runtime plugin loading (dlopen/LoadLibrary paths)." ON)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from conan.tools.files import copy
|
||||||
|
|
||||||
class WebotsControllerConan(ConanFile):
|
class WebotsControllerConan(ConanFile):
|
||||||
name = "webots-controller"
|
name = "webots-controller"
|
||||||
version = "0.1.0"
|
version = "r2025a"
|
||||||
package_type = "library"
|
package_type = "library"
|
||||||
|
|
||||||
settings = "os", "arch", "compiler", "build_type"
|
settings = "os", "arch", "compiler", "build_type"
|
||||||
|
|
@ -20,7 +20,7 @@ class WebotsControllerConan(ConanFile):
|
||||||
"no_plugins": True,
|
"no_plugins": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
exports_sources = "CMakeLists.txt", "src/*", "LICENSE", "README.md"
|
exports_sources = "CMakeLists.txt", "src/*", "include/*", "LICENSE", "README.md"
|
||||||
|
|
||||||
def config_options(self):
|
def config_options(self):
|
||||||
if self.settings.os == "Windows":
|
if self.settings.os == "Windows":
|
||||||
|
|
@ -50,3 +50,4 @@ class WebotsControllerConan(ConanFile):
|
||||||
|
|
||||||
def package_info(self):
|
def package_info(self):
|
||||||
self.cpp_info.libs = ["webots_cpp_controller", "webots_controller"]
|
self.cpp_info.libs = ["webots_cpp_controller", "webots_controller"]
|
||||||
|
self.cpp_info.includedirs = ["include/controller/cpp", "include/controller/c"]
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,15 @@ if(WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(webots_controller
|
target_include_directories(webots_controller
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${WEBOTS_HEADERS_ROOT}>
|
||||||
|
$<INSTALL_INTERFACE:include/controller/c>
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${WEBOTS_HEADERS_ROOT}
|
|
||||||
${WEBOTS_INCLUDE_ROOT}
|
|
||||||
${WEBOTS_STB_DIR}
|
${WEBOTS_STB_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(webots_controller PRIVATE LIBCONTROLLER_VERSION="custom")
|
target_compile_definitions(webots_controller PRIVATE LIBCONTROLLER_VERSION="R2025a")
|
||||||
if(WEBOTS_CONTROLLER_NO_PLUGINS)
|
if(WEBOTS_CONTROLLER_NO_PLUGINS)
|
||||||
target_compile_definitions(webots_controller PUBLIC WEBOTS_CONTROLLER_NO_PLUGINS=1)
|
target_compile_definitions(webots_controller PUBLIC WEBOTS_CONTROLLER_NO_PLUGINS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -114,3 +115,4 @@ if(UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS webots_controller)
|
install(TARGETS webots_controller)
|
||||||
|
install(DIRECTORY "${WEBOTS_HEADERS_ROOT}/webots" DESTINATION "include/controller/c")
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ if(WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(webots_cpp_controller
|
target_include_directories(webots_cpp_controller
|
||||||
PRIVATE
|
PUBLIC
|
||||||
${CMAKE_SOURCE_DIR}/include/controller/c
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/controller/cpp>
|
||||||
${CMAKE_SOURCE_DIR}/include/controller/cpp
|
$<INSTALL_INTERFACE:include/controller/cpp>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(webots_cpp_controller
|
target_link_libraries(webots_cpp_controller
|
||||||
|
|
@ -55,3 +55,4 @@ target_link_libraries(webots_cpp_controller
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS webots_cpp_controller)
|
install(TARGETS webots_cpp_controller)
|
||||||
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/controller/cpp/webots" DESTINATION "include/controller/cpp")
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,25 @@
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(test_package CXX)
|
project(test_package CXX)
|
||||||
|
|
||||||
find_package(webots-controller REQUIRED CONFIG)
|
find_package(webots-controller REQUIRED CONFIG)
|
||||||
|
|
||||||
add_executable(test_package test_package.cpp)
|
add_executable(test_package test_package.cpp)
|
||||||
target_link_libraries(test_package PRIVATE Webots::CppController Webots::Controller)
|
target_link_libraries(test_package PRIVATE webots-controller::webots-controller)
|
||||||
|
|
||||||
if(POLICY CMP0207)
|
if(POLICY CMP0207)
|
||||||
cmake_policy(SET CMP0207 NEW)
|
cmake_policy(SET CMP0207 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(_extra_runtime_dirs)
|
||||||
|
if(CMAKE_PREFIX_PATH)
|
||||||
|
foreach(prefix IN LISTS CMAKE_PREFIX_PATH)
|
||||||
|
list(APPEND _extra_runtime_dirs "${prefix}/lib")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if(WIN32 AND DEFINED ENV{MINGW_HOME})
|
||||||
|
list(APPEND _extra_runtime_dirs "$ENV{MINGW_HOME}/bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Webots controllers rely on seeing shared deps in the same directory as the executable.
|
# Webots controllers rely on seeing shared deps in the same directory as the executable.
|
||||||
install(TARGETS test_package
|
install(TARGETS test_package
|
||||||
RUNTIME_DEPENDENCY_SET test_package_runtime_deps
|
RUNTIME_DEPENDENCY_SET test_package_runtime_deps
|
||||||
|
|
@ -18,29 +28,30 @@ install(TARGETS test_package
|
||||||
ARCHIVE DESTINATION lib)
|
ARCHIVE DESTINATION lib)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# for single-config generators.
|
set(_runtime_dep_pre_excludes
|
||||||
set(_runtime_dependency_directories)
|
"^api-ms-win-.*"
|
||||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _conan_build_type)
|
"^ext-ms-.*")
|
||||||
set(_webots_bin_dirs_var "webots-controller_BIN_DIRS_${_conan_build_type}")
|
set(_runtime_dep_post_excludes
|
||||||
if(DEFINED ${_webots_bin_dirs_var})
|
".*/system32/.*"
|
||||||
list(APPEND _runtime_dependency_directories ${${_webots_bin_dirs_var}})
|
".*/Windows/.*"
|
||||||
endif()
|
".*/SysWOW64/.*")
|
||||||
if(DEFINED ENV{MINGW_HOME})
|
|
||||||
list(APPEND _runtime_dependency_directories "$ENV{MINGW_HOME}/bin")
|
|
||||||
endif()
|
|
||||||
install(
|
|
||||||
RUNTIME_DEPENDENCY_SET test_package_runtime_deps
|
|
||||||
DIRECTORIES ${_runtime_dependency_directories}
|
|
||||||
PRE_EXCLUDE_REGEXES
|
|
||||||
"^api-ms-win-.*"
|
|
||||||
"^ext-ms-.*"
|
|
||||||
POST_EXCLUDE_REGEXES
|
|
||||||
".*/system32/.*"
|
|
||||||
".*/Windows/.*"
|
|
||||||
".*/SysWOW64/.*"
|
|
||||||
DESTINATION bin)
|
|
||||||
else()
|
else()
|
||||||
install(
|
set(_runtime_dep_pre_excludes
|
||||||
RUNTIME_DEPENDENCY_SET test_package_runtime_deps
|
[[libc\.so\..*]]
|
||||||
DESTINATION bin)
|
[[libgcc_s\.so\..*]]
|
||||||
endif()
|
[[libm\.so\..*]]
|
||||||
|
[[libstdc\+\+\.so\..*]]
|
||||||
|
[[ld-linux-x86-64\.so\..*]])
|
||||||
|
set(_runtime_dep_post_excludes
|
||||||
|
[[^/lib.*]]
|
||||||
|
[[^/usr/lib.*]])
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(
|
||||||
|
RUNTIME_DEPENDENCY_SET test_package_runtime_deps
|
||||||
|
PRE_EXCLUDE_REGEXES ${_runtime_dep_pre_excludes}
|
||||||
|
POST_EXCLUDE_REGEXES ${_runtime_dep_post_excludes}
|
||||||
|
DIRECTORIES
|
||||||
|
${CONAN_RUNTIME_LIB_DIRS}
|
||||||
|
${CMAKE_SYSROOT}/lib
|
||||||
|
${_extra_runtime_dirs})
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ class TestPackageConan(ConanFile):
|
||||||
cmake.build()
|
cmake.build()
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
|
# check if RUNTIME_DEPENDENCY_SET work
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
cmake.install()
|
cmake.install()
|
||||||
if can_run(self):
|
if can_run(self):
|
||||||
exe = os.path.join(self.source_folder, "bin", "test_package")
|
exe = os.path.join(self.source_folder, "bin", "test_package")
|
||||||
self.run(exe, env="conanrun")
|
self.run(exe, env="conanrun")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue