mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
cleanup gz_msgs CMakeLists (#24450)
* cleanup gz_sim CMakeLists * Check if protobuf is found * ignore old protobuf float warning --------- Co-authored-by: jmackay2 <jmackay2@gmail.com>
This commit is contained in:
@@ -4,35 +4,10 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# message(FATAL_ERROR "JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE JAKE ")
|
|
||||||
|
|
||||||
# Check for Gazebo first
|
|
||||||
if(NOT DEFINED ENV{GZ_DISTRO})
|
|
||||||
set(GZ_DISTRO "harmonic" CACHE STRING "Gazebo distribution to use")
|
|
||||||
else()
|
|
||||||
set(GZ_DISTRO $ENV{GZ_DISTRO})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Set versions based on distribution
|
|
||||||
if(GZ_DISTRO STREQUAL "harmonic")
|
|
||||||
set(GZ_CMAKE_VERSION "3")
|
|
||||||
set(GZ_MSGS_VERSION "10")
|
|
||||||
set(GZ_TRANSPORT_VERSION "13")
|
|
||||||
elseif(GZ_DISTRO STREQUAL "ionic")
|
|
||||||
set(GZ_CMAKE_VERSION "4")
|
|
||||||
set(GZ_MSGS_VERSION "11")
|
|
||||||
set(GZ_TRANSPORT_VERSION "14")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unknown Gazebo distribution: ${GZ_DISTRO}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find required packages
|
# Find required packages
|
||||||
find_package(gz-transport${GZ_TRANSPORT_VERSION})
|
find_package(Protobuf)
|
||||||
if(gz-transport${GZ_TRANSPORT_VERSION}_FOUND)
|
|
||||||
find_package(gz-cmake${GZ_CMAKE_VERSION} REQUIRED)
|
|
||||||
find_package(gz-msgs${GZ_MSGS_VERSION} REQUIRED)
|
|
||||||
find_package(Protobuf REQUIRED)
|
|
||||||
|
|
||||||
|
if (Protobuf_FOUND)
|
||||||
# Generate protobuf messages
|
# Generate protobuf messages
|
||||||
file(GLOB MSGS_PROTOS "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
|
file(GLOB MSGS_PROTOS "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
|
||||||
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MSGS_PROTOS})
|
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MSGS_PROTOS})
|
||||||
@@ -49,6 +24,9 @@ if(gz-transport${GZ_TRANSPORT_VERSION}_FOUND)
|
|||||||
${Protobuf_INCLUDE_DIRS}
|
${Protobuf_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
target_link_libraries(px4_gz_msgs PUBLIC ${PROTOBUF_LIBRARIES})
|
target_link_libraries(px4_gz_msgs PUBLIC ${PROTOBUF_LIBRARIES})
|
||||||
|
if (Protobuf_VERSION VERSION_LESS "3.8")
|
||||||
|
target_compile_options(px4_gz_msgs PRIVATE -Wno-error=float-equal)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Export the binary dir for other modules
|
# Export the binary dir for other modules
|
||||||
set(PX4_GZ_MSGS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
|
set(PX4_GZ_MSGS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
|
||||||
|
|||||||
Reference in New Issue
Block a user