-
Notifications
You must be signed in to change notification settings - Fork 7.4k
ignition-msgs5: Add support for cross-compilation #11538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
traversaro
wants to merge
5
commits into
microsoft:master
from
traversaro:ignition-msgs-support-crosscompilation
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c24aa1a
protobuf: Do not install malformed CMake configuration files when cro…
traversaro cfd98a6
ignition-modularscripts: Add options to handle tools and custom CMAke…
traversaro 6921ebe
ignition-msgs5: Add support for crosscompilation
traversaro ded0872
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal fa1b7de
Merge branch 'master' of https://github.com/microsoft/vcpkg into igni…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| Source: ignition-modularscripts | ||
| Version: 2020-05-16 | ||
| Port-Version: 1 | ||
| Version: 2020-09-05 | ||
| Description: Vcpkg helpers to package ignition libraries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| From 8d3735616c34fdc266b45c614c6d179d72732066 Mon Sep 17 00:00:00 2001 | ||
| From: Silvio Traversaro <silvio.traversaro@iit.it> | ||
| Date: Sat, 23 May 2020 12:09:15 +0200 | ||
| Subject: [PATCH] Add CMake options to support cross-compilation | ||
|
|
||
| This commit adds two CMake options: | ||
| * INSTALL_IGN_MSGS_GEN_EXECUTABLE if this option is enabled, the | ||
| ign_msgs_gen protobuf executable plugin is also installed, so | ||
| that this option can be enabled in host builds to permit | ||
| cross-compilation builds to use it to generate the messages. | ||
| As this executable is not side by side installable with other | ||
| ignition-msgs installations with different major versions and is an | ||
| advanced option meant just for packaging, by default it is set to OFF. | ||
| * IGN_MSGS_GEN_EXECUTABLE: this string variable can be set to | ||
| have ign-msgs use a ign_msgs_gen executable plugin that was not | ||
| build by the project, to enable cross-compilation scenarios. | ||
|
|
||
| Signed-off-by: Silvio Traversaro <silvio.traversaro@iit.it> | ||
| --- | ||
| CMakeLists.txt | 13 ++++++++++++- | ||
| src/CMakeLists.txt | 6 +++++- | ||
| 2 files changed, 17 insertions(+), 2 deletions(-) | ||
|
|
||
| diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| index 62b56b1..1641489 100644 | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -20,7 +20,18 @@ ign_configure_project() | ||
| # Set project-specific options | ||
| #============================================================================ | ||
|
|
||
| -# ignition-msgs currently has no options that are unique to it | ||
| +option( | ||
| + INSTALL_IGN_MSGS_GEN_EXECUTABLE | ||
| + "Install the ign_msgs_gen executable." | ||
| + OFF) | ||
| +mark_as_advanced(INSTALL_IGN_MSGS_GEN_EXECUTABLE) | ||
| + | ||
| +set( | ||
| + IGN_MSGS_GEN_EXECUTABLE | ||
| + "$<TARGET_FILE:ign_msgs_gen>" | ||
| + CACHE STRING | ||
| + "ign_msgs_gen executable used in the ign_msgs_protoc CMake function.") | ||
| +mark_as_advanced(IGN_MSGS_GEN_EXECUTABLE) | ||
|
|
||
| #============================================================================ | ||
| # Search for project-specific dependencies | ||
| diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
| index f68bf3d..1eb5e36 100644 | ||
| --- a/src/CMakeLists.txt | ||
| +++ b/src/CMakeLists.txt | ||
| @@ -11,6 +11,9 @@ if (UNIX) | ||
| target_link_libraries(ign_msgs_gen pthread) | ||
| endif() | ||
|
|
||
| +if(INSTALL_IGN_MSGS_GEN_EXECUTABLE) | ||
| + install(TARGETS ign_msgs_gen DESTINATION ${IGN_BIN_INSTALL_DIR}) | ||
| +endif() | ||
|
|
||
| ################################################## | ||
| # A function that calls protoc on a protobuf file | ||
| @@ -57,7 +61,7 @@ function(ign_msgs_protoc) | ||
| list(APPEND ${ign_msgs_protoc_OUTPUT_CPP_CC_VAR} ${output_source}) | ||
| list(APPEND output_files ${output_header}) | ||
| list(APPEND output_files ${output_source}) | ||
| - list(APPEND protoc_args "--plugin=protoc-gen-ignmsgs=$<TARGET_FILE:ign_msgs_gen>") | ||
| + list(APPEND protoc_args "--plugin=protoc-gen-ignmsgs=${IGN_MSGS_GEN_EXECUTABLE}") | ||
| list(APPEND protoc_args "--cpp_out=dllexport_decl=IGNITION_MSGS_VISIBLE:${ign_msgs_protoc_OUTPUT_CPP_DIR}") | ||
| list(APPEND protoc_args "--ignmsgs_out" "${ign_msgs_protoc_OUTPUT_CPP_DIR}") | ||
| set(${ign_msgs_protoc_OUTPUT_CPP_HH_VAR} ${${ign_msgs_protoc_OUTPUT_CPP_HH_VAR}} PARENT_SCOPE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,46 @@ | ||
| # Explicitly disable cross-compilation until the upstream discussion | ||
| # https://github.com/ignitionrobotics/ign-msgs/issues/34 is solved | ||
| vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "linux" "uwp") | ||
| vcpkg_fail_port_install(ON_TARGET "linux") | ||
|
|
||
| include(${CURRENT_INSTALLED_DIR}/share/ignitionmodularscripts/ignition_modular_library.cmake) | ||
|
|
||
| if(CMAKE_HOST_WIN32 AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x86") | ||
| set(ignition_msgs_CROSSCOMPILING ON) | ||
| else() | ||
| set(ignition_msgs_CROSSCOMPILING OFF) | ||
| endif() | ||
|
|
||
| if(CMAKE_HOST_WIN32) | ||
| set(HOST_EXECUTABLE_SUFFIX ".exe") | ||
| else() | ||
| set(HOST_EXECUTABLE_SUFFIX "") | ||
| endif() | ||
|
|
||
| # This port needs to generate protobuf messages with a custom plugin generator, | ||
| # so it needs to have in Windows the relative protobuf dll available in the PATH | ||
| set(path_backup $ENV{PATH}) | ||
| vcpkg_add_to_path(${CURRENT_INSTALLED_DIR}/bin) | ||
| vcpkg_add_to_path(${CURRENT_INSTALLED_DIR}/debug/bin) | ||
| if(NOT ignition_msgs_CROSSCOMPILING) | ||
| set(path_backup $ENV{PATH}) | ||
| vcpkg_add_to_path(${CURRENT_INSTALLED_DIR}/bin) | ||
| vcpkg_add_to_path(${CURRENT_INSTALLED_DIR}/debug/bin) | ||
| set(CMAKE_OPTIONS "-DINSTALL_IGN_MSGS_GEN_EXECUTABLE:BOOL=ON") | ||
| set(TOOL_NAMES_OPTION TOOL_NAMES ign_msgs_gen) | ||
| else() | ||
| if(NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/${PORT}) | ||
| message(FATAL_ERROR "Cross-targetting ${PORT} requires the x86-windows ${PORT} to be available. Please install ${PORT}:x86-windows first.") | ||
| endif() | ||
| set(CMAKE_OPTIONS "-DIGN_MSGS_GEN_EXECUTABLE=${CURRENT_INSTALLED_DIR}/../x86-windows/tools/${PORT}/ign_msgs_gen${HOST_EXECUTABLE_SUFFIX}") | ||
| set(TOOL_NAMES_OPTION "") | ||
| endif() | ||
|
|
||
| ignition_modular_library(NAME msgs | ||
| VERSION "5.1.0" | ||
| SHA512 db485f737c465b310602342a1a751c561473e330eb18d1b322b32d13de246536fe6a7efdf245faaaa9be1c9bfce662b2d39d1bb7cffc37e52690893cb47cc2ee | ||
| PATCHES | ||
| "01-protobuf.patch") | ||
| "01-protobuf.patch" | ||
| # Backport https://github.com/ignitionrobotics/ign-msgs/pull/60 | ||
| "02-support-crosscompilation.patch" | ||
| CMAKE_OPTIONS "${CMAKE_OPTIONS}" | ||
| ${TOOL_NAMES_OPTION}) | ||
|
|
||
| # Restore old path | ||
| set(ENV{PATH} "${path_backup}") | ||
| if(NOT ignition_msgs_CROSSCOMPILING) | ||
| set(ENV{PATH} "${path_backup}") | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.