Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/maintainers/vcpkg_fixup_cmake_targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Additionally corrects common issues with targets, such as absolute paths and inc

## Usage
```cmake
vcpkg_fixup_cmake_targets([CONFIG_PATH <share/${PORT}>] [TARGET_PATH <share/${PORT}>])
vcpkg_fixup_cmake_targets([CONFIG_PATH <share/${PORT}>] [TARGET_PATH <share/${PORT}>] [DO_NOT_DELETE_PARENT_CONFIG_PATH])
```

## Parameters
Expand All @@ -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/<CONFIG_PATH>/*targets-debug.cmake` files and move them to `/<TARGET_PATH>`.
Removes all `/debug/<CONFIG_PATH>/*targets.cmake` and `/debug/<CONFIG_PATH>/*config.cmake`.
Expand Down
2 changes: 1 addition & 1 deletion ports/ignition-modularscripts/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: ignition-modularscripts
Version: 2020-05-09
Version: 2020-05-16
Description: Vcpkg helpers to package ignition libraries
18 changes: 15 additions & 3 deletions ports/ignition-modularscripts/ignition_modular_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}/*")
Expand All @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions ports/ignition-plugin1/CONTROL
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions ports/ignition-plugin1/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions scripts/cmake/vcpkg_common_definitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
17 changes: 11 additions & 6 deletions scripts/cmake/vcpkg_fixup_cmake_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
##
## ## Usage
## ```cmake
## vcpkg_fixup_cmake_targets([CONFIG_PATH <share/${PORT}>] [TARGET_PATH <share/${PORT}>])
## vcpkg_fixup_cmake_targets([CONFIG_PATH <share/${PORT}>] [TARGET_PATH <share/${PORT}>] [DO_NOT_DELETE_PARENT_CONFIG_PATH])
## ```
##
## ## Parameters
Expand All @@ -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/<CONFIG_PATH>/*targets-debug.cmake` files and move them to `/<TARGET_PATH>`.
## Removes all `/debug/<CONFIG_PATH>/*targets.cmake` and `/debug/<CONFIG_PATH>/*config.cmake`.
Expand All @@ -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}")
Expand Down Expand Up @@ -85,27 +90,27 @@ 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()
endif()

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()
Expand Down
4 changes: 2 additions & 2 deletions scripts/cmake/vcpkg_fixup_pkgconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does pkgconfig need the system libraries on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the system libraries that I have encounter in pkg-config files on Windows are defined in https://github.com/microsoft/vcpkg/pull/11275/files#diff-c1846c91b47ff94ccee5e8a6a1658e62R130 . In particular, I found them in the pcap port (see https://github.com/microsoft/vcpkg/blob/2020.06/ports/libpcap/portfile.cmake#L89), and adding them in a centralized place seems to me consistent to what we are doing in Linux/macOS .

list(APPEND _vfpkg_SYSTEM_LIBRARIES ${VCPKG_SYSTEM_LIBRARIES})
endif()
message(STATUS "Fixing pkgconfig")
if(_vfpkg_UNPARSED_ARGUMENTS)
Expand Down