diff --git a/.gitignore b/.gitignore index b5a7db5..24a1178 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,5 @@ Testing/ .cache/ # user -/CMakeUserPresets.json - +**/CMakeUserPresets.json +/test_package/bin diff --git a/CMakeLists.txt b/CMakeLists.txt index cbcba07..f34378e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ 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) diff --git a/conanfile.py b/conanfile.py index 24720d4..9737fac 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.files import copy class WebotsControllerConan(ConanFile): name = "webots-controller" - version = "0.1.0" + version = "r2025a" package_type = "library" settings = "os", "arch", "compiler", "build_type" @@ -20,7 +20,7 @@ class WebotsControllerConan(ConanFile): "no_plugins": True, } - exports_sources = "CMakeLists.txt", "src/*", "LICENSE", "README.md" + exports_sources = "CMakeLists.txt", "src/*", "include/*", "LICENSE", "README.md" def config_options(self): if self.settings.os == "Windows": @@ -50,3 +50,4 @@ class WebotsControllerConan(ConanFile): def package_info(self): self.cpp_info.libs = ["webots_cpp_controller", "webots_controller"] + self.cpp_info.includedirs = ["include/controller/cpp", "include/controller/c"] diff --git a/src/controller/c/CMakeLists.txt b/src/controller/c/CMakeLists.txt index 6a24c56..c3ae48b 100644 --- a/src/controller/c/CMakeLists.txt +++ b/src/controller/c/CMakeLists.txt @@ -91,14 +91,15 @@ if(WIN32) endif() target_include_directories(webots_controller + PUBLIC + $ + $ PRIVATE - ${WEBOTS_HEADERS_ROOT} - ${WEBOTS_INCLUDE_ROOT} ${WEBOTS_STB_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) target_compile_definitions(webots_controller PUBLIC WEBOTS_CONTROLLER_NO_PLUGINS=1) endif() @@ -114,3 +115,4 @@ if(UNIX) endif() install(TARGETS webots_controller) +install(DIRECTORY "${WEBOTS_HEADERS_ROOT}/webots" DESTINATION "include/controller/c") diff --git a/src/controller/cpp/CMakeLists.txt b/src/controller/cpp/CMakeLists.txt index 041bdf4..43e5ac6 100644 --- a/src/controller/cpp/CMakeLists.txt +++ b/src/controller/cpp/CMakeLists.txt @@ -44,9 +44,9 @@ if(WIN32) endif() target_include_directories(webots_cpp_controller - PRIVATE - ${CMAKE_SOURCE_DIR}/include/controller/c - ${CMAKE_SOURCE_DIR}/include/controller/cpp + PUBLIC + $ + $ ) target_link_libraries(webots_cpp_controller @@ -55,3 +55,4 @@ target_link_libraries(webots_cpp_controller ) install(TARGETS webots_cpp_controller) +install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/controller/cpp/webots" DESTINATION "include/controller/cpp") diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 3da4349..2a25d1a 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -1,15 +1,25 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.21) project(test_package CXX) find_package(webots-controller REQUIRED CONFIG) 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) cmake_policy(SET CMP0207 NEW) 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. install(TARGETS test_package RUNTIME_DEPENDENCY_SET test_package_runtime_deps @@ -18,29 +28,30 @@ install(TARGETS test_package ARCHIVE DESTINATION lib) if(WIN32) - # for single-config generators. - set(_runtime_dependency_directories) - string(TOUPPER "${CMAKE_BUILD_TYPE}" _conan_build_type) - set(_webots_bin_dirs_var "webots-controller_BIN_DIRS_${_conan_build_type}") - if(DEFINED ${_webots_bin_dirs_var}) - list(APPEND _runtime_dependency_directories ${${_webots_bin_dirs_var}}) - endif() - 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) + set(_runtime_dep_pre_excludes + "^api-ms-win-.*" + "^ext-ms-.*") + set(_runtime_dep_post_excludes + ".*/system32/.*" + ".*/Windows/.*" + ".*/SysWOW64/.*") else() - install( - RUNTIME_DEPENDENCY_SET test_package_runtime_deps - DESTINATION bin) -endif() \ No newline at end of file + set(_runtime_dep_pre_excludes + [[libc\.so\..*]] + [[libgcc_s\.so\..*]] + [[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}) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 16aa76e..37448dc 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -21,8 +21,10 @@ class TestPackageConan(ConanFile): cmake.build() def test(self): + # check if RUNTIME_DEPENDENCY_SET work cmake = CMake(self) cmake.install() if can_run(self): exe = os.path.join(self.source_folder, "bin", "test_package") - self.run(exe, env="conanrun") \ No newline at end of file + self.run(exe, env="conanrun") +