Skip to content
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

[vcpkg/script] get infos from installed ports #17029

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions docs/maintainers/portfile-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- [vcpkg\_install\_qmake](vcpkg_install_qmake.md)
- [vcpkg\_minimum\_required](vcpkg_minimum_required.md)
- [vcpkg\_replace\_string](vcpkg_replace_string.md)
- [x\_vcpkg\_get\_port\_info](x_vcpkg_get_port_info.md)

## Internal Functions

Expand Down
26 changes: 26 additions & 0 deletions docs/maintainers/x_vcpkg_get_port_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# x_vcpkg_get_port_info

The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/x_vcpkg_get_port_info.md).

Experimental
Retrieve port information (e.g. installed features) of an already installed port.

## Usage
```cmake
x_vcpkg_get_port_info(
PORTS <portname>...
)
```
## Parameters
### PORTS
List of ports to retrieve information about.
Information will be stored in:
<PORT>_FEATURES: features <PORT> was installed with
<PORT>_LIBRARY_LINKAGE: VCPKG_LIBRARY_LINKAGE <PORT> was installed with

## Examples

* [pcl](https://github.com/microsoft/vcpkg/blob/master/ports/pcl/portfile.cmake)

## Source
[scripts/cmake/x\_vcpkg\_get\_port\_info.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/x_vcpkg_get_port_info.cmake)
2 changes: 1 addition & 1 deletion ports/pcl/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: pcl
Version: 1.11.1
Port-Version: 2
Port-Version: 3
Homepage: https://github.com/PointCloudLibrary/pcl
Description: Point Cloud Library (PCL) is open source library for 2D/3D image and point cloud processing.
Build-Depends: eigen3, flann, qhull, libpng, boost-system, boost-filesystem, boost-thread, boost-date-time, boost-iostreams, boost-random, boost-foreach, boost-dynamic-bitset, boost-property-map, boost-graph, boost-multi-array, boost-signals2, boost-sort, boost-ptr-container, boost-uuid, boost-interprocess, boost-asio
Expand Down
11 changes: 7 additions & 4 deletions ports/pcl/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
opengl WITH_OPENGL
vtk WITH_VTK
)

x_vcpkg_get_port_info(PORTS qhull flann boost-system)
string(COMPARE EQUAL "${boost-system_LIBRARY_LINKAGE}" "dynamic" BOOST_LINKAGE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This (boost) needs to be checked by someone.

string(COMPARE EQUAL "${qhull_LIBRARY_LINKAGE}" "dynamic" QHULL_LINKAGE)
string(COMPARE EQUAL "${flann_LIBRARY_LINKAGE}" "dynamic" FLANN_LINKAGE)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
# BUILD
-DBUILD_surface_on_nurbs=ON
# PCL
-DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=${BOOST_LINKAGE}
-DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=${FLANN_LINKAGE}
-DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=${QHULL_LINKAGE}
-DPCL_SHARED_LIBS=${PCL_SHARED_LIBS}
# WITH
-DWITH_LIBUSB=OFF
Expand Down
47 changes: 47 additions & 0 deletions scripts/cmake/x_vcpkg_get_port_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#[===[.md:
# x_vcpkg_get_port_info

Experimental
Retrieve port information (e.g. installed features) of an already installed port.

## Usage
```cmake
x_vcpkg_get_port_info(
PORTS <portname>...
)
```
## Parameters
### PORTS
List of ports to retrieve information about.
Information will be stored in:
<PORT>_FEATURES: features <PORT> was installed with
<PORT>_LIBRARY_LINKAGE: VCPKG_LIBRARY_LINKAGE <PORT> was installed with

## Examples

* [pcl](https://github.com/microsoft/vcpkg/blob/master/ports/pcl/portfile.cmake)
#]===]
function(x_vcpkg_get_port_info)
cmake_parse_arguments(PARSE_ARGV 0 x_vcpkg_get_port_info "" "" "PORTS")
if(NOT x_vcpkg_get_port_info_PORTS)
message(FATAL_ERROR "x_vcpkg_get_port_info requires parameter PORTS!")
endif()
string(TOLOWER "${x_vcpkg_get_port_info_PORTS}" x_vcpkg_get_port_info_PORTS)

foreach(_port IN LISTS x_vcpkg_get_port_info_PORTS )
set(_port_info "${CURRENT_INSTALLED_DIR}/share/${_port}/vcpkg_port_info.cmake")
if(EXISTS "${_port_info}")
include("${_port_info}")
endif()
set(${_port}_FEATURES "${${_port}_FEATURES}" PARENT_SCOPE)
endforeach()
endfunction()

# Write information about the port. Keep in sync with x_vcpkg_get_port_info
function(z_vcpkg_write_port_info)
set(_file "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg_port_info.cmake")
set(_contents "set(${PORT}_FEATURES \"${FEATURES}\")\n")
string(APPEND _contents "set(${PORT}_LIBRARY_LINKAGE \"${VCPKG_LIBRARY_LINKAGE}\")\n")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(WRITE "${_file}" "${_contents}")
endfunction()
3 changes: 3 additions & 0 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ if(CMD MATCHES "^BUILD$")
include("${SCRIPTS}/cmake/vcpkg_replace_string.cmake")
include("${SCRIPTS}/cmake/vcpkg_test_cmake.cmake")

include("${SCRIPTS}/cmake/x_vcpkg_get_port_info.cmake")

include("${SCRIPTS}/cmake/z_vcpkg_apply_patches.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_prettify_command_line.cmake")

include("${CURRENT_PORT_DIR}/portfile.cmake")
if(DEFINED PORT)
include("${SCRIPTS}/build_info.cmake")
z_vcpkg_write_port_info()
endif()
elseif(CMD MATCHES "^CREATE$")
file(TO_NATIVE_PATH "${VCPKG_ROOT_DIR}" NATIVE_VCPKG_ROOT_DIR)
Expand Down