Skip to content

Commit

Permalink
fix: add error handling for local protoc compiler detection (AimRT#89)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
zhangyi1357 authored Nov 8, 2024
1 parent 0a63cb9 commit 29eb541
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ if(AIMRT_BUILD_WITH_PROTOBUF)
include(ProtobufGenCode)

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
"protoc"
CACHE STRING "Path to protoc compiler.")
${PROTOC_EXECUTABLE}
CACHE STRING "Path to local protoc compiler.")
add_executable(aimrt::protoc IMPORTED GLOBAL)
set_target_properties(aimrt::protoc PROPERTIES IMPORTED_LOCATION ${Protobuf_PROTOC_EXECUTABLE})
set_property(GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY "aimrt")
Expand All @@ -172,11 +178,8 @@ if(AIMRT_BUILD_WITH_ROS2)
cmake_policy(SET CMP0148 OLD)
endif()

# fix gflag
set(BUILD_TESTING
OFF
CACHE BOOL "")
include(GetJsonCpp)
include(GetYamlCpp)
find_package(rclcpp REQUIRED)
find_package(Python3 REQUIRED)
endif()
Expand Down

0 comments on commit 29eb541

Please sign in to comment.