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

[pkg-config] Add new port #11523

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions ports/pkg-config/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Source: pkg-config
Version: 0.29.2
Homepage: https://gitlab.freedesktop.org/pkg-config/pkg-config
Description: pkg-config is a script to make putting together all the build flags when compiling/linking a lot easier.
Build-Depends: glib[core]
49 changes: 49 additions & 0 deletions ports/pkg-config/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) # Tool build no library or includes

vcpkg_from_gitlab(
GITLAB_URL https://gitlab.freedesktop.org/
OUT_SOURCE_PATH SOURCE_PATH
REPO pkg-config/pkg-config
REF edf8e6f0ea77ede073f07bff0d2ae1fc7a38103b #v0.29.2
SHA512 537bace09ff183ec793587fc7cf091d75cd5ec34efc1261227de70a15631f40558528f19dbe9e3f2eb8bc24bed21003a01c7766c849ae498031c0c1ae322e314
HEAD_REF master
)

# Remove if GLIB installs a *.pc file or keep it to make it independent of pkg-config itself
set(GLIBS "-lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0")
if(VCPKG_TARGET_IS_WINDOWS)
set(GLIB_LIBS_DEBUG "-L${CURRENT_INSTALLED_DIR}/debug/lib ${GLIBS} -lzlibd")
set(GLIB_LIBS_RELEASE "-L${CURRENT_INSTALLED_DIR}/lib ${GLIBS} -lzlib")
else()
set(GLIB_LIBS_DEBUG "-L${CURRENT_INSTALLED_DIR}/lib ${GLIBS} -lz -pthread")
set(GLIB_LIBS_RELEASE "-L${CURRENT_INSTALLED_DIR}/lib ${GLIBS} -lz -pthread")
endif()

set(ENV{GLIB_CFLAGS} "-I${CURRENT_INSTALLED_DIR}/include")
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
AUTOCONFIG
CONFIG_DEPENDENT_ENVIROMNENT "GLIB_LIBS"
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
)

vcpkg_install_make()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug) # no need for debug tools

vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin)

# # Handle copyright
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

# pkg-config depends on glib. Note that glib build-depends on pkg-config,
# but you can just set the corresponding environment variables (ZLIB_LIBS,
# ZLIB_CFLAGS are the only needed ones when this is written) to build it.

# pkg-config also either needs an earlier version of itself to find glib
# or you need to set GLIB_CFLAGS and GLIB_LIBS to the correct values for
# where it's installed in your system.

# If this requirement is too cumbersome, a bundled copy of a recent glib
# stable release is included. Pass --with-internal-glib to configure to
# use this copy.
2 changes: 2 additions & 0 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,8 @@ pixel:x64-windows=fail
pixel:x64-windows-static=fail
pixel:x86-windows=fail
pixel:x64-linux=ignore
# Make currently does not support crosscompile.
pkg-config:arm64-windows=fail
platform-folders:arm-uwp=fail
platform-folders:x64-uwp=fail
plib:arm-uwp=fail
Expand Down
21 changes: 20 additions & 1 deletion scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
## ### OPTIONS_DEBUG
## Additional options passed to configure during the Debug configuration. These are in addition to `OPTIONS`.
##
## ### CONFIG_DEPENDENT_ENVIROMNENT
## List of additional configuration dependent enviroment variables to set.
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
## Pass SOMEVAR to set the enviroment and have SOMEVAR_(DEBUG|RELEASE) set in the portfile to the appriopiate values
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
## General enviromnent variables can be set from within the portfile itself.
##
## ## Notes
## This command supplies many common arguments to configure. To see the full list, examine the source.
##
Expand Down Expand Up @@ -110,7 +115,7 @@ function(vcpkg_configure_make)
cmake_parse_arguments(_csc
"AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE"
"SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL"
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE"
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIG_DEPENDENT_ENVIROMNENT"
${ARGN}
)
# Backup enviromnent variables
Expand Down Expand Up @@ -421,6 +426,12 @@ function(vcpkg_configure_make)
endif()

foreach(_buildtype IN LISTS _buildtypes)
foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIROMNENT})
if(ENV{${ENV_VAR}})
set(BACKUP_CONFIG_${ENV_VAR} "$ENV{${ENV_VAR}}")
endif()
set(ENV{${ENV_VAR}} "${${ENV_VAR}_${_buildtype}}")
endforeach()
set(TAR_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}")
file(MAKE_DIRECTORY "${TAR_DIR}")
file(RELATIVE_PATH RELATIVE_BUILD_PATH "${TAR_DIR}" "${SRC_DIR}")
Expand Down Expand Up @@ -477,6 +488,14 @@ function(vcpkg_configure_make)
unset(ENV{PKG_CONFIG_PATH})
endif()
unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype})

foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIROMNENT})
if(BACKUP_CONFIG_${ENV_VAR})
set(ENV{${ENV_VAR}} "${BACKUP_CONFIG_${ENV_VAR}}")
else()
unset(ENV{${ENV_VAR}})
endif()
endforeach()
endforeach()

# Restore enviromnent
Expand Down