Skip to content

Commit

Permalink
[pkgconf] enable search for system libs on linux (#23010)
Browse files Browse the repository at this point in the history
* pkgconf enable system lookup on linux

* verison stuff

* use ubuntu defaults.

* version stuff

* WIP get libpaths from CMake

* just get colmap trace for fun

* merge opensuse and ubuntu settings. should be good for most systems.

* revert colmap change

* version stuff

Co-authored-by: Billy Robert O'Neal III <[email protected]>
  • Loading branch information
Neumann-A and BillyONeal authored Feb 24, 2022
1 parent b7a1088 commit 3f3efcc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
53 changes: 53 additions & 0 deletions ports/pkgconf/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,59 @@ vcpkg_configure_meson(
NO_PKG_CONFIG
OPTIONS -Dtests=false
)

set(systemsuffix "")
set(architectureprefix "")

set(SYSTEM_LIBDIR "")
set(PKG_DEFAULT_PATH "")
set(SYSTEM_INCLUDEDIR "")
set(PERSONALITY_PATH "personality.d")


if(NOT VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_CROSSCOMPILING AND VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
# These defaults are obtained from pkgconf/pkg-config on Ubuntu and OpenSuse
# vcpkg cannot do system introspection to obtain/set these values since it would break binary caching.
set(SYSTEM_INCLUDEDIR "/usr/include")
# System lib dirs will be stripped from -L from the pkg-config output
set(SYSTEM_LIBDIR "/lib:/lib/i386-linux-gnu:/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnux32:/lib64:/lib32:/libx32:/usr/lib:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnux32:/usr/lib64:/usr/lib32:/usr/libx32")
set(PKG_DEFAULT_PATH "/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig")
set(PERSONALITY_PATH "/usr/share/pkgconfig/personality.d:/etc/pkgconfig/personality.d")
endif()

if(DEFINED VCPKG_pkgconf_SYSTEM_LIBDIR)
set(SYSTEM_LIBDIR "${VCPKG_pkgconf_SYSTEM_LIBDIR}")
endif()
if(DEFINED VCPKG_pkgconf_PKG_DEFAULT_PATH)
set(PKG_DEFAULT_PATH "${VCPKG_pkgconf_PKG_DEFAULT_PATH}")
endif()
if(DEFINED VCPKG_pkgconf_SYSTEM_INCLUDEDIR)
set(SYSTEM_INCLUDEDIR "${VCPKG_pkgconf_SYSTEM_INCLUDEDIR}")
endif()
if(DEFINED VCPKG_pkgconf_PERSONALITY_PATH)
set(PERSONALITY_PATH "${VCPKG_pkgconf_PERSONALITY_PATH}")
endif()


set(pkgconfig_file "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/libpkgconf/config.h")
if(EXISTS "${pkgconfig_file}")
file(READ "${pkgconfig_file}" contents)
string(REGEX REPLACE "#define PKG_DEFAULT_PATH [^\n]+" "#define PKG_DEFAULT_PATH \"${PKG_DEFAULT_PATH}\"" contents "${contents}")
string(REGEX REPLACE "#define SYSTEM_INCLUDEDIR [^\n]+" "#define SYSTEM_INCLUDEDIR \"${SYSTEM_INCLUDEDIR}\"" contents "${contents}")
string(REGEX REPLACE "#define SYSTEM_LIBDIR [^\n]+" "#define SYSTEM_LIBDIR \"${SYSTEM_LIBDIR}\"" contents "${contents}")
string(REGEX REPLACE "#define PERSONALITY_PATH [^\n]+" "#define PERSONALITY_PATH \"${PERSONALITY_PATH}\"" contents "${contents}")
file(WRITE "${pkgconfig_file}" "${contents}")
endif()
set(pkgconfig_file "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/libpkgconf/config.h")
if(EXISTS "${pkgconfig_file}")
file(READ "${pkgconfig_file}" contents)
string(REGEX REPLACE "#define PKG_DEFAULT_PATH [^\n]+" "#define PKG_DEFAULT_PATH \"${PKG_DEFAULT_PATH}\"" contents "${contents}")
string(REGEX REPLACE "#define SYSTEM_INCLUDEDIR [^\n]+" "#define SYSTEM_INCLUDEDIR \"${SYSTEM_INCLUDEDIR}\"" contents "${contents}")
string(REGEX REPLACE "#define SYSTEM_LIBDIR [^\n]+" "#define SYSTEM_LIBDIR \"${SYSTEM_LIBDIR}\"" contents "${contents}")
string(REGEX REPLACE "#define PERSONALITY_PATH [^\n]+" "#define PERSONALITY_PATH \"${PERSONALITY_PATH}\"" contents "${contents}")
file(WRITE "${pkgconfig_file}" "${contents}")
endif()

vcpkg_install_meson()
vcpkg_fixup_pkgconfig(SKIP_CHECK)

Expand Down
2 changes: 1 addition & 1 deletion ports/pkgconf/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pkgconf",
"version": "1.8.0",
"port-version": 1,
"port-version": 2,
"description": "pkgconf is a program which helps to configure compiler and linker flags for development libraries. It is similar to pkg-config from freedesktop.org.",
"homepage": "https://github.com/pkgconf/pkgconf",
"supports": "!uwp",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5338,7 +5338,7 @@
},
"pkgconf": {
"baseline": "1.8.0",
"port-version": 1
"port-version": 2
},
"platform-folders": {
"baseline": "4.1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/pkgconf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "5b599bd7dbbbc7837f7dbcf1b111478da076e2a4",
"version": "1.8.0",
"port-version": 2
},
{
"git-tree": "cbcb5f984f7713a636caa075f06b755d37493dbd",
"version": "1.8.0",
Expand Down

0 comments on commit 3f3efcc

Please sign in to comment.