diff --git a/ports/pkg-config/CONTROL b/ports/pkg-config/CONTROL new file mode 100644 index 00000000000000..b8a15a4da0496f --- /dev/null +++ b/ports/pkg-config/CONTROL @@ -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] diff --git a/ports/pkg-config/portfile.cmake b/ports/pkg-config/portfile.cmake new file mode 100644 index 00000000000000..7db16b0fd21351 --- /dev/null +++ b/ports/pkg-config/portfile.cmake @@ -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_ENVIRONMENT "GLIB_LIBS" +) + +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. \ No newline at end of file diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 4963f063d1e7ac..ba00e30fbb5e38 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -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 diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 9f31bebbc518df..de21166f35b156 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -44,6 +44,11 @@ ## ### OPTIONS_DEBUG ## Additional options passed to configure during the Debug configuration. These are in addition to `OPTIONS`. ## +## ### CONFIG_DEPENDENT_ENVIRONMENT +## List of additional configuration dependent environment variables to set. +## Pass SOMEVAR to set the environment and have SOMEVAR_(DEBUG|RELEASE) set in the portfile to the appropriate values +## General environment 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. ## @@ -110,10 +115,10 @@ 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_ENVIRONMENT" ${ARGN} ) - # Backup enviromnent variables + # Backup environment variables set(C_FLAGS_BACKUP "$ENV{CFLAGS}") set(CXX_FLAGS_BACKUP "$ENV{CXXFLAGS}") set(LD_FLAGS_BACKUP "$ENV{LDFLAGS}") @@ -180,8 +185,8 @@ function(vcpkg_configure_make) set(BUILD_TARGET "--build=${MSYS_HOST}-pc-mingw32 --target=arm-pc-mingw32 --host=i686-pc-mingw32") endif() - macro(_vcpkg_append_to_configure_enviromnent inoutstring var defaultval) - # Allows to overwrite settings in custom triplets via the enviromnent + macro(_vcpkg_append_to_configure_environment inoutstring var defaultval) + # Allows to overwrite settings in custom triplets via the environment if(ENV{${var}}) string(APPEND ${inoutstring} " ${var}='$ENV{${var}}'") else() @@ -190,16 +195,16 @@ function(vcpkg_configure_make) endmacro() set(CONFIGURE_ENV "") - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV CC "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV CXX "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV LD "link.exe -verbose") - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV AR "${MSYS_ROOT}/usr/share/automake-1.16/ar-lib lib.exe -verbose") - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV RANLIB ":") # Trick to ignore the RANLIB call - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers -all") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "link.exe -verbose") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${MSYS_ROOT}/usr/share/automake-1.16/ar-lib lib.exe -verbose") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") # Trick to ignore the RANLIB call + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers -all") # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS) - _vcpkg_append_to_configure_enviromnent(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") # Other maybe interesting variables to control # COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line. @@ -281,7 +286,7 @@ function(vcpkg_configure_make) list(JOIN _csc_OPTIONS_DEBUG " " _csc_OPTIONS_DEBUG) endif() - # Setup include enviromnent + # Setup include environment set(ENV{INCLUDE} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_BACKUP}") set(ENV{INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_PATH_BACKUP}") set(ENV{C_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${C_INCLUDE_PATH_BACKUP}") @@ -421,6 +426,12 @@ function(vcpkg_configure_make) endif() foreach(_buildtype IN LISTS _buildtypes) + foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIRONMENT}) + 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}") @@ -440,7 +451,7 @@ function(vcpkg_configure_make) set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}:${PKGCONFIG_INSTALLED_SHARE_DIR}") endif() - # Setup enviromnent + # Setup environment set(ENV{CFLAGS} ${CFLAGS_${_buildtype}}) set(ENV{CXXFLAGS} ${CXXFLAGS_${_buildtype}}) set(ENV{LDFLAGS} ${LDFLAGS_${_buildtype}}) @@ -477,9 +488,17 @@ function(vcpkg_configure_make) unset(ENV{PKG_CONFIG_PATH}) endif() unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) + + foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIRONMENT}) + if(BACKUP_CONFIG_${ENV_VAR}) + set(ENV{${ENV_VAR}} "${BACKUP_CONFIG_${ENV_VAR}}") + else() + unset(ENV{${ENV_VAR}}) + endif() + endforeach() endforeach() - # Restore enviromnent + # Restore environment set(ENV{CFLAGS} "${C_FLAGS_BACKUP}") set(ENV{CXXFLAGS} "${CXX_FLAGS_BACKUP}") set(ENV{LDFLAGS} "${LD_FLAGS_BACKUP}")