diff --git a/ports/ignition-modularscripts/CONTROL b/ports/ignition-modularscripts/CONTROL index e52ae90a5a50e4..bb1f6f54f13f50 100644 --- a/ports/ignition-modularscripts/CONTROL +++ b/ports/ignition-modularscripts/CONTROL @@ -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 diff --git a/ports/ignition-modularscripts/ignition_modular_library.cmake b/ports/ignition-modularscripts/ignition_modular_library.cmake index b294c097b6fcf1..a217e183508db0 100644 --- a/ports/ignition-modularscripts/ignition_modular_library.cmake +++ b/ports/ignition-modularscripts/ignition_modular_library.cmake @@ -1,61 +1,3 @@ - -function(ignition_modular_build_library NAME MAJOR_VERSION SOURCE_PATH CMAKE_PACKAGE_NAME DEFAULT_CMAKE_PACKAGE_NAME IML_DISABLE_PKGCONFIG_INSTALL) - vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS -DBUILD_TESTING=OFF - ) - - vcpkg_install_cmake() - - # If necessary, move the CMake config files - if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/cmake") - # Some ignition libraries install library subcomponents, that are effectively additional cmake packages - # with name ${CMAKE_PACKAGE_NAME}-${COMPONENT_NAME}, so it is needed to call vcpkg_fixup_cmake_targets for them as well - file(GLOB COMPONENTS_CMAKE_PACKAGE_NAMES - LIST_DIRECTORIES TRUE - RELATIVE "${CURRENT_PACKAGES_DIR}/lib/cmake/" - "${CURRENT_PACKAGES_DIR}/lib/cmake/*") - - foreach(COMPONENT_CMAKE_PACKAGE_NAME IN LISTS COMPONENTS_CMAKE_PACKAGE_NAMES) - vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/${COMPONENT_CMAKE_PACKAGE_NAME}" - TARGET_PATH "share/${COMPONENT_CMAKE_PACKAGE_NAME}" - DO_NOT_DELETE_PARENT_CONFIG_PATH) - endforeach() - - file(GLOB_RECURSE CMAKE_RELEASE_FILES - "${CURRENT_PACKAGES_DIR}/lib/cmake/${CMAKE_PACKAGE_NAME}/*") - - file(COPY ${CMAKE_RELEASE_FILES} DESTINATION - "${CURRENT_PACKAGES_DIR}/share/${CMAKE_PACKAGE_NAME}/") - endif() - - # Remove unused files files - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake - ${CURRENT_PACKAGES_DIR}/debug/include - ${CURRENT_PACKAGES_DIR}/debug/lib/cmake - ${CURRENT_PACKAGES_DIR}/debug/share) - - # Make pkg-config files relocatable - if(NOT IML_DISABLE_PKGCONFIG_INSTALL) - if(VCPKG_TARGET_IS_LINUX) - set(SYSTEM_LIBRARIES SYSTEM_LIBRARIES pthread) - endif() - vcpkg_fixup_pkgconfig(${SYSTEM_LIBRARIES}) - else() - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/pkgconfig - ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig) - endif() - - # Find the relevant license file and install it - if(EXISTS "${SOURCE_PATH}/LICENSE") - set(LICENSE_PATH "${SOURCE_PATH}/LICENSE") - elseif(EXISTS "${SOURCE_PATH}/README.md") - set(LICENSE_PATH "${SOURCE_PATH}/README.md") - endif() - file(INSTALL ${LICENSE_PATH} DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) -endfunction() - ## # ignition_modular_library ## ## Download and build a library from the Ignition Robotics project ( https://ignitionrobotics.org/ ). @@ -101,6 +43,13 @@ endfunction() ## ### DISABLE_PKGCONFIG_INSTALL ## If present, disable installation of .pc pkg-config configuration files. ## +## ### CMAKE_OPTIONS +## A list of options to be passed to the CMake invocation. +## This is forwarded to the `vcpkg_configure_cmake` command. +## +## ### TOOL_NAMES +## A list of executable tools that need to be handled by this port. +## If present, this option is forwarded to the `vcpkg_copy_tools` command. ## ## ## Examples: ## @@ -110,7 +59,7 @@ endfunction() function(ignition_modular_library) set(options DISABLE_PKGCONFIG_INSTALL) set(oneValueArgs NAME VERSION SHA512 REF HEAD_REF CMAKE_PACKAGE_NAME) - set(multiValueArgs PATCHES) + set(multiValueArgs PATCHES CMAKE_OPTIONS TOOL_NAMES) cmake_parse_arguments(IML "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) string(REPLACE "." ";" IML_VERSION_LIST ${IML_VERSION}) @@ -132,6 +81,11 @@ function(ignition_modular_library) set(IML_CMAKE_PACKAGE_NAME ${DEFAULT_CMAKE_PACKAGE_NAME}) endif() + # If the CMAKE_OPTIONS option is omitted set it to an empty + if(NOT DEFINED IML_CMAKE_OPTIONS) + set(IML_CMAKE_OPTIONS "") + endif() + # Download library from github, to support also the --head option vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -143,5 +97,64 @@ function(ignition_modular_library) ) # Build library - ignition_modular_build_library(${IML_NAME} ${IML_MAJOR_VERSION} ${SOURCE_PATH} ${IML_CMAKE_PACKAGE_NAME} ${DEFAULT_CMAKE_PACKAGE_NAME} ${IML_DISABLE_PKGCONFIG_INSTALL}) + vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS -DBUILD_TESTING:BOOL=OFF ${IML_CMAKE_OPTIONS} + ) + + vcpkg_install_cmake() + + # If necessary, move the CMake config files + if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/cmake") + # Some ignition libraries install library subcomponents, that are effectively additional cmake packages + # with name ${CMAKE_PACKAGE_NAME}-${COMPONENT_NAME}, so it is needed to call vcpkg_fixup_cmake_targets for them as well + file(GLOB COMPONENTS_CMAKE_PACKAGE_NAMES + LIST_DIRECTORIES TRUE + RELATIVE "${CURRENT_PACKAGES_DIR}/lib/cmake/" + "${CURRENT_PACKAGES_DIR}/lib/cmake/*") + + foreach(COMPONENT_CMAKE_PACKAGE_NAME IN LISTS COMPONENTS_CMAKE_PACKAGE_NAMES) + vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/${COMPONENT_CMAKE_PACKAGE_NAME}" + TARGET_PATH "share/${COMPONENT_CMAKE_PACKAGE_NAME}" + DO_NOT_DELETE_PARENT_CONFIG_PATH) + endforeach() + + file(GLOB_RECURSE CMAKE_RELEASE_FILES + "${CURRENT_PACKAGES_DIR}/lib/cmake/${CMAKE_PACKAGE_NAME}/*") + + file(COPY ${CMAKE_RELEASE_FILES} DESTINATION + "${CURRENT_PACKAGES_DIR}/share/${CMAKE_PACKAGE_NAME}/") + endif() + + # Remove unused files files + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake + ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/lib/cmake + ${CURRENT_PACKAGES_DIR}/debug/share) + + # Make pkg-config files relocatable + if(NOT IML_DISABLE_PKGCONFIG_INSTALL) + if(VCPKG_TARGET_IS_LINUX) + set(SYSTEM_LIBRARIES SYSTEM_LIBRARIES pthread) + endif() + vcpkg_fixup_pkgconfig(${SYSTEM_LIBRARIES}) + else() + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/pkgconfig + ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig) + endif() + + # Find the relevant license file and install it + if(EXISTS "${SOURCE_PATH}/LICENSE") + set(LICENSE_PATH "${SOURCE_PATH}/LICENSE") + elseif(EXISTS "${SOURCE_PATH}/README.md") + set(LICENSE_PATH "${SOURCE_PATH}/README.md") + endif() + file(INSTALL ${LICENSE_PATH} DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + + # Handle tools + if(DEFINED IML_TOOL_NAMES) + vcpkg_copy_tools(TOOL_NAMES ${IML_TOOL_NAMES} AUTO_CLEAN) + endif() + endfunction() diff --git a/ports/ignition-msgs5/02-support-crosscompilation.patch b/ports/ignition-msgs5/02-support-crosscompilation.patch new file mode 100644 index 00000000000000..95bd0320576636 --- /dev/null +++ b/ports/ignition-msgs5/02-support-crosscompilation.patch @@ -0,0 +1,70 @@ +From 8d3735616c34fdc266b45c614c6d179d72732066 Mon Sep 17 00:00:00 2001 +From: Silvio Traversaro +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 +--- + 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 ++ "$" ++ 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=$") ++ 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) diff --git a/ports/ignition-msgs5/CONTROL b/ports/ignition-msgs5/CONTROL index 690ded1b6a60f5..9a82a46c87ffd5 100644 --- a/ports/ignition-msgs5/CONTROL +++ b/ports/ignition-msgs5/CONTROL @@ -3,4 +3,4 @@ Version: 5.1.0 Port-Version: 1 Build-Depends: ignition-modularscripts, ignition-cmake2, ignition-math6, protobuf, tinyxml2 Description: Middleware protobuf messages for robotics -Supports: !(arm|linux|uwp) \ No newline at end of file +Supports: !(linux) \ No newline at end of file diff --git a/ports/ignition-msgs5/portfile.cmake b/ports/ignition-msgs5/portfile.cmake index aec3a6cd75c385..196850cc365161 100644 --- a/ports/ignition-msgs5/portfile.cmake +++ b/ports/ignition-msgs5/portfile.cmake @@ -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() diff --git a/ports/protobuf/CONTROL b/ports/protobuf/CONTROL index 115b306c55ae64..7aabc7f4cf1ed0 100644 --- a/ports/protobuf/CONTROL +++ b/ports/protobuf/CONTROL @@ -3,7 +3,6 @@ Version: 3.13.0 Port-Version: 2 Homepage: https://github.com/protocolbuffers/protobuf Description: Protocol Buffers - Google's data interchange format - Feature: zlib Description: ZLib based features like Gzip streams Build-Depends: zlib diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake index 47510b5504ac2a..0bcfc078e05cc4 100644 --- a/ports/protobuf/portfile.cmake +++ b/ports/protobuf/portfile.cmake @@ -11,14 +11,14 @@ vcpkg_from_github( ) if(CMAKE_HOST_WIN32 AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND NOT VCPKG_TARGET_ARCHITECTURE MATCHES "x86") - set(protobuf_BUILD_PROTOC_BINARIES OFF) + set(protobuf_CROSSCOMPILING ON) elseif(CMAKE_HOST_WIN32 AND NOT VCPKG_TARGET_IS_MINGW AND NOT (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP)) - set(protobuf_BUILD_PROTOC_BINARIES OFF) + set(protobuf_CROSSCOMPILING ON) else() - set(protobuf_BUILD_PROTOC_BINARIES ON) + set(protobuf_CROSSCOMPILING OFF) endif() -if(NOT protobuf_BUILD_PROTOC_BINARIES AND NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/protobuf) +if(protobuf_CROSSCOMPILING AND NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/protobuf) message(FATAL_ERROR "Cross-targetting protobuf requires the x86-windows protoc to be available. Please install protobuf:x86-windows first.") endif() @@ -52,7 +52,7 @@ vcpkg_configure_cmake( -Dprotobuf_MSVC_STATIC_RUNTIME=${VCPKG_BUILD_STATIC_CRT} -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf - -Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES} + -Dprotobuf_BUILD_PROTOC_BINARIES=ON ${FEATURE_OPTIONS} ) @@ -94,7 +94,7 @@ endif() protobuf_try_remove_recurse_wait(${CURRENT_PACKAGES_DIR}/debug/share) if(CMAKE_HOST_WIN32) - if(protobuf_BUILD_PROTOC_BINARIES) + if(NOT protobuf_CROSSCOMPILING) vcpkg_copy_tools(TOOL_NAMES protoc) else() file(COPY ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)