mirror of https://github.com/microsoft/vcpkg.git
[z_vcpkg_setup_pkgconfig_path] debug needs `share/pkgconfig` (#36151)
Pass `share/pkgconfig` instead of `debug/share/pkgconfig`: The `share` location is for config-independent data. Integrate `CURRENT_PACKAGES_DIR` locations. Change the function interface to take a CONFIG parameter instead of prefix list (suggested below). Use `z_vcpkg_setup_pkgconfig_path` also for `vcpkg_fixup_pkgconfig` (which already had proper handling of `CURRENT_PACKAGES_DIR` and `share`). Remove redundant trailing slash. Extend unit test. Fixes consuming `wayland-protocols` and similar.
This commit is contained in:
parent
836a2d684d
commit
215a253559
|
|
@ -809,7 +809,8 @@ function(vcpkg_configure_make)
|
|||
set(relative_build_path .)
|
||||
endif()
|
||||
|
||||
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}")
|
||||
# Setup PKG_CONFIG_PATH
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG "${current_buildtype}")
|
||||
|
||||
# Setup environment
|
||||
set(ENV{CPPFLAGS} "${CPPFLAGS_${current_buildtype}}")
|
||||
|
|
|
|||
|
|
@ -418,11 +418,7 @@ function(vcpkg_configure_meson)
|
|||
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}")
|
||||
#setting up PKGCONFIG
|
||||
if(NOT arg_NO_PKG_CONFIG)
|
||||
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()
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG "${buildtype}")
|
||||
endif()
|
||||
|
||||
z_vcpkg_meson_setup_variables(${buildtype})
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ function(vcpkg_configure_qmake)
|
|||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}" "${CURRENT_PACKAGES_DIR}")
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG RELEASE)
|
||||
|
||||
set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ function(vcpkg_configure_qmake)
|
|||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
||||
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "${CURRENT_INSTALLED_DIR}/debug" "${CURRENT_PACKAGES_DIR}/debug")
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG DEBUG)
|
||||
|
||||
set(current_binary_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
||||
|
||||
|
|
|
|||
|
|
@ -116,18 +116,7 @@ function(z_vcpkg_fixup_pkgconfig_check_files arg_file arg_config)
|
|||
set(path_suffix_DEBUG /debug)
|
||||
set(path_suffix_RELEASE "")
|
||||
|
||||
if(DEFINED ENV{PKG_CONFIG_PATH})
|
||||
set(backup_env_pkg_config_path "$ENV{PKG_CONFIG_PATH}")
|
||||
else()
|
||||
unset(backup_env_pkg_config_path)
|
||||
endif()
|
||||
|
||||
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH}
|
||||
"${CURRENT_PACKAGES_DIR}${path_suffix_${arg_config}}/lib/pkgconfig"
|
||||
"${CURRENT_PACKAGES_DIR}/share/pkgconfig"
|
||||
"${CURRENT_INSTALLED_DIR}${path_suffix_${arg_config}}/lib/pkgconfig"
|
||||
"${CURRENT_INSTALLED_DIR}/share/pkgconfig"
|
||||
)
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG "${arg_config}")
|
||||
|
||||
# First make sure everything is ok with the package and its deps
|
||||
cmake_path(GET arg_file STEM LAST_ONLY package_name)
|
||||
|
|
@ -149,11 +138,8 @@ function(z_vcpkg_fixup_pkgconfig_check_files arg_file arg_config)
|
|||
else()
|
||||
debug_message("pkg-config --exists ${package_name} output: ${output}")
|
||||
endif()
|
||||
if(DEFINED backup_env_pkg_config_path)
|
||||
set(ENV{PKG_CONFIG_PATH} "${backup_env_pkg_config_path}")
|
||||
else()
|
||||
unset(ENV{PKG_CONFIG_PATH})
|
||||
endif()
|
||||
|
||||
z_vcpkg_restore_pkgconfig_path()
|
||||
endfunction()
|
||||
|
||||
function(vcpkg_fixup_pkgconfig)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
function(z_vcpkg_setup_pkgconfig_path)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BASE_DIRS")
|
||||
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "CONFIG" "")
|
||||
|
||||
if(NOT DEFINED arg_BASE_DIRS OR "${arg_BASE_DIRS}" STREQUAL "")
|
||||
message(FATAL_ERROR "BASE_DIRS is required.")
|
||||
if("${arg_CONFIG}" STREQUAL "")
|
||||
message(FATAL_ERROR "CONFIG is required.")
|
||||
endif()
|
||||
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||
|
|
@ -22,13 +22,19 @@ function(z_vcpkg_setup_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/")
|
||||
foreach(prefix IN ITEMS "${CURRENT_INSTALLED_DIR}" "${CURRENT_PACKAGES_DIR}")
|
||||
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${prefix}/share/pkgconfig")
|
||||
if(arg_CONFIG STREQUAL "RELEASE")
|
||||
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${prefix}/lib/pkgconfig")
|
||||
# search order is lib, share, external
|
||||
elseif(arg_CONFIG STREQUAL "DEBUG")
|
||||
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${prefix}/debug/lib/pkgconfig")
|
||||
# search order is debug/lib, share, external
|
||||
else()
|
||||
message(FATAL_ERROR "CONFIG must be either RELEASE or DEBUG.")
|
||||
endif()
|
||||
endforeach()
|
||||
# total search order is current packages dir, current installed dir, external
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_restore_pkgconfig_path)
|
||||
|
|
|
|||
|
|
@ -8,9 +8,23 @@ set(ENV{PKG_CONFIG} "/a/pkgconf")
|
|||
set(ENV{PKG_CONFIG_PATH} "1")
|
||||
set(saved_path "$ENV{PATH}")
|
||||
|
||||
z_vcpkg_setup_pkgconfig_path(BASE_DIRS "/2")
|
||||
block(SCOPE_FOR VARIABLES)
|
||||
|
||||
set(CURRENT_PACKAGES_DIR "P")
|
||||
set(CURRENT_INSTALLED_DIR "I")
|
||||
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG RELEASE)
|
||||
unit_test_check_variable_equal([[]] ENV{PKG_CONFIG} [[/a/pkgconf]])
|
||||
unit_test_match([[]] ENV{PKG_CONFIG_PATH} "^P.lib.pkgconfig.P.share.pkgconfig.I.lib.pkgconfig.I.share.pkgconfig.1\$")
|
||||
|
||||
z_vcpkg_restore_pkgconfig_path()
|
||||
unit_test_check_variable_equal([[]] ENV{PKG_CONFIG} [[/a/pkgconf]])
|
||||
unit_test_check_variable_equal([[]] ENV{PKG_CONFIG_PATH} "1")
|
||||
|
||||
z_vcpkg_setup_pkgconfig_path(CONFIG DEBUG)
|
||||
unit_test_check_variable_equal([[]] ENV{PKG_CONFIG} [[/a/pkgconf]])
|
||||
unit_test_check_variable_not_equal([[]] ENV{PKG_CONFIG_PATH} "1")
|
||||
unit_test_match([[]] ENV{PKG_CONFIG_PATH} "^P.debug.lib.pkgconfig.P.share.pkgconfig.I.debug.lib.pkgconfig.I.share.pkgconfig.1\$")
|
||||
|
||||
z_vcpkg_restore_pkgconfig_path()
|
||||
unit_test_check_variable_equal([[]] ENV{PKG_CONFIG} [[/a/pkgconf]])
|
||||
|
|
@ -20,3 +34,8 @@ unit_test_check_variable_equal([[]] ENV{PKG_CONFIG_PATH} "1")
|
|||
# It is hard to see which side effects a restore would have, so
|
||||
# this is expected behaviour for now.
|
||||
unit_test_check_variable_not_equal([[]] ENV{PATH} "${saved_path}")
|
||||
|
||||
unit_test_ensure_fatal_error([[ z_vcpkg_setup_pkgconfig_path() ]])
|
||||
unit_test_ensure_fatal_error([[ z_vcpkg_setup_pkgconfig_path(CONFIG unknown) ]])
|
||||
|
||||
endblock()
|
||||
|
|
|
|||
Loading…
Reference in New Issue