From 70ab27fcad50241d72e0fe235ec4012f0ce7551e Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Wed, 24 Jun 2020 23:59:32 +0200 Subject: [PATCH] =?UTF-8?q?[ignition-plugin1]=20Add=20new=20port=20?= =?UTF-8?q?=F0=9F=A4=96=20(#11275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ignition-plugin1] Add new port * vcpkg_fixup_cmake_targets: Add DO_NOT_DELETE_PARENT_CONFIG_PATH By default the vcpkg_fixup_cmake_targets script remove the parent path of CONFIG_PATH if it named "cmake", this behaviour is not convenient for ports that install more than one CMake package config file, and for which vcpkg_fixup_cmake_targets is invoked multiple times. To optionally disable this behaviour, this commit adds the option DO_NOT_DELETE_PARENT_CONFIG_PATH to vcpkg_fixup_cmake_targets. * [ignition-modularscripts] Add support for ignition libraries that install multiple CMake package config files Some ignition libraries install several CMake package config files, to represent the different components of the library. This commit modifies the ignition_modular_library function to fixup correctly all the cmake package config files. * vcpkg_fixup_pkgconfig: Move definition of SYSTEM_LIBRARIES to vcpkg_common_definitions To correctly validate installed pkg-config files, vcpkg_fixup_pkgconfig needs to know for each platform which libraries are not managed by vcpkg. This commits improve this definitions for all the triplet supported by vcpkg, and move this definition to vcpkg_common_definitions in a way that permit custom triplets to overload its value. --- docs/maintainers/vcpkg_fixup_cmake_targets.md | 7 ++++++- ports/ignition-modularscripts/CONTROL | 2 +- .../ignition_modular_library.cmake | 18 ++++++++++++++--- ports/ignition-plugin1/CONTROL | 5 +++++ ports/ignition-plugin1/portfile.cmake | 7 +++++++ scripts/cmake/vcpkg_common_definitions.cmake | 20 +++++++++++++++++++ scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 17 ++++++++++------ scripts/cmake/vcpkg_fixup_pkgconfig.cmake | 4 ++-- 8 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 ports/ignition-plugin1/CONTROL create mode 100644 ports/ignition-plugin1/portfile.cmake diff --git a/docs/maintainers/vcpkg_fixup_cmake_targets.md b/docs/maintainers/vcpkg_fixup_cmake_targets.md index 5abd7c6224..18e8d08679 100644 --- a/docs/maintainers/vcpkg_fixup_cmake_targets.md +++ b/docs/maintainers/vcpkg_fixup_cmake_targets.md @@ -6,7 +6,7 @@ Additionally corrects common issues with targets, such as absolute paths and inc ## Usage ```cmake -vcpkg_fixup_cmake_targets([CONFIG_PATH ] [TARGET_PATH ]) +vcpkg_fixup_cmake_targets([CONFIG_PATH ] [TARGET_PATH ] [DO_NOT_DELETE_PARENT_CONFIG_PATH]) ``` ## Parameters @@ -22,6 +22,11 @@ This needs to be specified if the port name differs from the `find_package()` na Defaults to `share/${PORT}`. +### DO_NOT_DELETE_PARENT_CONFIG_PATH +By default the parent directory of CONFIG_PATH is removed if it is named "cmake". +Passing this option disable such behavior, as it is convenient for ports that install +more than one CMake package configuration file. + ## Notes Transform all `/debug//*targets-debug.cmake` files and move them to `/`. Removes all `/debug//*targets.cmake` and `/debug//*config.cmake`. diff --git a/ports/ignition-modularscripts/CONTROL b/ports/ignition-modularscripts/CONTROL index 4dd2ac418f..efde5f1b4c 100644 --- a/ports/ignition-modularscripts/CONTROL +++ b/ports/ignition-modularscripts/CONTROL @@ -1,3 +1,3 @@ Source: ignition-modularscripts -Version: 2020-05-09 +Version: 2020-05-16 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 8b04d81778..f7b772d5f0 100644 --- a/ports/ignition-modularscripts/ignition_modular_library.cmake +++ b/ports/ignition-modularscripts/ignition_modular_library.cmake @@ -10,7 +10,18 @@ function(ignition_modular_build_library NAME MAJOR_VERSION SOURCE_PATH CMAKE_PAC # If necessary, move the CMake config files if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/cmake") - vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/${CMAKE_PACKAGE_NAME}" TARGET_PATH "share/${CMAKE_PACKAGE_NAME}") + # 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}/*") @@ -19,8 +30,9 @@ function(ignition_modular_build_library NAME MAJOR_VERSION SOURCE_PATH CMAKE_PAC "${CURRENT_PACKAGES_DIR}/share/${CMAKE_PACKAGE_NAME}/") endif() - # Remove debug files - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include + # 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) diff --git a/ports/ignition-plugin1/CONTROL b/ports/ignition-plugin1/CONTROL new file mode 100644 index 0000000000..ba3aa4c312 --- /dev/null +++ b/ports/ignition-plugin1/CONTROL @@ -0,0 +1,5 @@ +Source: ignition-plugin1 +Version: 1.1.0 +Homepage: https://ignitionrobotics.org/libs/plugin +Build-Depends: dlfcn-win32 (windows|uwp), ignition-cmake2, ignition-modularscripts +Description: Library for registering plugin libraries and dynamically loading them at runtime diff --git a/ports/ignition-plugin1/portfile.cmake b/ports/ignition-plugin1/portfile.cmake new file mode 100644 index 0000000000..daa6260474 --- /dev/null +++ b/ports/ignition-plugin1/portfile.cmake @@ -0,0 +1,7 @@ +include(${CURRENT_INSTALLED_DIR}/share/ignitionmodularscripts/ignition_modular_library.cmake) + +set(PACKAGE_VERSION "1.1.0") +ignition_modular_library(NAME plugin + VERSION ${PACKAGE_VERSION} + REF "ignition-plugin_${PACKAGE_VERSION}" + SHA512 0657c5816e67d02329a79364050b8a56957180e5b7481b01696c7369b063cbfedfc93793a8ad92d87d242d24e476283dc7847bd810a3de98d3ec5ae7d640568c) diff --git a/scripts/cmake/vcpkg_common_definitions.cmake b/scripts/cmake/vcpkg_common_definitions.cmake index 724644abcb..ee6f348499 100644 --- a/scripts/cmake/vcpkg_common_definitions.cmake +++ b/scripts/cmake/vcpkg_common_definitions.cmake @@ -16,6 +16,7 @@ ## VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX import library suffix for target (same as CMAKE_IMPORT_LIBRARY_SUFFIX) ## VCPKG_FIND_LIBRARY_PREFIXES target dependent prefixes used for find_library calls in portfiles ## VCPKG_FIND_LIBRARY_SUFFIXES target dependent suffixes used for find_library calls in portfiles +## VCPKG_SYSTEM_LIBRARIES list of libraries are provide by the toolchain and are not managed by vcpkg ## ``` ## ## CMAKE_STATIC_LIBRARY_(PREFIX|SUFFIX), CMAKE_SHARED_LIBRARY_(PREFIX|SUFFIX) and CMAKE_IMPORT_LIBRARY_(PREFIX|SUFFIX) are defined for the target @@ -111,3 +112,22 @@ set(CMAKE_IMPORT_LIBRARY_PREFIX "${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}") set(CMAKE_FIND_LIBRARY_SUFFIXES "${VCPKG_FIND_LIBRARY_SUFFIXES}" CACHE INTERNAL "") # Required by find_library set(CMAKE_FIND_LIBRARY_PREFIXES "${VCPKG_FIND_LIBRARY_PREFIXES}" CACHE INTERNAL "") # Required by find_library + +# Append platform libraries to VCPKG_SYSTEM_LIBRARIES +# The variable are just appended to permit to custom triplets define the variable + +# Platforms with libdl +if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_OSX) + list(APPEND VCPKG_SYSTEM_LIBRARIES dl) +endif() + +# Platforms with libm +if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_FREEBSD) + list(APPEND VCPKG_SYSTEM_LIBRARIES m) +endif() + +# Windows system libs +if(VCPKG_TARGET_IS_WINDOWS) + list(APPEND VCPKG_SYSTEM_LIBRARIES wsock32) + list(APPEND VCPKG_SYSTEM_LIBRARIES ws2_32) +endif() diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index b2faa4abe3..ec5ea05f57 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -6,7 +6,7 @@ ## ## ## Usage ## ```cmake -## vcpkg_fixup_cmake_targets([CONFIG_PATH ] [TARGET_PATH ]) +## vcpkg_fixup_cmake_targets([CONFIG_PATH ] [TARGET_PATH ] [DO_NOT_DELETE_PARENT_CONFIG_PATH]) ## ``` ## ## ## Parameters @@ -22,6 +22,11 @@ ## ## Defaults to `share/${PORT}`. ## +## ### DO_NOT_DELETE_PARENT_CONFIG_PATH +## By default the parent directory of CONFIG_PATH is removed if it is named "cmake". +## Passing this option disable such behavior, as it is convenient for ports that install +## more than one CMake package configuration file. +## ## ## Notes ## Transform all `/debug//*targets-debug.cmake` files and move them to `/`. ## Removes all `/debug//*targets.cmake` and `/debug//*config.cmake`. @@ -38,7 +43,7 @@ ## * [curl](https://github.com/Microsoft/vcpkg/blob/master/ports/curl/portfile.cmake) ## * [nlohmann-json](https://github.com/Microsoft/vcpkg/blob/master/ports/nlohmann-json/portfile.cmake) function(vcpkg_fixup_cmake_targets) - cmake_parse_arguments(_vfct "" "CONFIG_PATH;TARGET_PATH" "" ${ARGN}) + cmake_parse_arguments(_vfct "DO_NOT_DELETE_PARENT_CONFIG_PATH" "CONFIG_PATH;TARGET_PATH" "" ${ARGN}) if(_vfct_UNPARSED_ARGUMENTS) message(FATAL_ERROR "vcpkg_fixup_cmake_targets was passed extra arguments: ${_vfct_UNPARSED_ARGUMENTS}") @@ -85,13 +90,13 @@ function(vcpkg_fixup_cmake_targets) if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG} NAME) string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME) - if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake") + if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake" AND NOT _vfct_DO_NOT_DELETE_PARENT_CONFIG_PATH) file(REMOVE_RECURSE ${DEBUG_CONFIG}) else() get_filename_component(DEBUG_CONFIG_PARENT_DIR ${DEBUG_CONFIG} DIRECTORY) get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG_PARENT_DIR} NAME) string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME) - if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake") + if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake" AND NOT _vfct_DO_NOT_DELETE_PARENT_CONFIG_PATH) file(REMOVE_RECURSE ${DEBUG_CONFIG_PARENT_DIR}) endif() endif() @@ -99,13 +104,13 @@ function(vcpkg_fixup_cmake_targets) get_filename_component(RELEASE_CONFIG_DIR_NAME ${RELEASE_CONFIG} NAME) string(TOLOWER "${RELEASE_CONFIG_DIR_NAME}" RELEASE_CONFIG_DIR_NAME) - if(RELEASE_CONFIG_DIR_NAME STREQUAL "cmake") + if(RELEASE_CONFIG_DIR_NAME STREQUAL "cmake" AND NOT _vfct_DO_NOT_DELETE_PARENT_CONFIG_PATH) file(REMOVE_RECURSE ${RELEASE_CONFIG}) else() get_filename_component(RELEASE_CONFIG_PARENT_DIR ${RELEASE_CONFIG} DIRECTORY) get_filename_component(RELEASE_CONFIG_DIR_NAME ${RELEASE_CONFIG_PARENT_DIR} NAME) string(TOLOWER "${RELEASE_CONFIG_DIR_NAME}" RELEASE_CONFIG_DIR_NAME) - if(RELEASE_CONFIG_DIR_NAME STREQUAL "cmake") + if(RELEASE_CONFIG_DIR_NAME STREQUAL "cmake" AND NOT _vfct_DO_NOT_DELETE_PARENT_CONFIG_PATH) file(REMOVE_RECURSE ${RELEASE_CONFIG_PARENT_DIR}) endif() endif() diff --git a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake index 1256bef4a1..a5495a423b 100644 --- a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake +++ b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake @@ -194,8 +194,8 @@ endfunction() function(vcpkg_fixup_pkgconfig) cmake_parse_arguments(_vfpkg "" "" "RELEASE_FILES;DEBUG_FILES;SYSTEM_LIBRARIES;SYSTEM_PACKAGES;IGNORE_FLAGS" ${ARGN}) - if(VCPKG_TARGET_IS_LINUX) - list(APPEND _vfpkg_SYSTEM_LIBRARIES -ldl -lm) + if(VCPKG_SYSTEM_LIBRARIES) + list(APPEND _vfpkg_SYSTEM_LIBRARIES ${VCPKG_SYSTEM_LIBRARIES}) endif() message(STATUS "Fixing pkgconfig") if(_vfpkg_UNPARSED_ARGUMENTS)