From a3e2935e71ba2322bc7e715604eff41a70be450b Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 5 Aug 2020 15:26:15 +0200 Subject: [PATCH 1/5] [bzip2] fixes for building release-only --- ports/bzip2/CONTROL | 9 +- ports/bzip2/portfile.cmake | 104 +++++++++++----------- scripts/cmake/vcpkg_fixup_pkgconfig.cmake | 16 ++-- 3 files changed, 64 insertions(+), 65 deletions(-) diff --git a/ports/bzip2/CONTROL b/ports/bzip2/CONTROL index 4734c417155908..bdc70fcf4c9edb 100644 --- a/ports/bzip2/CONTROL +++ b/ports/bzip2/CONTROL @@ -1,4 +1,5 @@ -Source: bzip2 -Version: 1.0.6-6 -Homepage: http://www.bzip.org/ -Description: High-quality data compressor. +Source: bzip2 +Version: 1.0.6 +Port-Version: 7 +Homepage: http://www.bzip.org/ +Description: High-quality data compressor. diff --git a/ports/bzip2/portfile.cmake b/ports/bzip2/portfile.cmake index 571c84948f04cc..7244d0f4575b2b 100644 --- a/ports/bzip2/portfile.cmake +++ b/ports/bzip2/portfile.cmake @@ -1,51 +1,53 @@ -include(vcpkg_common_functions) -set(BZIP2_VERSION 1.0.6) # TODO: Update to 1.0.8 -vcpkg_download_distfile(ARCHIVE # TODO: switch to vcpkg_from_git with https://sourceware.org/git/?p=bzip2.git;a=summary - URLS "https://github.com/past-due/bzip2-mirror/releases/download/v${BZIP2_VERSION}/bzip2-${BZIP2_VERSION}.tar.gz" - FILENAME "bzip2-${BZIP2_VERSION}.tar.gz" - SHA512 00ace5438cfa0c577e5f578d8a808613187eff5217c35164ffe044fbafdfec9e98f4192c02a7d67e01e5a5ccced630583ad1003c37697219b0f147343a3fdd12) - -vcpkg_extract_source_archive_ex( - OUT_SOURCE_PATH SOURCE_PATH - ARCHIVE ${ARCHIVE} - REF ${BZIP2_VERSION} - PATCHES - fix-import-export-macros.patch - fix-windows-include.patch -) - -file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") - -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS_DEBUG - -DBZIP2_SKIP_HEADERS=ON - -DBZIP2_SKIP_TOOLS=ON -) - -vcpkg_install_cmake() -vcpkg_copy_pdbs() - -file(READ "${CURRENT_PACKAGES_DIR}/include/bzlib.h" BZLIB_H) -if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - string(REPLACE "defined(BZ_IMPORT)" "0" BZLIB_H "${BZLIB_H}") -else() - string(REPLACE "defined(BZ_IMPORT)" "1" BZLIB_H "${BZLIB_H}") -endif() -file(WRITE "${CURRENT_PACKAGES_DIR}/include/bzlib.h" "${BZLIB_H}") - -file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/bzip2") -file(RENAME "${CURRENT_PACKAGES_DIR}/share/bzip2/LICENSE" "${CURRENT_PACKAGES_DIR}/share/bzip2/copyright") - -file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") - -vcpkg_test_cmake(PACKAGE_NAME BZip2 MODULE) - -set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}") -set(bzname bz2) -configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/bzip2.pc" @ONLY) -set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}/debug") -set(bzname bz2d) -configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/bzip2.pc" @ONLY) -vcpkg_fixup_pkgconfig() \ No newline at end of file +include(vcpkg_common_functions) +set(BZIP2_VERSION 1.0.6) # TODO: Update to 1.0.8 +vcpkg_download_distfile(ARCHIVE # TODO: switch to vcpkg_from_git with https://sourceware.org/git/?p=bzip2.git;a=summary + URLS "https://github.com/past-due/bzip2-mirror/releases/download/v${BZIP2_VERSION}/bzip2-${BZIP2_VERSION}.tar.gz" + FILENAME "bzip2-${BZIP2_VERSION}.tar.gz" + SHA512 00ace5438cfa0c577e5f578d8a808613187eff5217c35164ffe044fbafdfec9e98f4192c02a7d67e01e5a5ccced630583ad1003c37697219b0f147343a3fdd12) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${BZIP2_VERSION} + PATCHES + fix-import-export-macros.patch + fix-windows-include.patch +) + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS_DEBUG + -DBZIP2_SKIP_HEADERS=ON + -DBZIP2_SKIP_TOOLS=ON +) + +vcpkg_install_cmake() +vcpkg_copy_pdbs() + +file(READ "${CURRENT_PACKAGES_DIR}/include/bzlib.h" BZLIB_H) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + string(REPLACE "defined(BZ_IMPORT)" "0" BZLIB_H "${BZLIB_H}") +else() + string(REPLACE "defined(BZ_IMPORT)" "1" BZLIB_H "${BZLIB_H}") +endif() +file(WRITE "${CURRENT_PACKAGES_DIR}/include/bzlib.h" "${BZLIB_H}") + +if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}") + set(bzname bz2) + configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/bzip2.pc" @ONLY) +endif() + +if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}/debug") + set(bzname bz2d) + configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/bzip2.pc" @ONLY) +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake index 24302a6af91962..73165306b328b6 100644 --- a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake +++ b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake @@ -30,7 +30,7 @@ ## If the *.pc file contains flags in the lib field which are not libraries. These can be listed here ## ## ### SKIP_CHECK -## Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases. +## Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases. ## ## ## Notes ## Still work in progress. If there are more cases which can be handled here feel free to add them @@ -51,7 +51,7 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib set(_VCPKG_INSTALLED_PKGCONF "${CURRENT_INSTALLED_DIR}") set(_VCPKG_PACKAGES_PKGCONF "${CURRENT_PACKAGES_DIR}") endif() - + set(PATH_SUFFIX_DEBUG /debug) set(PKGCONFIG_INSTALLED_DIR "${_VCPKG_INSTALLED_PKGCONF}${PATH_SUFFIX_${_config}}/lib/pkgconfig") set(PKGCONFIG_INSTALLED_SHARE_DIR "${_VCPKG_INSTALLED_PKGCONF}/share/pkgconfig") @@ -88,7 +88,7 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib debug_message("pkg-config error output:${_pkg_error_out}") endif() - # Get all required libs. --static means we get all libraries required for static linkage + # Get all required libs. --static means we get all libraries required for static linkage # which is the worst case and includes the case without --static # This retests already tested *.pc files since pkg-config will recursivly search for # required packages and add there link flags to the one being tested @@ -259,8 +259,7 @@ function(vcpkg_fixup_pkgconfig) else() set(PKGCONFIG_STATIC --static) endif() - - message(STATUS "Fixing pkgconfig") + if(_vfpkg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "vcpkg_fixup_pkgconfig was passed extra arguments: ${_vfct_UNPARSED_ARGUMENTS}") endif() @@ -288,11 +287,10 @@ function(vcpkg_fixup_pkgconfig) endif() endif() - #Absolute Unix like paths + #Absolute Unix like paths string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}") string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}") - message(STATUS "Fixing pkgconfig - release") debug_message("Files: ${_vfpkg_RELEASE_FILES}") foreach(_file ${_vfpkg_RELEASE_FILES}) message(STATUS "Checking file: ${_file}") @@ -317,7 +315,6 @@ function(vcpkg_fixup_pkgconfig) endforeach() endif() - message(STATUS "Fixing pkgconfig - debug") debug_message("Files: ${_vfpkg_DEBUG_FILES}") foreach(_file ${_vfpkg_DEBUG_FILES}) message(STATUS "Checking file: ${_file}") @@ -338,7 +335,7 @@ function(vcpkg_fixup_pkgconfig) string(REPLACE "debug/lib" "lib" _contents "${_contents}") # the prefix will contain the debug keyword string(REGEX REPLACE "^prefix=(\")?(\\\\)?\\\${prefix}(/debug)?(\")?" "prefix=\${pcfiledir}/${RELATIVE_PC_PATH}" _contents "${_contents}") # make pc file relocatable string(REGEX REPLACE "[\n]prefix=(\")?(\\\\)?\\\${prefix}(/debug)?(\")?" "\nprefix=\${pcfiledir}/${RELATIVE_PC_PATH}" _contents "${_contents}") # make pc file relocatable - string(REPLACE "\${prefix}/debug" "\${prefix}" _contents "${_contents}") # replace remaining debug paths if they exist. + string(REPLACE "\${prefix}/debug" "\${prefix}" _contents "${_contents}") # replace remaining debug paths if they exist. file(WRITE "${_file}" "${_contents}") unset(PKG_LIB_SEARCH_PATH) endforeach() @@ -348,7 +345,6 @@ function(vcpkg_fixup_pkgconfig) vcpkg_fixup_pkgconfig_check_files("${PKGCONFIG}" "${_file}" "DEBUG" "${_vfpkg_SYSTEM_LIBRARIES}" "${_vfpkg_IGNORE_FLAGS}") endforeach() endif() - message(STATUS "Fixing pkgconfig --- finished") set(VCPKG_FIXUP_PKGCONFIG_CALLED TRUE CACHE INTERNAL "See below" FORCE) # Variable to check if this function has been called! From 0ee492ce3571ed70bcc784b41cf1449e06b41722 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 5 Aug 2020 15:34:52 +0200 Subject: [PATCH 2/5] [vcpkg_fixup_pkgconfig] fix spacing in messages --- scripts/cmake/vcpkg_fixup_pkgconfig.cmake | 58 +++++++++++------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake index 73165306b328b6..c0e4b71da6db97 100644 --- a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake +++ b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake @@ -77,15 +77,15 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ERROR_STRIP_TRAILING_WHITESPACE ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --exists ${_package_name} failed") - message(STATUS "ENV{PKG_CONFIG_PATH}:$ENV{PKG_CONFIG_PATH}") - message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") - message(STATUS "pkg-config output:${_pkg_output}") - message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --exists ${_package_name} failed") + message(STATUS "ENV{PKG_CONFIG_PATH}: $ENV{PKG_CONFIG_PATH}") + message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") + message(STATUS "pkg-config output: ${_pkg_output}") + message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") else() - debug_message("pkg-config returned:${_pkg_error_var}") - debug_message("pkg-config output:${_pkg_output}") - debug_message("pkg-config error output:${_pkg_error_out}") + debug_message("pkg-config returned: ${_pkg_error_var}") + debug_message("pkg-config output: ${_pkg_output}") + debug_message("pkg-config error output: ${_pkg_error_out}") endif() # Get all required libs. --static means we get all libraries required for static linkage @@ -103,14 +103,14 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ERROR_STRIP_TRAILING_WHITESPACE ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --libs ${_package_name} failed") - message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") - message(STATUS "pkg-config output:${_pkg_libs_output}") - message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --libs ${_package_name} failed") + message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") + message(STATUS "pkg-config output: ${_pkg_libs_output}") + message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") else() - debug_message("pkg-config returned:${_pkg_error_var}") - debug_message("pkg-config output:${_pkg_libs_output}") - debug_message("pkg-config error output:${_pkg_error_out}") + debug_message("pkg-config returned: ${_pkg_error_var}") + debug_message("pkg-config output: ${_pkg_libs_output}") + debug_message("pkg-config error output: ${_pkg_error_out}") endif() execute_process(COMMAND "${pkg_cfg_cmd}" --print-errors --static --libs-only-L ${_package_name} @@ -123,14 +123,14 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --libs-only-L ${_package_name} failed") - message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") - message(STATUS "pkg-config output:${_pkg_lib_paths_output}") - message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --libs-only-L ${_package_name} failed") + message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") + message(STATUS "pkg-config output: ${_pkg_lib_paths_output}") + message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") else() - debug_message("pkg-config returned:${_pkg_error_var}") - debug_message("pkg-config output:${_pkg_lib_paths_output}") - debug_message("pkg-config error output:${_pkg_error_out}") + debug_message("pkg-config returned: ${_pkg_error_var}") + debug_message("pkg-config output: ${_pkg_lib_paths_output}") + debug_message("pkg-config error output: ${_pkg_error_out}") endif() string(REPLACE "\\ " "##" _pkg_lib_paths_output "${_pkg_lib_paths_output}") # Whitespace path protection @@ -160,8 +160,8 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib string(REGEX REPLACE "(^|;)/([a-zA-Z])/" "\\1\\2:/" _pkg_lib_paths_output "${_pkg_lib_paths_output}") string(REGEX REPLACE " /([a-zA-Z])/" ";\\1:/" _pkg_libs_output "${_pkg_libs_output}") string(REGEX REPLACE "-l/([a-zA-Z])/" "-l\\1:/" _pkg_libs_output "${_pkg_libs_output}") - debug_message("pkg-config output lib paths after replacement (cmake style):${_pkg_lib_paths_output}") - debug_message("pkg-config output lib after replacement (cmake style):${_pkg_libs_output}") + debug_message("pkg-config output lib paths after replacement (cmake style): ${_pkg_lib_paths_output}") + debug_message("pkg-config output lib after replacement (cmake style): ${_pkg_libs_output}") endif() if("${_config}" STREQUAL "DEBUG") @@ -198,15 +198,15 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib string(REGEX REPLACE ";?[\t ]*;[\t ]*" ";" _pkg_libs_output "${_pkg_libs_output}") # Double ;; and Whitespace before/after ; removal - debug_message("Library search paths:${_pkg_lib_paths_output}") - debug_message("Libraries to search:${_pkg_libs_output}") + debug_message("Library search paths: ${_pkg_lib_paths_output}") + debug_message("Libraries to search: ${_pkg_libs_output}") set(CMAKE_FIND_LIBRARY_SUFFIXES_BACKUP ${CMAKE_FIND_LIBRARY_SUFFIXES}) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll.a .a) foreach(_lib IN LISTS _pkg_libs_output) if(EXISTS "${_lib}" OR "x${_lib}x" STREQUAL "xx" ) # eat; all ok _lib is a fullpath to a library or empty continue() elseif (_lib MATCHES "^-l(.+)$") - debug_message("Library match: CMAKE_MATCH_1:${CMAKE_MATCH_1}") + debug_message("Library match: CMAKE_MATCH_1: ${CMAKE_MATCH_1}") set(_libname "${CMAKE_MATCH_1}") if(EXISTS "${_libname}") debug_message("${_libname} detected as an existing full path!") @@ -235,7 +235,7 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib endif() endforeach() # Reaching here means error! - message(STATUS "CHECK_LIB_${_libname}_${_config}:${CHECK_LIB_${_libname}_${_config}}") + message(STATUS "CHECK_LIB_${_libname}_${_config}: ${CHECK_LIB_${_libname}_${_config}}") message(FATAL_ERROR "Library \"${_libname}\" was not found! If it is a system library use the SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise, correct the *.pc file") else () message(FATAL_ERROR "Unhandled string \"${_lib}\" was found! If it is a system library use the SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise, correct the *.pc file or add the case to vcpkg_fixup_pkgconfig") @@ -293,7 +293,6 @@ function(vcpkg_fixup_pkgconfig) debug_message("Files: ${_vfpkg_RELEASE_FILES}") foreach(_file ${_vfpkg_RELEASE_FILES}) - message(STATUS "Checking file: ${_file}") get_filename_component(PKG_LIB_SEARCH_PATH "${_file}" DIRECTORY) file(RELATIVE_PATH RELATIVE_PC_PATH "${PKG_LIB_SEARCH_PATH}" "${CURRENT_PACKAGES_DIR}") string(REGEX REPLACE "/$" "" RELATIVE_PC_PATH "${RELATIVE_PC_PATH}") @@ -317,7 +316,6 @@ function(vcpkg_fixup_pkgconfig) debug_message("Files: ${_vfpkg_DEBUG_FILES}") foreach(_file ${_vfpkg_DEBUG_FILES}) - message(STATUS "Checking file: ${_file}") get_filename_component(PKG_LIB_SEARCH_PATH "${_file}" DIRECTORY) file(RELATIVE_PATH RELATIVE_PC_PATH "${PKG_LIB_SEARCH_PATH}" "${CURRENT_PACKAGES_DIR}/debug/") string(REGEX REPLACE "/$" "" RELATIVE_PC_PATH "${RELATIVE_PC_PATH}") From f3645d82ae45853a6a8c65cbfb7ebd55c01317e3 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 5 Aug 2020 18:39:53 +0200 Subject: [PATCH 3/5] Update ports/bzip2/portfile.cmake Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> --- ports/bzip2/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/bzip2/portfile.cmake b/ports/bzip2/portfile.cmake index 7244d0f4575b2b..88b4a4da2f9c6c 100644 --- a/ports/bzip2/portfile.cmake +++ b/ports/bzip2/portfile.cmake @@ -35,7 +35,7 @@ else() endif() file(WRITE "${CURRENT_PACKAGES_DIR}/include/bzlib.h" "${BZLIB_H}") -if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") +if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}") set(bzname bz2) configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/bzip2.pc" @ONLY) From 770e6cda150967e00fa00280ce75e8f920deb15d Mon Sep 17 00:00:00 2001 From: Lily <47812810+LilyWangL@users.noreply.github.com> Date: Thu, 6 Aug 2020 15:35:41 +0800 Subject: [PATCH 4/5] Update portfile.cmake --- ports/bzip2/portfile.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/bzip2/portfile.cmake b/ports/bzip2/portfile.cmake index 88b4a4da2f9c6c..d6b70bacb4381a 100644 --- a/ports/bzip2/portfile.cmake +++ b/ports/bzip2/portfile.cmake @@ -1,4 +1,3 @@ -include(vcpkg_common_functions) set(BZIP2_VERSION 1.0.6) # TODO: Update to 1.0.8 vcpkg_download_distfile(ARCHIVE # TODO: switch to vcpkg_from_git with https://sourceware.org/git/?p=bzip2.git;a=summary URLS "https://github.com/past-due/bzip2-mirror/releases/download/v${BZIP2_VERSION}/bzip2-${BZIP2_VERSION}.tar.gz" From 6f52c9ae4b9d7af30113eb05237214b766db1e4e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 12 Aug 2020 23:50:22 +0200 Subject: [PATCH 5/5] back out changes to vcpkg_fixup_pkgconfig --- scripts/cmake/vcpkg_fixup_pkgconfig.cmake | 74 ++++++++++++----------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake index c0e4b71da6db97..24302a6af91962 100644 --- a/scripts/cmake/vcpkg_fixup_pkgconfig.cmake +++ b/scripts/cmake/vcpkg_fixup_pkgconfig.cmake @@ -30,7 +30,7 @@ ## If the *.pc file contains flags in the lib field which are not libraries. These can be listed here ## ## ### SKIP_CHECK -## Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases. +## Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases. ## ## ## Notes ## Still work in progress. If there are more cases which can be handled here feel free to add them @@ -51,7 +51,7 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib set(_VCPKG_INSTALLED_PKGCONF "${CURRENT_INSTALLED_DIR}") set(_VCPKG_PACKAGES_PKGCONF "${CURRENT_PACKAGES_DIR}") endif() - + set(PATH_SUFFIX_DEBUG /debug) set(PKGCONFIG_INSTALLED_DIR "${_VCPKG_INSTALLED_PKGCONF}${PATH_SUFFIX_${_config}}/lib/pkgconfig") set(PKGCONFIG_INSTALLED_SHARE_DIR "${_VCPKG_INSTALLED_PKGCONF}/share/pkgconfig") @@ -77,18 +77,18 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ERROR_STRIP_TRAILING_WHITESPACE ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --exists ${_package_name} failed") - message(STATUS "ENV{PKG_CONFIG_PATH}: $ENV{PKG_CONFIG_PATH}") - message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") - message(STATUS "pkg-config output: ${_pkg_output}") - message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --exists ${_package_name} failed") + message(STATUS "ENV{PKG_CONFIG_PATH}:$ENV{PKG_CONFIG_PATH}") + message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") + message(STATUS "pkg-config output:${_pkg_output}") + message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") else() - debug_message("pkg-config returned: ${_pkg_error_var}") - debug_message("pkg-config output: ${_pkg_output}") - debug_message("pkg-config error output: ${_pkg_error_out}") + debug_message("pkg-config returned:${_pkg_error_var}") + debug_message("pkg-config output:${_pkg_output}") + debug_message("pkg-config error output:${_pkg_error_out}") endif() - # Get all required libs. --static means we get all libraries required for static linkage + # Get all required libs. --static means we get all libraries required for static linkage # which is the worst case and includes the case without --static # This retests already tested *.pc files since pkg-config will recursivly search for # required packages and add there link flags to the one being tested @@ -103,14 +103,14 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ERROR_STRIP_TRAILING_WHITESPACE ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --libs ${_package_name} failed") - message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") - message(STATUS "pkg-config output: ${_pkg_libs_output}") - message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --libs ${_package_name} failed") + message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") + message(STATUS "pkg-config output:${_pkg_libs_output}") + message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") else() - debug_message("pkg-config returned: ${_pkg_error_var}") - debug_message("pkg-config output: ${_pkg_libs_output}") - debug_message("pkg-config error output: ${_pkg_error_out}") + debug_message("pkg-config returned:${_pkg_error_var}") + debug_message("pkg-config output:${_pkg_libs_output}") + debug_message("pkg-config error output:${_pkg_error_out}") endif() execute_process(COMMAND "${pkg_cfg_cmd}" --print-errors --static --libs-only-L ${_package_name} @@ -123,14 +123,14 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib ) if(NOT _pkg_error_var EQUAL 0) - message(STATUS "pkg_cfg_cmd call with: ${pkg_cfg_cmd} --libs-only-L ${_package_name} failed") - message(STATUS "pkg-config call failed with error code: ${_pkg_error_var}") - message(STATUS "pkg-config output: ${_pkg_lib_paths_output}") - message(FATAL_ERROR "pkg-config error output: ${_pkg_error_out}") + message(STATUS "pkg_cfg_cmd call with:${pkg_cfg_cmd} --libs-only-L ${_package_name} failed") + message(STATUS "pkg-config call failed with error code:${_pkg_error_var}") + message(STATUS "pkg-config output:${_pkg_lib_paths_output}") + message(FATAL_ERROR "pkg-config error output:${_pkg_error_out}") else() - debug_message("pkg-config returned: ${_pkg_error_var}") - debug_message("pkg-config output: ${_pkg_lib_paths_output}") - debug_message("pkg-config error output: ${_pkg_error_out}") + debug_message("pkg-config returned:${_pkg_error_var}") + debug_message("pkg-config output:${_pkg_lib_paths_output}") + debug_message("pkg-config error output:${_pkg_error_out}") endif() string(REPLACE "\\ " "##" _pkg_lib_paths_output "${_pkg_lib_paths_output}") # Whitespace path protection @@ -160,8 +160,8 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib string(REGEX REPLACE "(^|;)/([a-zA-Z])/" "\\1\\2:/" _pkg_lib_paths_output "${_pkg_lib_paths_output}") string(REGEX REPLACE " /([a-zA-Z])/" ";\\1:/" _pkg_libs_output "${_pkg_libs_output}") string(REGEX REPLACE "-l/([a-zA-Z])/" "-l\\1:/" _pkg_libs_output "${_pkg_libs_output}") - debug_message("pkg-config output lib paths after replacement (cmake style): ${_pkg_lib_paths_output}") - debug_message("pkg-config output lib after replacement (cmake style): ${_pkg_libs_output}") + debug_message("pkg-config output lib paths after replacement (cmake style):${_pkg_lib_paths_output}") + debug_message("pkg-config output lib after replacement (cmake style):${_pkg_libs_output}") endif() if("${_config}" STREQUAL "DEBUG") @@ -198,15 +198,15 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib string(REGEX REPLACE ";?[\t ]*;[\t ]*" ";" _pkg_libs_output "${_pkg_libs_output}") # Double ;; and Whitespace before/after ; removal - debug_message("Library search paths: ${_pkg_lib_paths_output}") - debug_message("Libraries to search: ${_pkg_libs_output}") + debug_message("Library search paths:${_pkg_lib_paths_output}") + debug_message("Libraries to search:${_pkg_libs_output}") set(CMAKE_FIND_LIBRARY_SUFFIXES_BACKUP ${CMAKE_FIND_LIBRARY_SUFFIXES}) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll.a .a) foreach(_lib IN LISTS _pkg_libs_output) if(EXISTS "${_lib}" OR "x${_lib}x" STREQUAL "xx" ) # eat; all ok _lib is a fullpath to a library or empty continue() elseif (_lib MATCHES "^-l(.+)$") - debug_message("Library match: CMAKE_MATCH_1: ${CMAKE_MATCH_1}") + debug_message("Library match: CMAKE_MATCH_1:${CMAKE_MATCH_1}") set(_libname "${CMAKE_MATCH_1}") if(EXISTS "${_libname}") debug_message("${_libname} detected as an existing full path!") @@ -235,7 +235,7 @@ function(vcpkg_fixup_pkgconfig_check_files pkg_cfg_cmd _file _config _system_lib endif() endforeach() # Reaching here means error! - message(STATUS "CHECK_LIB_${_libname}_${_config}: ${CHECK_LIB_${_libname}_${_config}}") + message(STATUS "CHECK_LIB_${_libname}_${_config}:${CHECK_LIB_${_libname}_${_config}}") message(FATAL_ERROR "Library \"${_libname}\" was not found! If it is a system library use the SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise, correct the *.pc file") else () message(FATAL_ERROR "Unhandled string \"${_lib}\" was found! If it is a system library use the SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise, correct the *.pc file or add the case to vcpkg_fixup_pkgconfig") @@ -259,7 +259,8 @@ function(vcpkg_fixup_pkgconfig) else() set(PKGCONFIG_STATIC --static) endif() - + + message(STATUS "Fixing pkgconfig") if(_vfpkg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "vcpkg_fixup_pkgconfig was passed extra arguments: ${_vfct_UNPARSED_ARGUMENTS}") endif() @@ -287,12 +288,14 @@ function(vcpkg_fixup_pkgconfig) endif() endif() - #Absolute Unix like paths + #Absolute Unix like paths string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}") string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}") + message(STATUS "Fixing pkgconfig - release") debug_message("Files: ${_vfpkg_RELEASE_FILES}") foreach(_file ${_vfpkg_RELEASE_FILES}) + message(STATUS "Checking file: ${_file}") get_filename_component(PKG_LIB_SEARCH_PATH "${_file}" DIRECTORY) file(RELATIVE_PATH RELATIVE_PC_PATH "${PKG_LIB_SEARCH_PATH}" "${CURRENT_PACKAGES_DIR}") string(REGEX REPLACE "/$" "" RELATIVE_PC_PATH "${RELATIVE_PC_PATH}") @@ -314,8 +317,10 @@ function(vcpkg_fixup_pkgconfig) endforeach() endif() + message(STATUS "Fixing pkgconfig - debug") debug_message("Files: ${_vfpkg_DEBUG_FILES}") foreach(_file ${_vfpkg_DEBUG_FILES}) + message(STATUS "Checking file: ${_file}") get_filename_component(PKG_LIB_SEARCH_PATH "${_file}" DIRECTORY) file(RELATIVE_PATH RELATIVE_PC_PATH "${PKG_LIB_SEARCH_PATH}" "${CURRENT_PACKAGES_DIR}/debug/") string(REGEX REPLACE "/$" "" RELATIVE_PC_PATH "${RELATIVE_PC_PATH}") @@ -333,7 +338,7 @@ function(vcpkg_fixup_pkgconfig) string(REPLACE "debug/lib" "lib" _contents "${_contents}") # the prefix will contain the debug keyword string(REGEX REPLACE "^prefix=(\")?(\\\\)?\\\${prefix}(/debug)?(\")?" "prefix=\${pcfiledir}/${RELATIVE_PC_PATH}" _contents "${_contents}") # make pc file relocatable string(REGEX REPLACE "[\n]prefix=(\")?(\\\\)?\\\${prefix}(/debug)?(\")?" "\nprefix=\${pcfiledir}/${RELATIVE_PC_PATH}" _contents "${_contents}") # make pc file relocatable - string(REPLACE "\${prefix}/debug" "\${prefix}" _contents "${_contents}") # replace remaining debug paths if they exist. + string(REPLACE "\${prefix}/debug" "\${prefix}" _contents "${_contents}") # replace remaining debug paths if they exist. file(WRITE "${_file}" "${_contents}") unset(PKG_LIB_SEARCH_PATH) endforeach() @@ -343,6 +348,7 @@ function(vcpkg_fixup_pkgconfig) vcpkg_fixup_pkgconfig_check_files("${PKGCONFIG}" "${_file}" "DEBUG" "${_vfpkg_SYSTEM_LIBRARIES}" "${_vfpkg_IGNORE_FLAGS}") endforeach() endif() + message(STATUS "Fixing pkgconfig --- finished") set(VCPKG_FIXUP_PKGCONFIG_CALLED TRUE CACHE INTERNAL "See below" FORCE) # Variable to check if this function has been called!