From a1fda52c3709efe1d71f24bbd4d45688b52086a6 Mon Sep 17 00:00:00 2001 From: wtudio <95963900+wtudio@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:57:47 +0800 Subject: [PATCH] fix: misc adjustments (#66) * fix: misc * doc: update misc --- CMakeLists.txt | 50 ++++++++--------- cmake/GetAsio.cmake | 14 ++++- cmake/GetTBB.cmake | 2 +- cmake/GetYamlCpp.cmake | 2 +- document/doxygen/build.bat | 15 ----- document/sphinx-cn/release_notes/v0_9_0.md | 7 ++- .../tutorials/interface_cpp/channel.md | 2 +- .../sphinx-cn/tutorials/interface_cpp/rpc.md | 8 +++ .../tutorials/quick_start/installation_cpp.md | 6 +- src/common/net/CMakeLists.txt | 3 +- .../aimrt_module_cpp_interface/CMakeLists.txt | 6 -- src/plugins/grpc_plugin/CMakeLists.txt | 6 +- src/protocols/CMakeLists.txt | 55 ++++++++++--------- src/protocols/geometry/CMakeLists.txt | 2 - src/protocols/sensor/joint.proto | 34 ------------ src/protocols/visualization/CMakeLists.txt | 2 - src/runtime/core/CMakeLists.txt | 15 +++++ src/runtime/core/module/module_manager.cc | 28 +++++++++- src/tools/CMakeLists.txt | 8 +-- .../workspace/ws_CMakeLists.txt.jinja2 | 25 ++++----- src/tools/package_aimrt_py/CMakeLists.txt | 2 +- 21 files changed, 143 insertions(+), 149 deletions(-) delete mode 100644 document/doxygen/build.bat delete mode 100644 src/protocols/geometry/CMakeLists.txt delete mode 100644 src/protocols/sensor/joint.proto delete mode 100644 src/protocols/visualization/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2102f53a4..412774475 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ if(AIMRT_MASTER_PROJECT) set(CMAKE_CXX_VISIBLITY_INLINES_HIDDEN ON) set(BUILD_SHARED_LIBS OFF) - if(UNIX) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") if(AIMRT_BUILD_TESTS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") @@ -91,7 +91,7 @@ endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) -if(MSVC) +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_options(/utf-8 /wd4819) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") endif() @@ -101,15 +101,11 @@ if(WIN32) endif() # Build document -if(AIMRT_BUILD_DOCUMENT) +if(AIMRT_BUILD_DOCUMENT AND UNIX) message(STATUS "gen document ...") set(AIMRT_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/document) - if(WIN32) - execute_process(COMMAND ${AIMRT_DOC_DIR}/doxygen/build.bat ${AIMRT_DOC_DIR}/doxygen WORKING_DIRECTORY ${AIMRT_DOC_DIR}/doxygen) - elseif(UNIX) - execute_process(COMMAND ${AIMRT_DOC_DIR}/doxygen/build.sh ${AIMRT_DOC_DIR}/doxygen WORKING_DIRECTORY ${AIMRT_DOC_DIR}/doxygen) - execute_process(COMMAND ${AIMRT_DOC_DIR}/sphinx-cn/build.sh ${AIMRT_DOC_DIR}/sphinx-cn WORKING_DIRECTORY ${AIMRT_DOC_DIR}/sphinx-cn) - endif() + execute_process(COMMAND ${AIMRT_DOC_DIR}/doxygen/build.sh ${AIMRT_DOC_DIR}/doxygen WORKING_DIRECTORY ${AIMRT_DOC_DIR}/doxygen) + execute_process(COMMAND ${AIMRT_DOC_DIR}/sphinx-cn/build.sh ${AIMRT_DOC_DIR}/sphinx-cn WORKING_DIRECTORY ${AIMRT_DOC_DIR}/sphinx-cn) endif() # Include cmake module @@ -143,7 +139,22 @@ if(AIMRT_BUILD_CLI_TOOLS) OR NOT PYYAML_FOUND) set(AIMRT_BUILD_CLI_TOOLS OFF) message(WARNING "Can not find pyinstaller, jinja2 or pyyaml in your python environment, will not compile aimrt_cli!") - message(WARNING "try to install pyinstaller, jinja2 and pyyaml by `pip3 install pyinstaller jinja2 pyyaml --upgrade`") + message(WARNING "Try to install pyinstaller, jinja2 and pyyaml by `pip3 install pyinstaller jinja2 pyyaml --upgrade`") + endif() +endif() + +if(AIMRT_BUILD_BAGTRANS) + include(CheckPythonPackage) + check_python_package(build BUILD_FOUND) + check_python_package(wheel WHEEL_FOUND) + check_python_package(setuptools SETUPTOOLS_FOUND) + + if(NOT BUILD_FOUND + OR NOT WHEEL_FOUND + OR NOT SETUPTOOLS_FOUND) + set(AIMRT_BUILD_BAGTRANS OFF) + message(WARNING "Can not find build, wheel or setuptools in your python environment, will not compile bagtrans tool!") + message(WARNING "Try to install build, wheel and setuptools by `pip3 install build wheel setuptools --upgrade`") endif() endif() @@ -202,26 +213,11 @@ if(AIMRT_BUILD_RUNTIME) OR NOT WHEEL_FOUND) set(AIMRT_BUILD_PYTHON_PACKAGE OFF) message(WARNING "Can not find build, setuptools or wheel in your python environment, will not generate aimrt_py package! ") - message(WARNING "try to install build, setuptools and wheel by `pip3 install build setuptools wheel --upgrade`") + message(WARNING "Try to install build, setuptools and wheel by `pip3 install build setuptools wheel --upgrade`") endif() endif() endif() - if(AIMRT_BUILD_BAGTRANS) - include(CheckPythonPackage) - check_python_package(build BUILD_FOUND) - check_python_package(wheel WHEEL_FOUND) - check_python_package(setuptools SETUPTOOLS_FOUND) - - if(NOT BUILD_FOUND - OR NOT WHEEL_FOUND - OR NOT SETUPTOOLS_FOUND) - set(AIMRT_BUILD_BAGTRANS OFF) - message(WARNING "Can not find build, wheel or setuptools in your python environment, will not compile bagtrans tool!") - message(WARNING "try to install build, wheel and setuptools by `pip3 install build wheel setuptools --upgrade`") - endif() - endif() - if(AIMRT_BUILD_NET_PLUGIN) include(GetBoost) endif() @@ -305,8 +301,6 @@ endif() if(AIMRT_INSTALL AND AIMRT_BUILD_WITH_ROS2 - AND AIMRT_BUILD_ROS2_PLUGIN - AND AIMRT_BUILD_RECORD_PLAYBACK_PLUGIN AND AIMRT_BUILD_BAGTRANS) install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --config ${CMAKE_BUILD_TYPE} --target bagtrans)") endif() diff --git a/cmake/GetAsio.cmake b/cmake/GetAsio.cmake index 317eb42b3..001ac0ddb 100644 --- a/cmake/GetAsio.cmake +++ b/cmake/GetAsio.cmake @@ -29,9 +29,12 @@ if(NOT asio_POPULATED) add_library(asio INTERFACE) add_library(asio::asio ALIAS asio) - target_include_directories(asio INTERFACE ${asio_SOURCE_DIR}/asio/include) + target_include_directories(asio INTERFACE $ $) target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED) + file(GLOB_RECURSE head_files ${asio_SOURCE_DIR}/asio/include/*.hpp ${asio_SOURCE_DIR}/asio/include/*.ipp) + target_sources(asio INTERFACE FILE_SET HEADERS BASE_DIRS ${asio_SOURCE_DIR}/asio/include FILES ${head_files}) + find_package(Threads REQUIRED) target_link_libraries(asio INTERFACE Threads::Threads) @@ -64,6 +67,15 @@ if(NOT asio_POPULATED) target_compile_definitions(asio INTERFACE _WIN32_WINNT=${_WIN32_WINNT} WIN32_LEAN_AND_MEAN) endif() + + set_property(TARGET asio PROPERTY EXPORT_NAME asio::asio) + install( + TARGETS asio + EXPORT asio-config + FILE_SET HEADERS + DESTINATION include/asio) + + install(EXPORT asio-config DESTINATION lib/cmake/asio) endif() # import targets: diff --git a/cmake/GetTBB.cmake b/cmake/GetTBB.cmake index a7b19d557..7c440e185 100644 --- a/cmake/GetTBB.cmake +++ b/cmake/GetTBB.cmake @@ -33,7 +33,7 @@ if(NOT tbb_POPULATED) CACHE STRING "" FORCE) set(TBB_INSTALL - OFF + ON CACHE BOOL "") set(TBB_STRICT diff --git a/cmake/GetYamlCpp.cmake b/cmake/GetYamlCpp.cmake index 2b210f247..a6adbd3b4 100644 --- a/cmake/GetYamlCpp.cmake +++ b/cmake/GetYamlCpp.cmake @@ -34,7 +34,7 @@ if(NOT yaml-cpp_POPULATED) OFF CACHE BOOL "") set(YAML_CPP_INSTALL - OFF + ON CACHE BOOL "") set(YAML_CPP_FORMAT_SOURCE OFF diff --git a/document/doxygen/build.bat b/document/doxygen/build.bat deleted file mode 100644 index ce664c81a..000000000 --- a/document/doxygen/build.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -setlocal - -set "DIR=%~1" -if "%DIR%"=="" set "DIR=." - -where doxygen >nul 2>&1 -if %ERRORLEVEL% == 0 ( - if exist "%DIR%\html" ( - rmdir /s /q "%DIR%\html" - ) - doxygen "%DIR%\Doxyfile" > "%DIR%\doxygen.log" 2>&1 -) - -endlocal diff --git a/document/sphinx-cn/release_notes/v0_9_0.md b/document/sphinx-cn/release_notes/v0_9_0.md index edbc4ac7c..7327ed7da 100644 --- a/document/sphinx-cn/release_notes/v0_9_0.md +++ b/document/sphinx-cn/release_notes/v0_9_0.md @@ -8,13 +8,10 @@ - 现在可以传入 zenoh 原生配置; - mqtt 新增配置项以支持加密传输; - 新增了第三方库 asio,runtime::core 不再引用 boost,改为引用独立的 asio 库,以减轻依赖; -- 修复 aimrt_py 多线程 rpc 调用 server 端概率性崩溃的问题; -- 为 aimrt_py 的 channel 功能提供了 Context 支持; - 新增 bagtrans 命令行工具,用于将 使用 aimrt record_playback 插件录制的 bag 文件转换为 ros2 的 bag 文件; **次要修改**: - 缩短了一些 examples 的文件路径长度; -- 修复了一些轻微问题; - 优化代码结构,移动代码 src/runtime/common/net 至新位置 src/common/net; - 升级 jsoncpp 至 1.9.6 版本以优化一些 cmake 问题; - 新增了 aimrt_py channel benchmark 示例; @@ -22,3 +19,7 @@ - iceoryx 插件在编译前先检查是否存在libacl,不存在则不进行编译; - 提供 RPC 服务的插件现在支持指定 service name; - 提供一键运行example的脚本,并生成测试报告; +- 修复 aimrt_py 多线程 rpc 调用 server 端概率性崩溃的问题; +- 为 aimrt_py 的 channel 功能提供了 Context 支持; +- 现在支持 install aimrt::runtime::core; +- 删除一些未使用的协议; diff --git a/document/sphinx-cn/tutorials/interface_cpp/channel.md b/document/sphinx-cn/tutorials/interface_cpp/channel.md index cb03072c9..a5ddc09ce 100644 --- a/document/sphinx-cn/tutorials/interface_cpp/channel.md +++ b/document/sphinx-cn/tutorials/interface_cpp/channel.md @@ -257,7 +257,7 @@ Proxy 类型接口可以绑定类型信息,功能更齐全一些。但两种 - 对于协程形式的回调,Context 和 Msg 的生命周期将持续到协程退出为止; -此外还需要注意的是,由哪个执行器来执行订阅的回调,这和具体的 Channel 后端实现有关,在运行阶段通过配置才能确定,使用者在编写逻辑代码时不应有任何假设。详细信息请参考对应后端的文档。 +此外还需要注意的是,由哪个执行器来执行订阅的回调,这和具体的 Channel 后端实现有关,在运行阶段通过配置才能确定,使用者在编写逻辑代码时不应有任何假设,详细信息请参考对应后端的文档。 最佳实践是:如果回调中的任务非常轻量,比如只是设置一个变量,那就可以直接在回调里处理;但如果回调中的任务比较重,那最好调度到其他专门执行任务的执行器里进行处理。 diff --git a/document/sphinx-cn/tutorials/interface_cpp/rpc.md b/document/sphinx-cn/tutorials/interface_cpp/rpc.md index 9dbb32ca3..86881d5da 100644 --- a/document/sphinx-cn/tutorials/interface_cpp/rpc.md +++ b/document/sphinx-cn/tutorials/interface_cpp/rpc.md @@ -270,11 +270,14 @@ class XXXProxy : public aimrt::rpc::CoProxyBase { - 该方法实际调用的是一个为当前 RPC 生成的`RegisterXXXClientFunc`全局方法; - 该方法需要传入`aimrt::rpc::RpcHandleRef`句柄作为参数; - 该方法可以选择传入一个 RPC ServiceName 字段,作为注册时的 RPC 服务名称; +- 如果有多个同类型的 Proxy,则通过 `ServiceName` 作为区分。开发者需要保证注册时和使用时的 `ServiceName` 一致; - 可以为 Proxy 设置一个默认 Context: - 如果在调用 RPC 时未传入 Context 或者传入了空的 Context,则会使用该 Proxy 默认的 Context; - 使用者可以通过`SetDefaultContextSharedPtr`和`GetDefaultContextSharedPtr`方法来设置、获取默认 Context; - 使用者可以通过`NewContextSharedPtr`方法从默认 Context 复制得到一份新的 Context; +注意:开发者发起一个 RPC 调用后,特定的 RPC 后端将处理具体的请求,实际的耗时、性能等表现以及 timeout 功能等和运行时配置的后端有关,在开发阶段无法确定,详细信息请参考对应后端的文档。 + ### 同步型接口 @@ -564,6 +567,11 @@ class XXXService : public aimrt::rpc::ServiceBase { - RPC Type 为固有属性,表示该 RPC Service 名称所属的体系,例如`pb`、`ros2`等。可以通过`RpcType`方法获取; - RPC ServiceName 表示该 RPC 服务的名称,如果不做特殊配置,则会使用一个跟**协议名称**绑定的默认值。如果需要使用同一套协议来提供不同的服务,也可以通过`SetServiceName`方法进行设置; +注意:由哪个执行器来执行 Service 回调,这和具体的 RPC 后端实现有关,在运行阶段通过配置才能确定,使用者在编写逻辑代码时不应有任何假设,详细信息请参考对应后端的文档。 + + +最佳实践是:如果回调中的任务非常轻量,比如只是设置一个变量,那就可以直接在回调里处理;但如果回调中的任务比较重,那最好调度到其他专门执行任务的执行器里进行处理。 + ### 同步型接口 diff --git a/document/sphinx-cn/tutorials/quick_start/installation_cpp.md b/document/sphinx-cn/tutorials/quick_start/installation_cpp.md index c648beb44..32322f8dc 100644 --- a/document/sphinx-cn/tutorials/quick_start/installation_cpp.md +++ b/document/sphinx-cn/tutorials/quick_start/installation_cpp.md @@ -69,8 +69,6 @@ target_link_libraries( ### 安装后find_package引用 -请注意:使用 **install 后 find_package 引用**这种方式,只能引用部分功能,只能基于 pkg 模式开发,无法使用 app 模式开发、或开发 aimrt 插件。 - 参考 [源码构建](build_from_source_ubuntu.md) 运行 build.sh 脚本进行构建,在构建时可以修改 `CMAKE_INSTALL_PREFIX` 指定安装目录,完成安装后,参考以下步骤完成引用: - 如果没有安装在系统路径,则需要在自己项目的 CMake 中设置 CMAKE_PREFIX_PATH 到 AimRT 的安装目录,例如: ```cmake @@ -84,6 +82,8 @@ target_link_libraries( include(GetProtobuf) include(GetYamlCpp) include(GetJsonCpp) + include(GetTBB) + include(GetAsio) ``` - 如果编译 AimRT 时带上了 ROS 相关功能,还需要引用 AimRT 安装时引入的一些 ROS 包,例如: ```cmake @@ -105,6 +105,8 @@ include(GetLibUnifex) include(GetProtobuf) include(GetYamlCpp) include(GetJsonCpp) +include(GetTBB) +include(GetAsio) find_package(ros2_plugin_proto REQUIRED) find_package(aimrt REQUIRED) diff --git a/src/common/net/CMakeLists.txt b/src/common/net/CMakeLists.txt index 793055127..9ca8ec829 100644 --- a/src/common/net/CMakeLists.txt +++ b/src/common/net/CMakeLists.txt @@ -23,8 +23,7 @@ add_library(${CUR_TARGET_ALIAS_NAME} ALIAS ${CUR_TARGET_NAME}) # Set include path of target target_include_directories( ${CUR_TARGET_NAME} - INTERFACE $ - $) + INTERFACE $) # Set link libraries of target target_link_libraries( diff --git a/src/interface/aimrt_module_cpp_interface/CMakeLists.txt b/src/interface/aimrt_module_cpp_interface/CMakeLists.txt index bc49025a7..c5296af16 100644 --- a/src/interface/aimrt_module_cpp_interface/CMakeLists.txt +++ b/src/interface/aimrt_module_cpp_interface/CMakeLists.txt @@ -43,12 +43,6 @@ else() target_link_libraries(${CUR_TARGET_NAME} INTERFACE unifex::unifex) endif() -# Fmt lib -if(AIMRT_USE_FMT_LIB) - target_link_libraries(${CUR_TARGET_NAME} INTERFACE fmt::fmt) - target_compile_definitions(${CUR_TARGET_NAME} INTERFACE AIMRT_USE_FMT_LIB) -endif() - # Set installation of target if(AIMRT_INSTALL) set_property(TARGET ${CUR_TARGET_NAME} PROPERTY EXPORT_NAME ${CUR_TARGET_ALIAS_NAME}) diff --git a/src/plugins/grpc_plugin/CMakeLists.txt b/src/plugins/grpc_plugin/CMakeLists.txt index cb27c2c2f..421579589 100644 --- a/src/plugins/grpc_plugin/CMakeLists.txt +++ b/src/plugins/grpc_plugin/CMakeLists.txt @@ -48,11 +48,7 @@ add_werror(${CUR_TARGET_NAME}) # Set installation of target if(AIMRT_INSTALL) - set_property(TARGET ${CUR_TARGET_NAME} PROPERTY EXPORT_NAME ${CUR_TARGET_ALIAS_NAME}) - install( - TARGETS ${CUR_TARGET_NAME} - EXPORT ${INSTALL_CONFIG_NAME} - LIBRARY DESTINATION bin) + install(TARGETS ${CUR_TARGET_NAME} LIBRARY DESTINATION bin) endif() # Set test of target diff --git a/src/protocols/CMakeLists.txt b/src/protocols/CMakeLists.txt index 4a9adb689..54087292d 100644 --- a/src/protocols/CMakeLists.txt +++ b/src/protocols/CMakeLists.txt @@ -3,37 +3,38 @@ set_namespace() -if(AIMRT_BUILD_EXAMPLES AND AIMRT_BUILD_WITH_PROTOBUF) - add_subdirectory(example) -endif() - -if(AIMRT_BUILD_EXAMPLES AND AIMRT_BUILD_WITH_ROS2) - add_subdirectory(example_ros2) -endif() - if(AIMRT_BUILD_WITH_PROTOBUF) add_subdirectory(common) - add_subdirectory(geometry) add_subdirectory(sensor) - add_subdirectory(visualization) + + if(AIMRT_BUILD_EXAMPLES) + add_subdirectory(example) + endif() + + if(AIMRT_BUILD_TIME_MANIPULATOR_PLUGIN) + add_subdirectory(plugins/time_manipulator_plugin) + endif() + + if(AIMRT_BUILD_PARAMETER_PLUGIN) + add_subdirectory(plugins/parameter_plugin) + endif() + + if(AIMRT_BUILD_RECORD_PLAYBACK_PLUGIN) + add_subdirectory(plugins/record_playback_plugin) + endif() + + if(AIMRT_BUILD_LOG_CONTROL_PLUGIN) + add_subdirectory(plugins/log_control_plugin) + endif() + endif() -if(AIMRT_BUILD_WITH_PROTOBUF AND AIMRT_BUILD_TIME_MANIPULATOR_PLUGIN) - add_subdirectory(plugins/time_manipulator_plugin) -endif() +if(AIMRT_BUILD_WITH_ROS2) + if(AIMRT_BUILD_EXAMPLES) + add_subdirectory(example_ros2) + endif() -if(AIMRT_BUILD_WITH_PROTOBUF AND AIMRT_BUILD_PARAMETER_PLUGIN) - add_subdirectory(plugins/parameter_plugin) -endif() - -if(AIMRT_BUILD_WITH_PROTOBUF AND AIMRT_BUILD_RECORD_PLAYBACK_PLUGIN) - add_subdirectory(plugins/record_playback_plugin) -endif() - -if(AIMRT_BUILD_WITH_PROTOBUF AND AIMRT_BUILD_LOG_CONTROL_PLUGIN) - add_subdirectory(plugins/log_control_plugin) -endif() - -if(AIMRT_BUILD_WITH_ROS2 AND AIMRT_BUILD_ROS2_PLUGIN) - add_subdirectory(plugins/ros2_plugin_proto) + if(AIMRT_BUILD_ROS2_PLUGIN OR AIMRT_BUILD_BAGTRANS) + add_subdirectory(plugins/ros2_plugin_proto) + endif() endif() diff --git a/src/protocols/geometry/CMakeLists.txt b/src/protocols/geometry/CMakeLists.txt deleted file mode 100644 index f1805498c..000000000 --- a/src/protocols/geometry/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) 2023, AgiBot Inc. -# All rights reserved. diff --git a/src/protocols/sensor/joint.proto b/src/protocols/sensor/joint.proto deleted file mode 100644 index ecbb4a74f..000000000 --- a/src/protocols/sensor/joint.proto +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2023, AgiBot Inc. -// All rights reserved. - -syntax = "proto3"; - -import "header.proto"; - -package aimrt.protocols.sensor; - -message SingleJointState { - string name = 1; - double position = 2; - double velocity = 3; - double effort = 4; -} - -message JointState { - aimrt.protocols.common.Header header = 1; - repeated SingleJointState data = 2; -} - -message SingleJointStateWithPD { - string name = 1; - double position = 2; - double velocity = 3; - double effort = 4; - double stiffness = 5; - double damping = 6; -} - -message JointStateWithPD { - aimrt.protocols.common.Header header = 1; - repeated SingleJointStateWithPD data = 2; -} diff --git a/src/protocols/visualization/CMakeLists.txt b/src/protocols/visualization/CMakeLists.txt deleted file mode 100644 index f1805498c..000000000 --- a/src/protocols/visualization/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) 2023, AgiBot Inc. -# All rights reserved. diff --git a/src/runtime/core/CMakeLists.txt b/src/runtime/core/CMakeLists.txt index 8a7c87f27..ca02a2aae 100644 --- a/src/runtime/core/CMakeLists.txt +++ b/src/runtime/core/CMakeLists.txt @@ -25,6 +25,9 @@ add_library(${CUR_TARGET_ALIAS_NAME} ALIAS ${CUR_TARGET_NAME}) # Set source file of target target_sources(${CUR_TARGET_NAME} PRIVATE ${src}) +# Set head files of target +target_sources(${CUR_TARGET_NAME} INTERFACE FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES ${head_files}) + # Set include path of target target_include_directories( ${CUR_TARGET_NAME} @@ -49,6 +52,18 @@ add_werror(${CUR_TARGET_NAME}) # Set version of target target_compile_definitions(${CUR_TARGET_NAME} PUBLIC AIMRT_VERSION="${AIMRT_VERSION}") +# Set installation of target +if(AIMRT_INSTALL) + set_property(TARGET ${CUR_TARGET_NAME} PROPERTY EXPORT_NAME ${CUR_TARGET_ALIAS_NAME}) + install( + TARGETS ${CUR_TARGET_NAME} + EXPORT ${INSTALL_CONFIG_NAME} + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + FILE_SET HEADERS + DESTINATION include/aimrt/${CUR_DIR}) +endif() + # Set test of target if(AIMRT_BUILD_TESTS AND test_files) add_gtest_target(TEST_TARGET ${CUR_TARGET_NAME} TEST_SRC ${test_files}) diff --git a/src/runtime/core/module/module_manager.cc b/src/runtime/core/module/module_manager.cc index 8251621a0..02beb9f2f 100644 --- a/src/runtime/core/module/module_manager.cc +++ b/src/runtime/core/module/module_manager.cc @@ -398,6 +398,8 @@ std::list> ModuleManager::GenInitializationR state_.load() == State::kInit, "Method can only be called when state is 'Init'."); + std::list> report; + std::vector> module_info_table = {{"name", "pkg", "version"}}; @@ -413,7 +415,31 @@ std::list> ModuleManager::GenInitializationR module_info_table.emplace_back(std::move(cur_module_info)); } - return {{"Module Info List", aimrt::common::util::DrawTable(module_info_table)}}; + report.emplace_back( + std::pair{ + "Module Info List", + aimrt::common::util::DrawTable(module_info_table)}); + + std::vector unused_module_options_vec; + for (const auto& item : options_.modules_options) { + auto finditr = std::find_if( + module_detail_info_vec_.begin(), module_detail_info_vec_.end(), + [name = item.name](const util::ModuleDetailInfo* ptr) { + return name == ptr->name; + }); + + if (finditr == module_detail_info_vec_.end()) + unused_module_options_vec.emplace_back(item.name); + } + + if (!unused_module_options_vec.empty()) { + report.emplace_back( + std::pair{ + "Unused Module Options Warning", + "[ " + aimrt::common::util::JoinVec(unused_module_options_vec, " , ") + " ]"}); + } + + return report; } } // namespace aimrt::runtime::core::module diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 91045eec6..1b8f144d0 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -16,10 +16,10 @@ if(AIMRT_BUILD_CLI_TOOLS) add_subdirectory(aimrt_cli) endif() +if(AIMRT_BUILD_WITH_ROS2 AND AIMRT_BUILD_BAGTRANS) + add_subdirectory(bagtrans) +endif() + if(AIMRT_BUILD_PYTHON_RUNTIME AND AIMRT_BUILD_PYTHON_PACKAGE) add_subdirectory(package_aimrt_py) endif() - -if(AIMRT_BUILD_WITH_ROS2 AND AIMRT_BUILD_RECORD_PLAYBACK_PLUGIN) - add_subdirectory(bagtrans) -endif() diff --git a/src/tools/aimrt_cli/aimrt_cli/templates/workspace/ws_CMakeLists.txt.jinja2 b/src/tools/aimrt_cli/aimrt_cli/templates/workspace/ws_CMakeLists.txt.jinja2 index 8b81c1018..351822bd7 100644 --- a/src/tools/aimrt_cli/aimrt_cli/templates/workspace/ws_CMakeLists.txt.jinja2 +++ b/src/tools/aimrt_cli/aimrt_cli/templates/workspace/ws_CMakeLists.txt.jinja2 @@ -29,28 +29,27 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_CXX_VISIBLITY_INLINES_HIDDEN ON) set(BUILD_SHARED_LIBS OFF) - if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") if({{ project_name | upper }}_BUILD_TESTS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") endif() endif() - if(MSVC) - add_compile_options(/wd4819) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") - endif() - - if(WIN32) - add_compile_definitions(NOMINMAX) - endif() - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_compile_options(/utf-8 /wd4819) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") +endif() + +if(WIN32) + add_compile_definitions(NOMINMAX) +endif() + # Include cmake module include(NamespaceTool) diff --git a/src/tools/package_aimrt_py/CMakeLists.txt b/src/tools/package_aimrt_py/CMakeLists.txt index 3b3caf428..e740fec75 100644 --- a/src/tools/package_aimrt_py/CMakeLists.txt +++ b/src/tools/package_aimrt_py/CMakeLists.txt @@ -2,7 +2,7 @@ # All rights reserved. get_target_property(py_files aimrt::runtime::python_runtime PY_FILES) -file(GLOB_RECURSE gencode_file ${PROJECT_SOURCE_DIR}/src/tools/protoc_plugin_py_gen_aimrt_py_rpc/*.py) # TODO +file(GLOB_RECURSE gencode_file ${PROJECT_SOURCE_DIR}/src/tools/protoc_plugin_py_gen_aimrt_py_rpc/*.py) list(APPEND py_files ${gencode_file}) set(AIMRT_PY_PKG_DIR ${CMAKE_BINARY_DIR}/aimrt_py_pkg)