From 73b9a2a35962e758d310b0684dfe21ec2b0bde12 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Tue, 14 Mar 2023 22:11:06 +0100 Subject: [PATCH] [openssl,vcpkg-cmake-get-vars] Fix android and emscripten, add feature `tools` (#29966) * [vcpkg-cmake-get-vars] Call 'project' early System variables like 'APPLE' or 'ANDROID' aren't set before 'project()'. * Get Android variables * [openssl] Ensure that compiler is reached via 'PATH' * Fix Android configuration * Add 'tools' feature * Update versions * [openssl] Initialize android with vcpkg settings * [openssl] Really don't build apps * [vcpkg-cmake-get-vars] Update android vars * [libpq] Pass openssl version from pkgconfig * [vcpkg-cmake-get-vars] Update android vars * [vcpkg-cmake-get-vars] Report generator * [vcpkg-cmake-get-vars] Escape all output * Transfer cmake-get-vars fixes * Transfer cmake-get-vars extra flags * no-asm for android-arm w/o neon * [vcpkg_configure_make] Unquote as needed Toolchain flags are passed into make via environment variables (e.g. CFLAGS) and expanded by Makefiles regardless of quotes. And even vcm's internal handling isn't prepared for these quotes. So we must remove the early. This doesn't interfere with properly escaped quotes. * Re-add lost 'project', amends 4cf7caaa * [openssl] Fix emscripten --- .../patches/windows/host_skip_openssl.patch | 38 ---------- .../patches/windows/openssl-version.patch | 14 ++++ .../patches/windows/openssl_exe_path.patch | 13 ---- ports/libpq/portfile.cmake | 10 ++- ports/libpq/vcpkg.json | 1 + ports/openssl/disable-apps.patch | 12 +++ ports/openssl/portfile.cmake | 6 ++ ports/openssl/unix/Makefile.emscripten | 4 + ports/openssl/unix/android-cc.patch | 20 +++++ ports/openssl/unix/configure | 2 +- ports/openssl/unix/portfile.cmake | 55 +++++++++----- ports/openssl/vcpkg.json | 13 +++- ports/openssl/windows/portfile.cmake | 17 ++++- .../cmake_get_vars/CMakeLists.txt | 76 +++++++++++++------ ports/vcpkg-cmake-get-vars/vcpkg.json | 2 +- scripts/cmake/vcpkg_configure_make.cmake | 17 +++++ scripts/get_cmake_vars/CMakeLists.txt | 76 +++++++++++++------ versions/baseline.json | 6 +- versions/l-/libpq.json | 5 ++ versions/o-/openssl.json | 5 ++ versions/v-/vcpkg-cmake-get-vars.json | 5 ++ 21 files changed, 265 insertions(+), 132 deletions(-) delete mode 100644 ports/libpq/patches/windows/host_skip_openssl.patch create mode 100644 ports/libpq/patches/windows/openssl-version.patch delete mode 100644 ports/libpq/patches/windows/openssl_exe_path.patch create mode 100644 ports/openssl/disable-apps.patch create mode 100644 ports/openssl/unix/Makefile.emscripten create mode 100644 ports/openssl/unix/android-cc.patch diff --git a/ports/libpq/patches/windows/host_skip_openssl.patch b/ports/libpq/patches/windows/host_skip_openssl.patch deleted file mode 100644 index e18e178843..0000000000 --- a/ports/libpq/patches/windows/host_skip_openssl.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm -index 25a549015..9018270ab 100644 ---- a/src/tools/msvc/Solution.pm -+++ b/src/tools/msvc/Solution.pm -@@ -132,21 +132,21 @@ sub GetOpenSSLVersion - # Attempt to get OpenSSL version and location. This assumes that - # openssl.exe is in the specified directory. - # Quote the .exe name in case it has spaces -- my $opensslcmd = -- qq("openssl.exe" version 2>&1); -- my $sslout = `$opensslcmd`; -+ #my $opensslcmd = -+ # qq("openssl.exe" version 2>&1); -+ #my $sslout = `$opensslcmd`; - -- $? >> 8 == 0 -- or croak -- "Unable to determine OpenSSL version: The openssl.exe command wasn't found."; -+ #$? >> 8 == 0 -+ # or croak -+ # "Unable to determine OpenSSL version: The openssl.exe command wasn't found."; - -- if ($sslout =~ /(\d+)\.(\d+)\.(\d+)(\D)/m) -- { -- return ($1, $2, $3); -- } -+ #if ($sslout =~ /(\d+)\.(\d+)\.(\d+)(\D)/m) -+ #{ -+ return (1, 1, 1); -+ #} - -- croak -- "Unable to determine OpenSSL version: The openssl.exe version could not be determined."; -+ #croak -+ # "Unable to determine OpenSSL version: The openssl.exe version could not be determined."; - } - - sub GenerateFiles diff --git a/ports/libpq/patches/windows/openssl-version.patch b/ports/libpq/patches/windows/openssl-version.patch new file mode 100644 index 0000000000..77f464041c --- /dev/null +++ b/ports/libpq/patches/windows/openssl-version.patch @@ -0,0 +1,14 @@ +diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm +index 72c5b98..0d153c0 100644 +--- a/src/tools/msvc/Solution.pm ++++ b/src/tools/msvc/Solution.pm +@@ -128,6 +128,9 @@ sub copyFile + sub GetOpenSSLVersion + { + my $self = shift; ++ if (($ENV{'VCPKG_OPENSSL_VERSION'} // '') =~ /(\d+)\.(\d+)\.(\d+)/m) { ++ return ($1, $2, $3); ++ } + + # Attempt to get OpenSSL version and location. This assumes that + # openssl.exe is in the specified directory. diff --git a/ports/libpq/patches/windows/openssl_exe_path.patch b/ports/libpq/patches/windows/openssl_exe_path.patch deleted file mode 100644 index 813ea58b1b..0000000000 --- a/ports/libpq/patches/windows/openssl_exe_path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm -index 51711c2bf..d33fdc3b0 100644 ---- a/src/tools/msvc/Solution.pm -+++ b/src/tools/msvc/Solution.pm -@@ -129,7 +129,7 @@ sub GetOpenSSLVersion - # openssl.exe is in the specified directory. - # Quote the .exe name in case it has spaces - my $opensslcmd = -- qq("$self->{options}->{openssl}\\bin\\openssl.exe" version 2>&1); -+ qq("openssl.exe" version 2>&1); - my $sslout = `$opensslcmd`; - - $? >> 8 == 0 diff --git a/ports/libpq/portfile.cmake b/ports/libpq/portfile.cmake index c47f70159d..dbff64f8bf 100644 --- a/ports/libpq/portfile.cmake +++ b/ports/libpq/portfile.cmake @@ -11,7 +11,7 @@ vcpkg_download_distfile(ARCHIVE set(PATCHES patches/windows/install.patch patches/windows/win_bison_flex.patch - patches/windows/openssl_exe_path.patch + patches/windows/openssl-version.patch patches/windows/Solution.patch patches/windows/MSBuildProject_fix_gendef_perl.patch patches/windows/msgfmt.patch @@ -31,7 +31,6 @@ if(VCPKG_CRT_LINKAGE STREQUAL "static") endif() if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") list(APPEND PATCHES patches/windows/arm.patch) - list(APPEND PATCHES patches/windows/host_skip_openssl.patch) # Skip openssl.exe version check since it cannot be executed by the host endif() if(NOT "${FEATURES}" MATCHES "client") list(APPEND PATCHES patches/windows/minimize_install.patch) @@ -88,6 +87,11 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) vcpkg_cmake_get_vars(vars_file) include("${vars_file}") + file(STRINGS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/openssl.pc" OPENSSL_VERSION REGEX "Version:") + if(OPENSSL_VERSION) + set(ENV{VCPKG_OPENSSL_VERSION} "${OPENSSL_VERSION}") + endif() + file(GLOB SOURCE_FILES ${SOURCE_PATH}/*) foreach(_buildtype ${port_config_list}) # Copy libpq sources. @@ -140,8 +144,6 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") endif() if("${FEATURES}" MATCHES "openssl") - set(buildenv_contents "${buildenv_contents}\n\$ENV{'PATH'}=\$ENV{'PATH'} . ';${CURRENT_INSTALLED_DIR}/tools/openssl';") - #set(_contents "${_contents}\n\$ENV{PATH}=\$ENV{PATH} . ';${CURRENT_INSTALLED_DIR}/tools/openssl';") string(REPLACE "openssl => undef" "openssl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") endif() if("${FEATURES}" MATCHES "python") diff --git a/ports/libpq/vcpkg.json b/ports/libpq/vcpkg.json index 395bbfbb6c..be8c59ad64 100644 --- a/ports/libpq/vcpkg.json +++ b/ports/libpq/vcpkg.json @@ -1,6 +1,7 @@ { "name": "libpq", "version": "15.2", + "port-version": 1, "description": "The official database access API of postgresql", "homepage": "https://www.postgresql.org/", "license": "PostgreSQL", diff --git a/ports/openssl/disable-apps.patch b/ports/openssl/disable-apps.patch new file mode 100644 index 0000000000..8dac3d6835 --- /dev/null +++ b/ports/openssl/disable-apps.patch @@ -0,0 +1,12 @@ +diff --git a/Configure b/Configure +index 5ac4b52..ad638e8 100755 +--- a/Configure ++++ b/Configure +@@ -401,6 +401,7 @@ my @dtls = qw(dtls1 dtls1_2); + my @disablables = ( + "acvp-tests", + "afalgeng", ++ "apps", + "aria", + "asan", + "asm", diff --git a/ports/openssl/portfile.cmake b/ports/openssl/portfile.cmake index ea61abf1b9..eec8cf3086 100644 --- a/ports/openssl/portfile.cmake +++ b/ports/openssl/portfile.cmake @@ -21,11 +21,13 @@ vcpkg_from_github( REF "openssl-${VERSION}" SHA512 5a821aaaaa89027ce08a347e5fc216757c2971e29f7d24792609378c54f657839b3775bf639e7330b28b4f96ef0d32869f0a96afcb25c8a2e1c2fe51a6eb4aa3 PATCHES + disable-apps.patch disable-install-docs.patch script-prefix.patch windows/install-layout.patch windows/install-pdbs.patch windows/umul128-arm64.patch # Fixed upstream in https://github.com/openssl/openssl/pull/20244, but not released as of 3.0.8 + unix/android-cc.patch unix/move-openssldir.patch unix/no-empty-dirs.patch unix/no-static-libs-for-shared.patch @@ -45,6 +47,10 @@ else() vcpkg_list(APPEND CONFIGURE_OPTIONS no-shared no-module) endif() +if(NOT "tools" IN_LIST FEATURES) + vcpkg_list(APPEND CONFIGURE_OPTIONS no-apps) +endif() + if(DEFINED OPENSSL_USE_NOPINSHARED) vcpkg_list(APPEND CONFIGURE_OPTIONS no-pinshared) endif() diff --git a/ports/openssl/unix/Makefile.emscripten b/ports/openssl/unix/Makefile.emscripten new file mode 100644 index 0000000000..126430b5a6 --- /dev/null +++ b/ports/openssl/unix/Makefile.emscripten @@ -0,0 +1,4 @@ +build_sw: + $(EMSDK)/upstream/emscripten/emmake $(MAKE) -f Makefile build_sw ${VCPKG_JOBS} $(MAKEFLAGS) +install: + $(EMSDK)/upstream/emscripten/emmake $(MAKE) -f Makefile install ${VCPKG_JOBS} $(MAKEFLAGS) diff --git a/ports/openssl/unix/android-cc.patch b/ports/openssl/unix/android-cc.patch new file mode 100644 index 0000000000..f4c3d68343 --- /dev/null +++ b/ports/openssl/unix/android-cc.patch @@ -0,0 +1,20 @@ +diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf +index 41ad922..d15e34c 100644 +--- a/Configurations/15-android.conf ++++ b/Configurations/15-android.conf +@@ -102,6 +102,7 @@ + my $cflags; + my $cppflags; + ++if (0) { + # see if there is NDK clang on $PATH, "universal" or "standalone" + if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) { + my $host=$1; +@@ -158,6 +159,7 @@ + $sysroot =~ s|^$ndk/||; + $sysroot = " --sysroot=\$($ndk_var)/$sysroot"; + } ++} + $android_ndk = { + cflags => $cflags . $sysroot, + cppflags => $cppflags, diff --git a/ports/openssl/unix/configure b/ports/openssl/unix/configure index c49aa7a935..5599aaa0f6 100755 --- a/ports/openssl/unix/configure +++ b/ports/openssl/unix/configure @@ -15,7 +15,7 @@ for OPTION; do INTERPRETER="${LAST_SEEN}" COPY_OPTIONS=yes ;; - --prefix=*|--openssldir=*|--libdir=*|--debug,*) + --prefix=*|--openssldir=*|--libdir=*|--cross-compile-prefix=*|--debug,*) OUT_OPTIONS+=("${OPTION}") ;; -*|*=*) diff --git a/ports/openssl/unix/portfile.cmake b/ports/openssl/unix/portfile.cmake index 414da82d8f..2016b68f7b 100644 --- a/ports/openssl/unix/portfile.cmake +++ b/ports/openssl/unix/portfile.cmake @@ -27,17 +27,26 @@ if(NOT perl_ipc_cmd_result STREQUAL "0") message(FATAL_ERROR "\nPerl cannot find IPC::Cmd. Please install it through your system package manager.\n") endif() +# Ideally, OpenSSL should use `CC` from vcpkg as is (absolute path). +# But in reality, OpenSSL expects to locate the compiler via `PATH`, +# and it makes its own choices e.g. for Android. +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") +cmake_path(GET VCPKG_DETECTED_CMAKE_C_COMPILER PARENT_PATH compiler_path) +cmake_path(GET VCPKG_DETECTED_CMAKE_C_COMPILER FILENAME compiler_name) +find_program(compiler_in_path NAMES "${compiler_name}" PATHS ENV PATH NO_DEFAULT_PATH) +if(NOT compiler_in_path) + vcpkg_host_path_list(APPEND ENV{PATH} "${compiler_path}") +elseif(NOT compiler_in_path STREQUAL VCPKG_DETECTED_CMAKE_C_COMPILER) + vcpkg_host_path_list(PREPEND ENV{PATH} "${compiler_path}") +endif() + +vcpkg_list(SET MAKEFILE_OPTIONS) if(VCPKG_TARGET_IS_ANDROID) - if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") - set(OPENSSL_ARCH android-arm64) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") - set(OPENSSL_ARCH android-arm) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - set(OPENSSL_ARCH android-x86_64) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86") - set(OPENSSL_ARCH android-x86) - else() - message(FATAL_ERROR "Unknown iOS target architecture: ${VCPKG_TARGET_ARCHITECTURE}") + set(ENV{ANDROID_NDK_ROOT} "${VCPKG_DETECTED_CMAKE_ANDROID_NDK}") + set(OPENSSL_ARCH "android-${VCPKG_DETECTED_CMAKE_ANDROID_ARCH}") + if(VCPKG_DETECTED_CMAKE_ANDROID_ARCH STREQUAL "arm" AND NOT VCPKG_DETECTED_CMAKE_ANDROID_ARM_NEON) + vcpkg_list(APPEND CONFIGURE_OPTIONS no-asm) endif() elseif(VCPKG_TARGET_IS_LINUX) if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") @@ -79,8 +88,12 @@ elseif(VCPKG_TARGET_IS_MINGW) endif() elseif(VCPKG_TARGET_IS_EMSCRIPTEN) set(INTERPRETER "$ENV{EMSDK}/upstream/emscripten/emconfigure") - set(MAKE "$ENV{EMSDK}/upstream/emscripten/emmake") - set(ENV{MAKE} "${MAKE}") + # We must wrap the build in emmake which does not pass jobserver fds. + vcpkg_list(SET MAKEFILE_OPTIONS + MAKEFILE "${CMAKE_CURRENT_LIST_DIR}/Makefile.emscripten" + DISABLE_PARALLEL + ) + set(ENV{VCPKG_JOBS} "-j${VCPKG_CONCURRENCY}") vcpkg_list(APPEND CONFIGURE_OPTIONS threads no-engine @@ -109,13 +122,21 @@ vcpkg_configure_make( OPTIONS_DEBUG --debug ) -vcpkg_install_make(BUILD_TARGET build_sw) +vcpkg_install_make( + ${MAKEFILE_OPTIONS} + BUILD_TARGET build_sw +) vcpkg_fixup_pkgconfig() -file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") -file(RENAME "${CURRENT_PACKAGES_DIR}/bin/c_rehash" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/c_rehash") -file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/c_rehash") -vcpkg_copy_tools(TOOL_NAMES openssl AUTO_CLEAN) +if("tools" IN_LIST FEATURES) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + file(RENAME "${CURRENT_PACKAGES_DIR}/bin/c_rehash" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/c_rehash") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/c_rehash") + vcpkg_copy_tools(TOOL_NAMES openssl AUTO_CLEAN) +elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/etc/ssl/misc") +endif() file(TOUCH "${CURRENT_PACKAGES_DIR}/etc/ssl/certs/.keep") file(TOUCH "${CURRENT_PACKAGES_DIR}/etc/ssl/private/.keep") diff --git a/ports/openssl/vcpkg.json b/ports/openssl/vcpkg.json index 790c240aea..b564ba3a91 100644 --- a/ports/openssl/vcpkg.json +++ b/ports/openssl/vcpkg.json @@ -1,7 +1,7 @@ { "name": "openssl", "version": "3.0.8", - "port-version": 1, + "port-version": 2, "description": "OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.", "homepage": "https://www.openssl.org", "license": "Apache-2.0", @@ -16,8 +16,13 @@ }, { "name": "vcpkg-cmake-get-vars", - "host": true, - "platform": "windows & !mingw" + "host": true } - ] + ], + "features": { + "tools": { + "description": "Install openssl executable and scripts", + "supports": "!uwp" + } + } } diff --git a/ports/openssl/windows/portfile.cmake b/ports/openssl/windows/portfile.cmake index 3b7d6202ae..a5a5da413d 100644 --- a/ports/openssl/windows/portfile.cmake +++ b/ports/openssl/windows/portfile.cmake @@ -85,14 +85,23 @@ vcpkg_build_nmake( install_runtime install_ssldirs # extra targets ) -file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") -file(RENAME "${CURRENT_PACKAGES_DIR}/openssl.cnf" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/openssl.cnf") -if(NOT VCPKG_TARGET_IS_UWP) - foreach(script IN ITEMS "bin/c_rehash.pl" "misc/CA.pl" "misc/tsget.pl") +set(scripts "bin/c_rehash.pl" "misc/CA.pl" "misc/tsget.pl") +if("tools" IN_LIST FEATURES) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + file(RENAME "${CURRENT_PACKAGES_DIR}/openssl.cnf" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/openssl.cnf") + foreach(script IN LISTS scripts) file(COPY "${CURRENT_PACKAGES_DIR}/${script}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") file(REMOVE "${CURRENT_PACKAGES_DIR}/${script}" "${CURRENT_PACKAGES_DIR}/debug/${script}") endforeach() vcpkg_copy_tools(TOOL_NAMES openssl AUTO_CLEAN) +else() + file(REMOVE "${CURRENT_PACKAGES_DIR}/openssl.cnf") + foreach(script IN LISTS scripts) + file(REMOVE "${CURRENT_PACKAGES_DIR}/${script}" "${CURRENT_PACKAGES_DIR}/debug/${script}") + endforeach() + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") + endif() endif() vcpkg_copy_pdbs() diff --git a/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt b/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt index 7e4c45a34d..fa010eb0bc 100644 --- a/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt +++ b/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt @@ -1,17 +1,62 @@ cmake_minimum_required(VERSION 3.20) +if(NOT VCPKG_OUTPUT_FILE) + message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") +endif() + +if(NOT CMAKE_BUILD_TYPE) + message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") +else() + string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) +endif() + set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project") -set(OUTPUT_STRING) +project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) + + +set(OUTPUT_STRING "# Generator: ${CMAKE_CURRENT_LIST_FILE}\n") + +function(escaped out_var value) + string(REPLACE "\\" "\\\\" value "${value}") + string(REPLACE "\"" "\\\"" value "${value}") + string(REPLACE "\$" "\\\$" value "${value}") + set(${out_var} "${value}" PARENT_SCOPE) +endfunction() + # Build default checklists list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING CMAKE_SYSTEM_NAME + CMAKE_SYSTEM_VERSION CMAKE_HOST_SYSTEM_NAME CMAKE_SYSTEM_PROCESSOR CMAKE_HOST_SYSTEM_PROCESSOR CMAKE_SIZEOF_VOID_P MSVC MSVC_VERSION) +if(ANDROID) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK + CMAKE_ANDROID_ARCH + CMAKE_ANDROID_ARCH_ABI + CMAKE_ANDROID_ARM_MODE + CMAKE_ANDROID_ARM_NEON + CMAKE_ANDROID_NDK + CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG + CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION + CMAKE_ANDROID_NDK_VERSION + CMAKE_ANDROID_STL_TYPE + ) + # Forward legacy variables from older NDKs + if("${CMAKE_ANDROID_ARCH}" STREQUAL "") + set(CMAKE_ANDROID_ARCH "${ANDROID_ARCH_NAME}") + endif() + if("${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}" STREQUAL "") + set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "${ANDROID_HOST_TAG}") + endif() + if(CMAKE_SYSTEM_VERSION STREQUAL "1" AND ANDROID_PLATFORM_LEVEL GREATER "1") + set(CMAKE_SYSTEM_VERSION "${ANDROID_PLATFORM_LEVEL}") + endif() +endif() if(APPLE) list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT) @@ -67,30 +112,19 @@ set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables set(VCPKG_FLAGS_TO_CHECK "${VCPKG_DEFAULT_FLAGS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") set(VCPKG_ENV_VARS_TO_CHECK "${VCPKG_DEFAULT_ENV_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") -if(NOT VCPKG_OUTPUT_FILE) - message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") -endif() - -if(NOT CMAKE_BUILD_TYPE) - message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") -else() - string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) -endif() - - -project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) - foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK VCPKG_FLAGS_TO_CHECK) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\")\n") + escaped(value "${${VAR}}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${value}\")\n") endforeach() foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) if(CMAKE_HOST_WIN32) - string(REPLACE "\\" "/" ENV_${_env} "$ENV{${_env}}") - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${ENV_${_env}}\")\n") + string(REPLACE "\\" "/" value "$ENV{${_env}}") + escaped(value "${value}") else() - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"$ENV{${_env}}\")\n") + escaped(value "$ENV{${_env}}") endif() + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${value}\")\n") endforeach() set(EXTRA_FLAGS "") @@ -160,10 +194,8 @@ foreach(flag ${VCPKG_LANGUAGES} SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LI endif() endif() endif() - string(REPLACE "\\" "\\\\" ${flag}_FLAGS "${${flag}_FLAGS}") - string(REPLACE "\"" "\\\"" ${flag}_FLAGS "${${flag}_FLAGS}") - string(REPLACE "\$" "\\\$" ${flag}_FLAGS "${${flag}_FLAGS}") - string(APPEND OUTPUT_STRING "set(VCPKG_COMBINED_${flag}_FLAGS_${VCPKG_CONFIGS} \"${${flag}_FLAGS}\")\n") + escaped(value "${${flag}_FLAGS}") + string(APPEND OUTPUT_STRING "set(VCPKG_COMBINED_${flag}_FLAGS_${VCPKG_CONFIGS} \"${value}\")\n") endforeach() file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") diff --git a/ports/vcpkg-cmake-get-vars/vcpkg.json b/ports/vcpkg-cmake-get-vars/vcpkg.json index 61b2fc7ba0..4ac1e7b4b4 100644 --- a/ports/vcpkg-cmake-get-vars/vcpkg.json +++ b/ports/vcpkg-cmake-get-vars/vcpkg.json @@ -1,6 +1,6 @@ { "name": "vcpkg-cmake-get-vars", - "version-date": "2022-12-16", + "version-date": "2023-03-02", "documentation": "https://vcpkg.io/en/docs/README.html", "license": "MIT", "dependencies": [ diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 4ebecbf5c8..751e1ead8f 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -136,6 +136,23 @@ function(vcpkg_configure_make) debug_message("Including cmake vars from: ${cmake_vars_file}") include("${cmake_vars_file}") + # Remove outer quotes from cmake variables which will be forwarded via makefile/shell variables + # substituted into makefile commands (e.g. Android NDK has "--sysroot=...") + foreach(var IN ITEMS VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG + VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE + VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG + VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE + VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG + VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE + VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_DEBUG + VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_RELEASE + VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES + VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES + ) + separate_arguments(cmake_list NATIVE_COMMAND "${${var}}") + list(JOIN cmake_list " " "${var}") + endforeach() + if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(arg_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index 1f97de305d..d2135a1658 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -1,8 +1,29 @@ cmake_minimum_required(VERSION 3.20) +if(NOT VCPKG_OUTPUT_FILE) + message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") +endif() + +if(NOT CMAKE_BUILD_TYPE) + message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") +else() + string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) +endif() + set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project") -set(OUTPUT_STRING) +project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) + + +set(OUTPUT_STRING "# Generator: ${CMAKE_CURRENT_LIST_FILE}\n") + +function(escaped out_var value) + string(REPLACE "\\" "\\\\" value "${value}") + string(REPLACE "\"" "\\\"" value "${value}") + string(REPLACE "\$" "\\\$" value "${value}") + set(${out_var} "${value}" PARENT_SCOPE) +endfunction() + # Build default checklists list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING CMAKE_SYSTEM_NAME @@ -64,34 +85,35 @@ set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables set(VCPKG_FLAGS_TO_CHECK "${VCPKG_DEFAULT_FLAGS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") set(VCPKG_ENV_VARS_TO_CHECK "${VCPKG_DEFAULT_ENV_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") -if(NOT VCPKG_OUTPUT_FILE) - message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") -endif() - -if(NOT CMAKE_BUILD_TYPE) - message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") -else() - string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) -endif() - - -project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) - foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\")\n") + escaped(value "${${VAR}}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${value}\")\n") endforeach() foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) if(CMAKE_HOST_WIN32) - string(REPLACE "\\" "/" ENV_${_env} "$ENV{${_env}}") - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${ENV_${_env}}\")\n") + string(REPLACE "\\" "/" value "$ENV{${_env}}") + escaped(value "${value}") else() - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"$ENV{${_env}}\")\n") + escaped(value "$ENV{${_env}}") endif() + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${value}\")\n") endforeach() +set(extra_flags "") +if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + string(APPEND extra_flags " \"${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}\"") + else() + string(APPEND extra_flags " ${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN} \"${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}\"") + endif() +endif() +if(CMAKE_SYSROOT AND CMAKE_CXX_COMPILE_OPTIONS_SYSROOT) + string(APPEND extra_flags " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"") +endif() + macro(_vcpkg_adjust_flags flag_var) - if(MSVC) # Transform MSVC /flags to -flags due to bash scripts intepreting /flag as a path. + if(MSVC) # Transform MSVC /flags to -flags due to msys2 runtime intepreting /flag as a path. string(REGEX REPLACE "(^| )/" "\\1-" ${flag_var} "${${flag_var}}") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") if("${flag_var}" STREQUAL "CMAKE_CXX_FLAGS") @@ -126,6 +148,9 @@ macro(_vcpkg_adjust_flags flag_var) string(PREPEND ${flag_var} "${CMAKE_${lang}_COMPILE_OPTIONS_TARGET} ${CMAKE_${lang}_COMPILER_TARGET} ") endif() endif() + if("${flag_var}" IN_LIST flags_to_add_target) + string(APPEND ${flag_var} " ${extra_flags}") + endif() unset(lang) unset(flags_to_add_target) endmacro() @@ -133,15 +158,16 @@ endmacro() foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK) string(STRIP "${${flag}}" ${flag}) # Strip leading and trailing whitespaces _vcpkg_adjust_flags(${flag}) - string(REPLACE [[\\]] [[\]] ${flag} "${${flag}}") - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n") + escaped(value "${${flag}}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${value}\")\n") foreach(config IN LISTS VCPKG_CONFIGS) + escaped(raw_value "${CMAKE_${flag}_FLAGS_${config}}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${raw_value}\")\n") string(STRIP "${${flag}_${config}}" ${flag}_${config}) _vcpkg_adjust_flags(${flag}_${config}) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") - set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}") - string(STRIP "${COMBINED_${flag}_${config}}" COMBINED_${flag}_${config}) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}_${config} \"${COMBINED_${flag}_${config}}\")\n") + escaped(combined_value "${${flag}} ${${flag}_${config}}") + string(STRIP "${combined_value}" combined_value) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}_${config} \"${combined_value}\")\n") endforeach() endforeach() diff --git a/versions/baseline.json b/versions/baseline.json index 8109fc6f6b..879d36e66b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4302,7 +4302,7 @@ }, "libpq": { "baseline": "15.2", - "port-version": 0 + "port-version": 1 }, "libpqxx": { "baseline": "7.7.4", @@ -5802,7 +5802,7 @@ }, "openssl": { "baseline": "3.0.8", - "port-version": 1 + "port-version": 2 }, "openssl-unix": { "baseline": "deprecated", @@ -8133,7 +8133,7 @@ "port-version": 1 }, "vcpkg-cmake-get-vars": { - "baseline": "2022-12-16", + "baseline": "2023-03-02", "port-version": 0 }, "vcpkg-get-python-packages": { diff --git a/versions/l-/libpq.json b/versions/l-/libpq.json index a93f8ca94f..b9c23f1192 100644 --- a/versions/l-/libpq.json +++ b/versions/l-/libpq.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "215b5533383016a897deb00d90b9ca5ebefc0469", + "version": "15.2", + "port-version": 1 + }, { "git-tree": "afe52a0d413f6e4dce23ba247692413dd9ff1cce", "version": "15.2", diff --git a/versions/o-/openssl.json b/versions/o-/openssl.json index 4d0005e41a..fc2a54df90 100644 --- a/versions/o-/openssl.json +++ b/versions/o-/openssl.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "3fbd85566107cc3a76ed800844569f1a7503f9d6", + "version": "3.0.8", + "port-version": 2 + }, { "git-tree": "17ce011827417025d6a29924ace0a474f1689c65", "version": "3.0.8", diff --git a/versions/v-/vcpkg-cmake-get-vars.json b/versions/v-/vcpkg-cmake-get-vars.json index 47e032be3c..4bfa475bc1 100644 --- a/versions/v-/vcpkg-cmake-get-vars.json +++ b/versions/v-/vcpkg-cmake-get-vars.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "2e624c2cf12a97a7a802e31ff1d28b9fa6ba9bde", + "version-date": "2023-03-02", + "port-version": 0 + }, { "git-tree": "bad453fe7f58edb2e8d0093692dcaa52347e446c", "version-date": "2022-12-16",