Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
38d175b
[vcpkg_configure_meson] Fix append host path
Mar 8, 2022
b858854
New functions vcpkg_setup_pkgconfig_path and vcpkg_restore_pkgconfig_…
Mar 8, 2022
f37504d
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
Mar 9, 2022
fefaa62
Fix bug, add cos
Mar 9, 2022
471c441
Apply suggestions
Mar 9, 2022
c302ed6
Merge branch 'master' of github.com:microsoft/vcpkg into dev/jack/22812
vicroms Mar 11, 2022
548a445
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
Mar 14, 2022
4889eb4
Merge branch 'dev/jack/22812' of https://github.com/JackBoosY/vcpkg i…
Mar 14, 2022
47168aa
Apply suggestions
Mar 14, 2022
4c52ff5
Apply suggestion
Mar 14, 2022
449c934
doc
Mar 14, 2022
3ef0734
Update docs/maintainers/vcpkg_setup_pkgconfig_path.cmake.md
JackBoosY Mar 22, 2022
f177768
Update scripts/cmake/vcpkg_setup_pkgconfig_path.cmake
JackBoosY Mar 22, 2022
fce9c18
Update scripts/cmake/vcpkg_configure_make.cmake
JackBoosY Mar 22, 2022
f67ae2f
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
Apr 7, 2022
5722870
Merge branch 'dev/jack/22812' of https://github.com/JackBoosY/vcpkg i…
Apr 7, 2022
9a7bdb4
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
Apr 12, 2022
1fd873e
Apply suggestions
Apr 18, 2022
767af25
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
Apr 18, 2022
4837448
Apply suggestion
Apr 18, 2022
20cd30a
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/…
May 6, 2022
94ec276
Apply suggestions
May 6, 2022
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
11 changes: 11 additions & 0 deletions docs/maintainers/internal/z_vcpkg_setup_pkgconfig_path.cmake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# z_vcpkg_setup_pkgconfig_path

Setup the generated pkgconfig file path to PKG_CONFIG_PATH environment variable or restore PKG_CONFIG_PATH environment variable.

```cmake
z_vcpkg_setup_pkgconfig_path(BASE_DIRS <"${CURRENT_INSTALLED_DIR}" ...>)
z_vcpkg_restore_pkgconfig_path()
```

`z_vcpkg_setup_pkgconfig_path` prepends `lib/pkgconfig` and `share/pkgconfig` directories for the given `BASE_DIRS` to the `PKG_CONFIG_PATH` environment variable. It creates or updates a backup of the previous value.
`z_vcpkg_restore_pkgconfig_path` shall be called when leaving the scope which called `z_vcpkg_setup_pkgconfig_path` in order to restore the original value from the backup.
1 change: 1 addition & 0 deletions docs/maintainers/portfile-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- [z\_vcpkg\_function\_arguments](internal/z_vcpkg_function_arguments.md)
- [z\_vcpkg\_get\_cmake\_vars](internal/z_vcpkg_get_cmake_vars.md)
- [z\_vcpkg\_prettify\_command\_line](internal/z_vcpkg_prettify_command_line.md)
- [z\_vcpkg\_setup\_pkgconfig\_path](internal/z_vcpkg_setup_pkgconfig_path.md)

## Scripts from Ports

Expand Down
22 changes: 4 additions & 18 deletions scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,6 @@ function(vcpkg_configure_make)
endif()
endif()
debug_message("ENV{LIBS}:$ENV{LIBS}")
vcpkg_find_acquire_program(PKGCONFIG)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static")
set(PKGCONFIG "${PKGCONFIG} --static") # Is this still required or was the PR changing the pc files accordingly merged?
endif()

# Run autoconf if necessary
if (arg_AUTOCONFIG OR requires_autoconfig)
Expand Down Expand Up @@ -767,13 +763,10 @@ function(vcpkg_configure_make)
endif()

# Setup PKG_CONFIG_PATH
set(pkgconfig_installed_dir "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/pkgconfig")
set(pkgconfig_installed_share_dir "${CURRENT_INSTALLED_DIR}/share/pkgconfig")
if(ENV{PKG_CONFIG_PATH})
set(backup_env_pkg_config_path_${current_buildtype} $ENV{PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_PATH} "${pkgconfig_installed_dir}${VCPKG_HOST_PATH_SEPARATOR}${pkgconfig_installed_share_dir}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}")
if ("${current_buildtype}" STREQUAL "DEBUG")
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}/debug")
else()
set(ENV{PKG_CONFIG_PATH} "${pkgconfig_installed_dir}${VCPKG_HOST_PATH_SEPARATOR}${pkgconfig_installed_share_dir}")
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}")
endif()

# Setup environment
Expand All @@ -794,7 +787,6 @@ function(vcpkg_configure_make)
set(link_config_backup "$ENV{_LINK_}")
set(ENV{_LINK_} "${LINK_ENV_${current_buildtype}}")
endif()
set(ENV{PKG_CONFIG} "${PKGCONFIG}")

vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) # LD_LIBRARY_PATH)
foreach(lib_env_var IN LISTS lib_env_vars)
Expand Down Expand Up @@ -834,13 +826,7 @@ function(vcpkg_configure_make)
file(RENAME "${target_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${short_name_${current_buildtype}}.log")
endif()
endif()

if(backup_env_pkg_config_path_${current_buildtype})
set(ENV{PKG_CONFIG_PATH} "${backup_env_pkg_config_path_${current_buildtype}}")
else()
unset(ENV{PKG_CONFIG_PATH})
endif()
unset(backup_env_pkg_config_path_${current_buildtype})
z_vcpkg_restore_pkgconfig_path()

if(link_config_backup)
set(ENV{_LINK_} "${link_config_backup}")
Expand Down
20 changes: 8 additions & 12 deletions scripts/cmake/vcpkg_configure_meson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,6 @@ function(vcpkg_configure_meson)
vcpkg_list(APPEND arg_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug']")
endif()

if(NOT arg_NO_PKG_CONFIG)
vcpkg_find_acquire_program(PKGCONFIG)
get_filename_component(PKGCONFIG_PATH ${PKGCONFIG} DIRECTORY)
vcpkg_add_to_path("${PKGCONFIG_PATH}")
set(pkgconfig_share_dir "${CURRENT_INSTALLED_DIR}/share/pkgconfig/")
endif()

set(buildtypes)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(buildname "DEBUG")
Expand All @@ -466,11 +459,12 @@ function(vcpkg_configure_meson)
message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}}")
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}")
#setting up PKGCONFIG
vcpkg_backup_env_variables(VARS PKG_CONFIG PKG_CONFIG_PATH)
if(NOT arg_NO_PKG_CONFIG)
set(ENV{PKG_CONFIG} "${PKGCONFIG}") # Set via native file?
set(pkgconfig_installed_dir "${CURRENT_INSTALLED_DIR}/${path_suffix_${buildtype}}lib/pkgconfig/")
vcpkg_host_path_list(APPEND ENV{PKG_CONFIG_PATH} "${pkgconfig_installed_dir}" "${pkgconfig_share_dir}" "$ENV{PKG_CONFIG_PATH}")
if ("${buildtype}" STREQUAL "DEBUG")
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}/debug")
else()
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}")
endif()
endif()

vcpkg_execute_required_process(
Expand All @@ -494,7 +488,9 @@ function(vcpkg_configure_meson)
endif()
message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}} done")

vcpkg_restore_env_variables(VARS PKG_CONFIG PKG_CONFIG_PATH)
if(NOT arg_NO_PKG_CONFIG)
z_vcpkg_restore_pkgconfig_path()
endif()
endforeach()

vcpkg_restore_env_variables(VARS INCLUDE)
Expand Down
23 changes: 5 additions & 18 deletions scripts/cmake/vcpkg_configure_qmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,8 @@ function(vcpkg_configure_qmake)
set(ENV{QMAKE_MACOSX_DEPLOYMENT_TARGET} ${VCPKG_OSX_DEPLOYMENT_TARGET})
endif()

vcpkg_backup_env_variables(VARS PKG_CONFIG_PATH)

vcpkg_find_acquire_program(PKGCONFIG)
set(ENV{PKG_CONFIG} "${PKGCONFIG}")
get_filename_component(PKGCONFIG_PATH "${PKGCONFIG}" DIRECTORY)
vcpkg_add_to_path("${PKGCONFIG_PATH}")

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH}
"${CURRENT_INSTALLED_DIR}/lib/pkgconfig"
"${CURRENT_INSTALLED_DIR}/share/pkgconfig"
"${CURRENT_PACKAGES_DIR}/lib/pkgconfig"
"${CURRENT_PACKAGES_DIR}/share/pkgconfig")
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}" "${CURRENT_PACKAGES_DIR}")

set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")

Expand Down Expand Up @@ -98,15 +87,11 @@ function(vcpkg_configure_qmake)
file(RENAME "${current_binary_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-rel.log")
endif()

vcpkg_restore_env_variables(VARS PKG_CONFIG_PATH)
z_vcpkg_restore_pkgconfig_path()
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH}
"${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig"
"${CURRENT_INSTALLED_DIR}/share/pkgconfig"
"${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig"
"${CURRENT_PACKAGES_DIR}/share/pkgconfig")
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}/debug" "${CURRENT_PACKAGES_DIR}/debug")

set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")

Expand Down Expand Up @@ -135,6 +120,8 @@ function(vcpkg_configure_qmake)
file(REMOVE "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-dbg.log")
file(RENAME "${current_binary_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/internal-config-${TARGET_TRIPLET}-dbg.log")
endif()

z_vcpkg_restore_pkgconfig_path()
endif()

endfunction()
48 changes: 48 additions & 0 deletions scripts/cmake/z_vcpkg_setup_pkgconfig_path.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#[===[
# z_vcpkg_setup_pkgconfig_path

`z_vcpkg_setup_pkgconfig_path` sets up environment variables to use `pkgconfig`, such as `PKG_CONFIG` and `PKG_CONFIG_PATH`.
The original values are restored with `z_vcpkg_restore_pkgconfig_path`. `BASE_DIRS` indicates the base directories to find `.pc` files; typically `${CURRENT_INSTALLED_DIR}`, or `${CURRENT_INSTALLED_DIR}/debug`.

```cmake
z_vcpkg_setup_pkgconfig_path(BASE_DIRS <"${CURRENT_INSTALLED_DIR}" ...>)
# Build process that may transitively invoke pkgconfig
z_vcpkg_restore_pkgconfig_path()
```

#]===]
function(z_vcpkg_setup_pkgconfig_path)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BASE_DIRS")

if(NOT DEFINED arg_BASE_DIRS OR "${arg_BASE_DIRS}" STREQUAL "")
message(FATAL_ERROR "BASE_DIRS is required.")
endif()
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

vcpkg_backup_env_variables(VARS PKG_CONFIG PKG_CONFIG_PATH)

vcpkg_find_acquire_program(PKGCONFIG)
get_filename_component(pkgconfig_path "${PKGCONFIG}" DIRECTORY)
vcpkg_add_to_path("${pkgconfig_path}")

set(ENV{PKG_CONFIG} "${PKGCONFIG}") # Set via native file?

foreach(base_dir IN LISTS arg_BASE_DIRS)
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${base_dir}/share/pkgconfig/")
endforeach()

foreach(base_dir IN LISTS arg_BASE_DIRS)
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${base_dir}/lib/pkgconfig/")
endforeach()
endfunction()

function(z_vcpkg_restore_pkgconfig_path)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "")
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

vcpkg_restore_env_variables(VARS PKG_CONFIG PKG_CONFIG_PATH)
endfunction()
1 change: 1 addition & 0 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ include("${SCRIPTS}/cmake/z_vcpkg_forward_output_variable.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_function_arguments.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_get_cmake_vars.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_prettify_command_line.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_setup_pkgconfig_path.cmake")

function(debug_message)
if(PORT_DEBUG)
Expand Down