fix: add error handling for local protoc compiler detection (#89)

* build: add error handling for local protoc compiler detection

Ensure that the local `protoc` compiler is found when `AIMRT_USE_LOCAL_PROTOC_COMPILER` is enabled. This improves setup reliability by providing clear feedback if `protoc` is missing, helping users avoid runtime issues.

* build: include YamlCpp for enhanced configuration support

Add support for YamlCpp to improve configuration handling alongside ROS2 dependencies.

* chore: remove redundant gflag setting

Clean up the CMake configuration by removing the unnecessary gflag setting for testing, streamlining the build process.
This commit is contained in:
zhangyi1357 2024-11-08 09:46:05 +08:00 committed by GitHub
parent 0a63cb9fe1
commit 29eb541fd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,9 +153,15 @@ if(AIMRT_BUILD_WITH_PROTOBUF)
include(ProtobufGenCode) include(ProtobufGenCode)
if(AIMRT_USE_LOCAL_PROTOC_COMPILER) if(AIMRT_USE_LOCAL_PROTOC_COMPILER)
find_program(PROTOC_EXECUTABLE protoc)
if(NOT PROTOC_EXECUTABLE)
message(FATAL_ERROR "AIMRT_USE_LOCAL_PROTOC_COMPILER is ON, but can not find protoc compiler, " #
"please install protoc and make it available in your PATH.")
endif()
message(STATUS "Found local protoc compiler: ${PROTOC_EXECUTABLE}")
set(Protobuf_PROTOC_EXECUTABLE set(Protobuf_PROTOC_EXECUTABLE
"protoc" ${PROTOC_EXECUTABLE}
CACHE STRING "Path to protoc compiler.") CACHE STRING "Path to local protoc compiler.")
add_executable(aimrt::protoc IMPORTED GLOBAL) add_executable(aimrt::protoc IMPORTED GLOBAL)
set_target_properties(aimrt::protoc PROPERTIES IMPORTED_LOCATION ${Protobuf_PROTOC_EXECUTABLE}) set_target_properties(aimrt::protoc PROPERTIES IMPORTED_LOCATION ${Protobuf_PROTOC_EXECUTABLE})
set_property(GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY "aimrt") set_property(GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY "aimrt")
@ -172,11 +178,8 @@ if(AIMRT_BUILD_WITH_ROS2)
cmake_policy(SET CMP0148 OLD) cmake_policy(SET CMP0148 OLD)
endif() endif()
# fix gflag
set(BUILD_TESTING
OFF
CACHE BOOL "")
include(GetJsonCpp) include(GetJsonCpp)
include(GetYamlCpp)
find_package(rclcpp REQUIRED) find_package(rclcpp REQUIRED)
find_package(Python3 REQUIRED) find_package(Python3 REQUIRED)
endif() endif()