Skip to content

Commit

Permalink
Fix support for cross-compilation with protobuf 23
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro authored May 30, 2023
1 parent 7ddc3ea commit 9e1ff6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()
# In a cross-compilation scenario, it is possible that the ign_msgs_gen
# generator compiled for the target machine cannot be used to generate
# the C++ code corresponding to the .proto definition. For this scenario,
# the following two options can be used as follows.
# the following options can be used as follows.
# First of all, ign-msgs is compiled targeting the host machine, and in the
# build targeting the host, the INSTALL_IGN_MSGS_GEN_EXECUTABLE option is
# enabled:
Expand All @@ -40,7 +40,8 @@ endif()
# can be cross-compiled, and in the cross-compilation build the location of the
# host ign_msgs_gen is specified via the IGN_MSGS_GEN_EXECUTABLE
# CMake cache variable:
# > cmake -IGN_MSGS_GEN_EXECUTABLE=<host_install_prefix>/bin/ign_msgs_gen ..
# > cmake -DIGN_MSGS_PROTOC_EXECUTABLE=<host_install_prefix>/bin/protoc
# -DIGN_MSGS_GEN_EXECUTABLE=<host_install_prefix>/bin/ign_msgs_gen ..

option(
INSTALL_IGN_MSGS_GEN_EXECUTABLE
Expand All @@ -55,6 +56,13 @@ set(
"ign_msgs_gen executable used in the ign_msgs_protoc CMake function.")
mark_as_advanced(IGN_MSGS_GEN_EXECUTABLE)

set(
IGN_MSGS_PROTOC_EXECUTABLE
"$<TARGET_FILE:libprotobuf::protoc>"
CACHE STRING
"protoc executable used in the ign_msgs_protoc CMake function.")
mark_as_advanced(IGN_MSGS_PROTOC_EXECUTABLE)

#============================================================================
# Search for project-specific dependencies
#============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ foreach(proto_file ${proto_files})
INPUT_PROTO
${proto_file}
PROTOC_EXEC
protobuf::protoc
${IGN_MSGS_PROTOC_EXECUTABLE}
OUTPUT_CPP_DIR
"${PROJECT_BINARY_DIR}/include"
OUTPUT_RUBY_DIR
Expand Down

0 comments on commit 9e1ff6c

Please sign in to comment.