From 81129e3ec97723028e2684efea8dda575ae4f56c Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 17 Jun 2023 19:33:35 +0200 Subject: [PATCH] Update Qt on Windows., update OpenSSL --- .gitignore | 1 + cmake/ports/openssl/disable-apps.patch | 12 - .../ports/openssl/disable-install-docs.patch | 26 -- cmake/ports/openssl/install-pc-files.cmake | 2 +- cmake/ports/openssl/openssl.pc.in | 2 +- cmake/ports/openssl/portfile.cmake | 74 ++--- cmake/ports/openssl/script-prefix.patch | 22 -- cmake/ports/openssl/unix/CMakeLists.txt | 285 ++++++++++++++++ cmake/ports/openssl/unix/android-cc.patch | 20 -- cmake/ports/openssl/unix/configure | 31 -- .../ports/openssl/unix/move-openssldir.patch | 15 - cmake/ports/openssl/unix/no-empty-dirs.patch | 22 -- .../unix/no-static-libs-for-shared.patch | 12 - cmake/ports/openssl/unix/portfile.cmake | 153 +-------- cmake/ports/openssl/uwp/make-openssl.bat | 16 + cmake/ports/openssl/uwp/portfile.cmake | 155 +++++++++ .../openssl/vcpkg-cmake-wrapper.cmake.in | 6 +- cmake/ports/openssl/vcpkg.json | 17 +- cmake/ports/openssl/windows/flags.patch | 35 ++ .../openssl/windows/install-layout.patch | 13 - .../ports/openssl/windows/install-pdbs.patch | 44 --- cmake/ports/openssl/windows/portfile.cmake | 272 +++++++++------ cmake/ports/vcpkg-cmake-config/copyright | 23 ++ cmake/ports/vcpkg-cmake-config/portfile.cmake | 12 + .../vcpkg-port-config.cmake | 1 + cmake/ports/vcpkg-cmake-config/vcpkg.json | 7 + .../vcpkg_cmake_config_fixup.cmake | 258 +++++++++++++++ .../cmake_get_vars/CMakeLists.txt | 204 ++++++++++++ .../ports/vcpkg-cmake-get-vars/portfile.cmake | 14 + .../vcpkg-port-config.cmake | 2 + cmake/ports/vcpkg-cmake-get-vars/vcpkg.json | 13 + .../vcpkg_cmake_get_vars.cmake | 34 ++ cmake/ports/vcpkg-cmake/portfile.cmake | 14 + .../ports/vcpkg-cmake/vcpkg-port-config.cmake | 3 + cmake/ports/vcpkg-cmake/vcpkg.json | 6 + .../ports/vcpkg-cmake/vcpkg_cmake_build.cmake | 91 +++++ .../vcpkg-cmake/vcpkg_cmake_configure.cmake | 311 ++++++++++++++++++ .../vcpkg-cmake/vcpkg_cmake_install.cmake | 21 ++ hifi_qt.py | 2 +- 39 files changed, 1726 insertions(+), 525 deletions(-) delete mode 100644 cmake/ports/openssl/disable-apps.patch delete mode 100644 cmake/ports/openssl/disable-install-docs.patch delete mode 100644 cmake/ports/openssl/script-prefix.patch create mode 100644 cmake/ports/openssl/unix/CMakeLists.txt delete mode 100644 cmake/ports/openssl/unix/android-cc.patch delete mode 100755 cmake/ports/openssl/unix/configure delete mode 100644 cmake/ports/openssl/unix/move-openssldir.patch delete mode 100644 cmake/ports/openssl/unix/no-empty-dirs.patch delete mode 100644 cmake/ports/openssl/unix/no-static-libs-for-shared.patch create mode 100644 cmake/ports/openssl/uwp/make-openssl.bat create mode 100644 cmake/ports/openssl/uwp/portfile.cmake create mode 100644 cmake/ports/openssl/windows/flags.patch delete mode 100644 cmake/ports/openssl/windows/install-layout.patch delete mode 100644 cmake/ports/openssl/windows/install-pdbs.patch create mode 100644 cmake/ports/vcpkg-cmake-config/copyright create mode 100644 cmake/ports/vcpkg-cmake-config/portfile.cmake create mode 100644 cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake create mode 100644 cmake/ports/vcpkg-cmake-config/vcpkg.json create mode 100644 cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake create mode 100644 cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt create mode 100644 cmake/ports/vcpkg-cmake-get-vars/portfile.cmake create mode 100644 cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake create mode 100644 cmake/ports/vcpkg-cmake-get-vars/vcpkg.json create mode 100644 cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake create mode 100644 cmake/ports/vcpkg-cmake/portfile.cmake create mode 100644 cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake create mode 100644 cmake/ports/vcpkg-cmake/vcpkg.json create mode 100644 cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake create mode 100644 cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake create mode 100644 cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake diff --git a/.gitignore b/.gitignore index 91e80c1fb0..bbcbadf2b6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ cmake-build-minsizerelease-visual-studio/ cmake-build-release-visual-studio/ cmake-build-relwithdebinfo-visual-studio/ cmake-build-debug-visual-studio/ +cmake-build-debug/ /release*/ /debug*/ /gprof*/ diff --git a/cmake/ports/openssl/disable-apps.patch b/cmake/ports/openssl/disable-apps.patch deleted file mode 100644 index 8dac3d6835..0000000000 --- a/cmake/ports/openssl/disable-apps.patch +++ /dev/null @@ -1,12 +0,0 @@ -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/cmake/ports/openssl/disable-install-docs.patch b/cmake/ports/openssl/disable-install-docs.patch deleted file mode 100644 index 6e39790cec..0000000000 --- a/cmake/ports/openssl/disable-install-docs.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl -index 110ba06..5b6b1c7 100644 ---- a/Configurations/unix-Makefile.tmpl -+++ b/Configurations/unix-Makefile.tmpl -@@ -611,7 +611,7 @@ install_sw: install_dev install_engines install_modules install_runtime - - uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev - --install_docs: install_man_docs install_html_docs -+install_docs: - - uninstall_docs: uninstall_man_docs uninstall_html_docs - $(RM) -r $(DESTDIR)$(DOCDIR) -diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl -index d054431..b5c1c88 100644 ---- a/Configurations/windows-makefile.tmpl -+++ b/Configurations/windows-makefile.tmpl -@@ -487,7 +487,7 @@ install_sw: install_dev install_engines install_modules install_runtime - - uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev - --install_docs: install_html_docs -+install_docs: - - uninstall_docs: uninstall_html_docs - diff --git a/cmake/ports/openssl/install-pc-files.cmake b/cmake/ports/openssl/install-pc-files.cmake index 04897faed7..eb8d2b8c28 100644 --- a/cmake/ports/openssl/install-pc-files.cmake +++ b/cmake/ports/openssl/install-pc-files.cmake @@ -25,7 +25,7 @@ install_pc_file(libcrypto [[ Name: OpenSSL-libcrypto Description: OpenSSL cryptography library Libs: -L"${libdir}" -llibcrypto -Libs.private: -lcrypt32 -lws2_32 -ladvapi32 -luser32 +Libs.private: -lcrypt32 -lws2_32 Cflags: -I"${includedir}" ]]) diff --git a/cmake/ports/openssl/openssl.pc.in b/cmake/ports/openssl/openssl.pc.in index f7fa9d185f..3033e1804d 100644 --- a/cmake/ports/openssl/openssl.pc.in +++ b/cmake/ports/openssl/openssl.pc.in @@ -2,5 +2,5 @@ prefix=${pcfiledir}/../.. exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include -Version: @VERSION@ +Version: @OPENSSL_VERSION@ @pc_data@ diff --git a/cmake/ports/openssl/portfile.cmake b/cmake/ports/openssl/portfile.cmake index 17e94cbe6f..f4adebca3d 100644 --- a/cmake/ports/openssl/portfile.cmake +++ b/cmake/ports/openssl/portfile.cmake @@ -3,73 +3,41 @@ if(EXISTS "${CURRENT_INSTALLED_DIR}/share/libressl/copyright" message(FATAL_ERROR "Can't build openssl if libressl/boringssl is installed. Please remove libressl/boringssl, and try install openssl again if you need it.") endif() -if(VCPKG_TARGET_IS_EMSCRIPTEN) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +if (VCPKG_TARGET_IS_LINUX) + message(WARNING +[[openssl currently requires the following library from the system package manager: + linux-headers +It can be installed on alpine systems via apk add linux-headers.]] + ) endif() -if (NOT "${VERSION}" MATCHES [[^([0-9]+)\.([0-9]+)\.([0-9]+)$]]) - message(FATAL_ERROR "Version regex did not match.") +set(OPENSSL_VERSION 3.0.5) + +if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP) + set(OPENSSL_PATCHES "${CMAKE_CURRENT_LIST_DIR}/windows/flags.patch") endif() -set(OPENSSL_VERSION_MAJOR "${CMAKE_MATCH_1}") -set(OPENSSL_VERSION_MINOR "${CMAKE_MATCH_2}") -set(OPENSSL_VERSION_FIX "${CMAKE_MATCH_3}") -configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO openssl/openssl - REF "openssl-${VERSION}" - SHA512 7073fd82ce17a63d77babb6a184c14c7341e4b1f8f5a6caeaa1a6d9c78d6a12bb6d9cbad5d39d16412be6d1c12eac60364644664a8e26e3940476973ba07fd19 - PATCHES - disable-apps.patch - disable-install-docs.patch - script-prefix.patch - windows/install-layout.patch - windows/install-pdbs.patch - unix/android-cc.patch - unix/move-openssldir.patch - unix/no-empty-dirs.patch - unix/no-static-libs-for-shared.patch + REF openssl-${OPENSSL_VERSION} + SHA512 e426f2d48dcd87ad938b246cea69988710198c3ed2f5bb9065aa9e74492161b056336f5b1f29be64e70dfd86a77808fe727ebb46eae10331c76f1ff08e341133 + PATCHES ${OPENSSL_PATCHES} ) -vcpkg_list(SET CONFIGURE_OPTIONS - enable-static-engine - enable-capieng - no-ssl3 - no-weak-ssl-ciphers - no-tests -) +vcpkg_find_acquire_program(PERL) +get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) +vcpkg_add_to_path("${PERL_EXE_PATH}") -set(INSTALL_FIPS "") -if("fips" IN_LIST FEATURES) - vcpkg_list(APPEND INSTALL_FIPS install_fips) - vcpkg_list(APPEND CONFIGURE_OPTIONS enable-fips) -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - vcpkg_list(APPEND CONFIGURE_OPTIONS shared) -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() - -if(OPENSSL_NO_AUTOLOAD_CONFIG) - vcpkg_list(APPEND CONFIGURE_OPTIONS no-autoload-config) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) +if(VCPKG_TARGET_IS_UWP) + include("${CMAKE_CURRENT_LIST_DIR}/uwp/portfile.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/install-pc-files.cmake") +elseif(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) include("${CMAKE_CURRENT_LIST_DIR}/windows/portfile.cmake") include("${CMAKE_CURRENT_LIST_DIR}/install-pc-files.cmake") else() include("${CMAKE_CURRENT_LIST_DIR}/unix/portfile.cmake") endif() +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/openssl/script-prefix.patch b/cmake/ports/openssl/script-prefix.patch deleted file mode 100644 index 70f0859ca8..0000000000 --- a/cmake/ports/openssl/script-prefix.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/tools/c_rehash.in b/tools/c_rehash.in -index 343cdc1..e48038e 100644 ---- a/tools/c_rehash.in -+++ b/tools/c_rehash.in -@@ -12,7 +12,7 @@ - # and add symbolic links to their hash values. - - my $dir = {- quotify1($config{openssldir}) -}; --my $prefix = {- quotify1($config{prefix}) -}; -+use FindBin; - - my $errorcount = 0; - my $openssl = $ENV{OPENSSL} || "openssl"; -@@ -61,7 +61,7 @@ if (defined(&Cwd::getcwd)) { - - # DOS/Win32 or Unix delimiter? Prefix our installdir, then search. - my $path_delim = ($pwd =~ /^[a-z]\:/i) ? ';' : ':'; --$ENV{PATH} = "$prefix/bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : ""); -+$ENV{PATH} = "$FindBin::Bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : ""); - - if (! -x $openssl) { - my $found = 0; diff --git a/cmake/ports/openssl/unix/CMakeLists.txt b/cmake/ports/openssl/unix/CMakeLists.txt new file mode 100644 index 0000000000..9cb6a5325d --- /dev/null +++ b/cmake/ports/openssl/unix/CMakeLists.txt @@ -0,0 +1,285 @@ +cmake_minimum_required(VERSION 3.9) +project(openssl C) + +if(NOT SOURCE_PATH) + message(FATAL_ERROR "Requires SOURCE_PATH") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(PLATFORM linux-x86_64) + else() + set(PLATFORM linux-generic32) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") + if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") + set(PLATFORM ios64-xcrun) + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") + set(PLATFORM ios-xcrun) + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" OR + VCPKG_TARGET_ARCHITECTURE MATCHES "x64") + set(PLATFORM iossimulator-xcrun) + else() + message(FATAL_ERROR "Unknown iOS target architecture: ${VCPKG_TARGET_ARCHITECTURE}") + endif() + # disable that makes linkage error (e.g. require stderr usage) + list(APPEND DISABLES no-stdio no-ui no-asm) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") + set(PLATFORM darwin64-arm64-cc) + else() + set(PLATFORM darwin64-x86_64-cc) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(PLATFORM BSD-generic64) +elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + set(PLATFORM BSD-generic64) +elseif(MINGW) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(PLATFORM mingw64) + else() + set(PLATFORM mingw) + endif() +elseif(EMSCRIPTEN) + set(MAKE $ENV{EMSDK}/upstream/emscripten/emmake) + set(ENV{MAKE} $ENV{EMSDK}/upstream/emscripten/emmake) +else() + message(FATAL_ERROR "Unknown platform") +endif() + +get_filename_component(COMPILER_ROOT "${CMAKE_C_COMPILER}" DIRECTORY) + +message("CMAKE_C_COMPILER=${CMAKE_C_COMPILER}") +message("COMPILER_ROOT=${COMPILER_ROOT}") +message("CMAKE_SYSROOT=${CMAKE_SYSROOT}") +message("CMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}") +message("CMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}") +message("CMAKE_C_FLAGS=${CMAKE_C_FLAGS}") +message("CMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}") +message("CMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}") +message("CMAKE_INCLUDE_SYSTEM_FLAG_C=${CMAKE_INCLUDE_SYSTEM_FLAG_C}") +message("CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG=${CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG}") + +string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) +set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BUILD_TYPE}}") +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + set(CFLAGS "${CFLAGS} -Wno-error=unused-command-line-argument") +endif() +if(CMAKE_C_COMPILER_TARGET AND CMAKE_C_COMPILE_OPTIONS_TARGET) + set(CFLAGS "${CFLAGS} ${CMAKE_C_COMPILE_OPTIONS_TARGET}${CMAKE_C_COMPILER_TARGET}") +endif() +if(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN AND CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN) + set(CFLAGS "${CFLAGS} ${CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}") +endif() +if(CMAKE_SYSROOT AND CMAKE_C_COMPILE_OPTIONS_SYSROOT) + set(CFLAGS "${CFLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}") +elseif(CMAKE_OSX_SYSROOT AND CMAKE_C_COMPILE_OPTIONS_SYSROOT) + set(CFLAGS "${CFLAGS} ${CMAKE_C_COMPILE_OPTIONS_SYSROOT}${CMAKE_OSX_SYSROOT}") +endif() +if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG) + set(CFLAGS "${CFLAGS} ${CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") +elseif((CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND (VCPKG_TARGET_ARCHITECTURE MATCHES "arm64")) + set(CFLAGS "${CFLAGS} -mmacosx-version-min=11.0") +endif() + +string(REGEX REPLACE "^ " "" CFLAGS "${CFLAGS}") + +if(CMAKE_HOST_WIN32) + file(TO_NATIVE_PATH ENV_PATH "${COMPILER_ROOT};$ENV{PATH}") +else() + file(TO_NATIVE_PATH ENV_PATH "${COMPILER_ROOT}:$ENV{PATH}") +endif() +set(ENV{ANDROID_DEV} "${CMAKE_SYSROOT}/usr") + +if(NOT IOS) + set(ENV{CC} "${CMAKE_C_COMPILER}") +endif() + +message("ENV{ANDROID_DEV}=$ENV{ANDROID_DEV}") + +get_filename_component(SOURCE_PATH_NAME "${SOURCE_PATH}" NAME) +set(BUILDDIR "${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_PATH_NAME}") + +if(NOT EXISTS "${BUILDDIR}") + file(COPY ${SOURCE_PATH} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endif() + +get_filename_component(MSYS_BIN_DIR "${MAKE}" DIRECTORY) + +if(BUILD_SHARED_LIBS) + set(SHARED shared) + file(STRINGS "${BUILDDIR}/VERSION.dat" SHLIB_VERSION + REGEX "^SHLIB_VERSION=.*") + string(REGEX REPLACE "^(SHLIB_VERSION=)(.*)$" "\\2" + SHLIB_VERSION "${SHLIB_VERSION}") + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(LIB_EXT dylib) + set(LIB_EXTS ${SHLIB_VERSION}.${LIB_EXT}) + elseif(MINGW) + string(REPLACE "." "_" SHLIB_VERSION "${SHLIB_VERSION}") + set(BIN_EXT dll) + set(LIB_EXT dll.a) + else() + set(LIB_EXT so) + set(LIB_EXTS ${LIB_EXT}.${SHLIB_VERSION}) + endif() + list(APPEND BIN_EXTS ${BIN_EXT}) + list(APPEND LIB_EXTS ${LIB_EXT}) +else() + set(SHARED no-shared no-module) + set(LIB_EXTS a) +endif() +set(INSTALL_PKG_CONFIGS "${BUILDDIR}/openssl.pc") +foreach(lib ssl crypto) + foreach(ext ${LIB_EXTS}) + list(APPEND INSTALL_LIBS "${BUILDDIR}/lib${lib}.${ext}") + list(APPEND INSTALL_PKG_CONFIGS "${BUILDDIR}/lib${lib}.pc") + endforeach() + foreach(ext ${BIN_EXTS}) + # This might be wrong for targets which don't follow this naming scheme, but I'm not aware of any + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + list(APPEND INSTALL_BINS "${BUILDDIR}/lib${lib}-${SHLIB_VERSION}-x64.${ext}") + else() + list(APPEND INSTALL_BINS "${BUILDDIR}/lib${lib}-${SHLIB_VERSION}.${ext}") + endif() + endforeach() +endforeach() + +if(CMAKE_HOST_WIN32) + set(ENV_COMMAND set) + set(PATH_VAR ";%PATH%") +else() + set(ENV_COMMAND export) + set(PATH_VAR ":$ENV{PATH}") +endif() + +add_custom_command( + OUTPUT "${BUILDDIR}/Makefile" + COMMAND ${ENV_COMMAND} "PATH=${MSYS_BIN_DIR}${PATH_VAR}" + VERBATIM + WORKING_DIRECTORY "${BUILDDIR}" +) + +if(NOT IOS) + add_custom_command( + OUTPUT "${BUILDDIR}/Makefile" + COMMAND ${ENV_COMMAND} CC=${CMAKE_C_COMPILER} + COMMAND ${ENV_COMMAND} AR=${CMAKE_AR} + COMMAND ${ENV_COMMAND} LD=${CMAKE_LINKER} + COMMAND ${ENV_COMMAND} RANLIB=${CMAKE_RANLIB} + COMMAND ${ENV_COMMAND} MAKE=${MAKE} + COMMAND ${ENV_COMMAND} MAKEDEPPROG=${CMAKE_C_COMPILER} + COMMAND ${ENV_COMMAND} WINDRES=${CMAKE_RC_COMPILER} + VERBATIM + APPEND + ) + if(EMSCRIPTEN) + list(APPEND DISABLES + threads + no-engine + no-dso + no-asm + no-shared + no-sse2 + no-srtp + ) + else() + list(APPEND DISABLES + enable-static-engine + no-zlib + no-ssl2 + no-idea + no-cast + no-seed + no-md2 + no-tests) + endif() +endif() + +if(EMSCRIPTEN) + add_custom_command( + OUTPUT "${BUILDDIR}/Makefile" + COMMAND "$ENV{EMSDK}/upstream/emscripten/emconfigure" ./config + ${SHARED} + ${DISABLES} + "--prefix=${CMAKE_INSTALL_PREFIX}" + "--openssldir=/etc/ssl" + "--cross-compile-prefix=\"/\"" + VERBATIM + APPEND + ) + + add_custom_target(build_libs ALL + COMMAND ${ENV_COMMAND} "PATH=${MSYS_BIN_DIR}${PATH_VAR}" + COMMAND "${CMAKE_COMMAND}" -E touch "${BUILDDIR}/krb5.h" + COMMAND "${MAKE}" make build_libs + VERBATIM + WORKING_DIRECTORY "${BUILDDIR}" + DEPENDS "${BUILDDIR}/Makefile" + BYPRODUCTS ${INSTALL_LIBS} + ) +else() + add_custom_command( + OUTPUT "${BUILDDIR}/Makefile" + COMMAND "${PERL}" Configure + ${SHARED} + ${DISABLES} + ${PLATFORM} + "--prefix=${CMAKE_INSTALL_PREFIX}" + "--openssldir=/etc/ssl" + ${CFLAGS} + VERBATIM + APPEND + ) + + add_custom_target(build_libs ALL + COMMAND ${ENV_COMMAND} "PATH=${MSYS_BIN_DIR}${PATH_VAR}" + COMMAND "${CMAKE_COMMAND}" -E touch "${BUILDDIR}/krb5.h" + COMMAND "${MAKE}" -j ${VCPKG_CONCURRENCY} build_libs + VERBATIM + WORKING_DIRECTORY "${BUILDDIR}" + DEPENDS "${BUILDDIR}/Makefile" + BYPRODUCTS ${INSTALL_LIBS} + ) +endif() + +add_custom_command( + OUTPUT "${BUILDDIR}/Makefile" + COMMAND "${CMAKE_COMMAND}" "-DDIR=${BUILDDIR}" -P "${CMAKE_CURRENT_LIST_DIR}/remove-deps.cmake" + VERBATIM + APPEND +) + +if((CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") AND BUILD_SHARED_LIBS) + if(DEFINED CMAKE_INSTALL_NAME_DIR) + set(ID_PREFIX "${CMAKE_INSTALL_NAME_DIR}") + else() + set(ID_PREFIX "@rpath") + endif() + + add_custom_command( + TARGET build_libs + COMMAND /usr/bin/install_name_tool -id "${ID_PREFIX}/libssl.${SHLIB_VERSION}.dylib" + "${BUILDDIR}/libssl.${SHLIB_VERSION}.dylib" + COMMAND /usr/bin/install_name_tool -id "${ID_PREFIX}/libcrypto.${SHLIB_VERSION}.dylib" + "${BUILDDIR}/libcrypto.${SHLIB_VERSION}.dylib" + COMMAND /usr/bin/install_name_tool -change "${CMAKE_INSTALL_PREFIX}/lib/libcrypto.${SHLIB_VERSION}.dylib" + "${ID_PREFIX}/libcrypto.${SHLIB_VERSION}.dylib" + "${BUILDDIR}/libssl.${SHLIB_VERSION}.dylib" + VERBATIM + ) +endif() + +install( + FILES ${INSTALL_LIBS} + DESTINATION lib +) +install( + FILES ${INSTALL_BINS} + DESTINATION bin +) +install( + FILES ${INSTALL_PKG_CONFIGS} + DESTINATION lib/pkgconfig +) diff --git a/cmake/ports/openssl/unix/android-cc.patch b/cmake/ports/openssl/unix/android-cc.patch deleted file mode 100644 index f4c3d68343..0000000000 --- a/cmake/ports/openssl/unix/android-cc.patch +++ /dev/null @@ -1,20 +0,0 @@ -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/cmake/ports/openssl/unix/configure b/cmake/ports/openssl/unix/configure deleted file mode 100755 index 5599aaa0f6..0000000000 --- a/cmake/ports/openssl/unix/configure +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -e - -declare -a OUT_OPTIONS - -INTERPRETER=perl - -LAST_SEEN= -COPY_OPTIONS=no -for OPTION; do - case "${OPTION},${COPY_OPTIONS}" in - */Configure,no) - OUT_OPTIONS+=("${OPTION}") - INTERPRETER="${LAST_SEEN}" - COPY_OPTIONS=yes - ;; - --prefix=*|--openssldir=*|--libdir=*|--cross-compile-prefix=*|--debug,*) - OUT_OPTIONS+=("${OPTION}") - ;; - -*|*=*) - ;; - *,yes) - OUT_OPTIONS+=("${OPTION}") - ;; - esac - LAST_SEEN="${OPTION}" -done - -set -x -"${INTERPRETER}" ${OUT_OPTIONS[@]} diff --git a/cmake/ports/openssl/unix/move-openssldir.patch b/cmake/ports/openssl/unix/move-openssldir.patch deleted file mode 100644 index 44e0183efe..0000000000 --- a/cmake/ports/openssl/unix/move-openssldir.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl -index dd96254..c4458ca 100644 ---- a/Configurations/unix-Makefile.tmpl -+++ b/Configurations/unix-Makefile.tmpl -@@ -689,6 +689,10 @@ install_ssldirs: - cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ - chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ - fi -+ $(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)$(OPENSSLDIR) -+ for I in $(DESTDIR)$(OPENSSLDIR)/*; do \ -+ mv $$I $(DESTDIR)$(INSTALLTOP)$(OPENSSLDIR)/; \ -+ done - - install_dev: install_runtime_libs - @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) diff --git a/cmake/ports/openssl/unix/no-empty-dirs.patch b/cmake/ports/openssl/unix/no-empty-dirs.patch deleted file mode 100644 index 4c59d9eaca..0000000000 --- a/cmake/ports/openssl/unix/no-empty-dirs.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl -index 5b6b1c7..4c8c916 100644 ---- a/Configurations/unix-Makefile.tmpl -+++ b/Configurations/unix-Makefile.tmpl -@@ -818,7 +818,7 @@ _install_modules_deps: install_runtime_libs build_modules - - install_engines: _install_modules_deps - @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) -- @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/ -+ @[ -z "$(INSTALL_ENGINES)" ] || $(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/ - @$(ECHO) "*** Installing engines" - @set -e; for e in dummy $(INSTALL_ENGINES); do \ - if [ "$$e" = "dummy" ]; then continue; fi; \ -@@ -842,7 +842,7 @@ uninstall_engines: - - install_modules: _install_modules_deps - @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) -- @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/ -+ @[ -z "$(INSTALL_MODULES)" ] || $(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/ - @$(ECHO) "*** Installing modules" - @set -e; for e in dummy $(INSTALL_MODULES); do \ - if [ "$$e" = "dummy" ]; then continue; fi; \ diff --git a/cmake/ports/openssl/unix/no-static-libs-for-shared.patch b/cmake/ports/openssl/unix/no-static-libs-for-shared.patch deleted file mode 100644 index 868e682a32..0000000000 --- a/cmake/ports/openssl/unix/no-static-libs-for-shared.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl -index 4c8c916..dd96254 100644 ---- a/Configurations/unix-Makefile.tmpl -+++ b/Configurations/unix-Makefile.tmpl -@@ -708,6 +708,7 @@ install_dev: install_runtime_libs - done - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) - @set -e; for l in $(INSTALL_LIBS); do \ -+ if [ -n "$(INSTALL_SHLIBS)" ] ; then continue ; fi ; \ - fn=`basename $$l`; \ - $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \ - cp $$l $(DESTDIR)$(libdir)/$$fn.new; \ diff --git a/cmake/ports/openssl/unix/portfile.cmake b/cmake/ports/openssl/unix/portfile.cmake index 9eff266edf..319b7e3905 100644 --- a/cmake/ports/openssl/unix/portfile.cmake +++ b/cmake/ports/openssl/unix/portfile.cmake @@ -1,11 +1,3 @@ -if (VCPKG_TARGET_IS_LINUX) - message(NOTICE [[ -openssl requires Linux kernel headers from the system package manager. - They can be installed on Alpine systems via `apk add linux-headers`. - They can be installed on Ubuntu systems via `apt install linux-libc-dev`. -]]) -endif() - if(CMAKE_HOST_WIN32) vcpkg_acquire_msys(MSYS_ROOT PACKAGES make perl) set(MAKE "${MSYS_ROOT}/usr/bin/make.exe") @@ -15,139 +7,26 @@ else() if(NOT MAKE) message(FATAL_ERROR "Could not find make. Please install it through your package manager.") endif() - vcpkg_find_acquire_program(PERL) -endif() -set(INTERPRETER "${PERL}") - -execute_process( - COMMAND "${PERL}" -e "use IPC::Cmd;" - RESULT_VARIABLE perl_ipc_cmd_result -) -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) - 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") - set(OPENSSL_ARCH linux-aarch64) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") - set(OPENSSL_ARCH linux-armv4) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - set(OPENSSL_ARCH linux-x86_64) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86") - set(OPENSSL_ARCH linux-x86) - else() - set(OPENSSL_ARCH linux-generic32) - endif() -elseif(VCPKG_TARGET_IS_IOS) - if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") - set(OPENSSL_ARCH ios64-xcrun) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm") - set(OPENSSL_ARCH ios-xcrun) - elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" OR VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - set(OPENSSL_ARCH iossimulator-xcrun) - else() - message(FATAL_ERROR "Unknown iOS target architecture: ${VCPKG_TARGET_ARCHITECTURE}") - endif() - # disable that makes linkage error (e.g. require stderr usage) - list(APPEND CONFIGURE_OPTIONS no-ui no-asm) -elseif(VCPKG_TARGET_IS_OSX) - if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") - set(OPENSSL_ARCH darwin64-arm64) - else() - set(OPENSSL_ARCH darwin64-x86_64) - endif() -elseif(VCPKG_TARGET_IS_FREEBSD OR VCPKG_TARGET_IS_OPENBSD) - set(OPENSSL_ARCH BSD-generic64) -elseif(VCPKG_TARGET_IS_MINGW) - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(OPENSSL_ARCH mingw64) - else() - set(OPENSSL_ARCH mingw) - endif() -elseif(VCPKG_TARGET_IS_EMSCRIPTEN) - vcpkg_list(APPEND CONFIGURE_OPTIONS - threads - no-engine - no-asm - no-sse2 - no-srtp - --cross-compile-prefix= - ) -else() - message(FATAL_ERROR "Unknown platform") -endif() - -file(MAKE_DIRECTORY "${SOURCE_PATH}/vcpkg") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/configure" DESTINATION "${SOURCE_PATH}/vcpkg") -vcpkg_configure_make( - SOURCE_PATH "${SOURCE_PATH}" - PROJECT_SUBPATH "vcpkg" - NO_ADDITIONAL_PATHS +vcpkg_cmake_configure( + SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}" OPTIONS - "${INTERPRETER}" - "${SOURCE_PATH}/Configure" - ${OPENSSL_ARCH} - ${CONFIGURE_OPTIONS} - "--openssldir=/etc/ssl" - "--libdir=lib" - OPTIONS_DEBUG - --debug -) -vcpkg_install_make( - ${MAKEFILE_OPTIONS} - BUILD_TARGET build_sw + -DSOURCE_PATH=${SOURCE_PATH} + -DPERL=${PERL} + -DMAKE=${MAKE} + -DVCPKG_CONCURRENCY=${VCPKG_CONCURRENCY} ) + +vcpkg_cmake_install() vcpkg_fixup_pkgconfig() -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(GLOB HEADERS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/include/openssl/*.h") +set(RESOLVED_HEADERS) +foreach(HEADER ${HEADERS}) + get_filename_component(X "${HEADER}" REALPATH) + list(APPEND RESOLVED_HEADERS "${X}") +endforeach() -file(TOUCH "${CURRENT_PACKAGES_DIR}/etc/ssl/certs/.keep") -file(TOUCH "${CURRENT_PACKAGES_DIR}/etc/ssl/private/.keep") - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/etc" - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" -) - -# For consistency of mingw build with nmake build -file(GLOB engines "${CURRENT_PACKAGES_DIR}/lib/ossl-modules/*.dll") -if(NOT engines STREQUAL "") - file(COPY ${engines} DESTINATION "${CURRENT_PACKAGES_DIR}/bin") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/ossl-modules") -endif() -file(GLOB engines "${CURRENT_PACKAGES_DIR}/debug/lib/ossl-modules/*.dll") -if(NOT engines STREQUAL "") - file(COPY ${engines} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/ossl-modules") -endif() +file(INSTALL ${RESOLVED_HEADERS} DESTINATION "${CURRENT_PACKAGES_DIR}/include/openssl") +file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/openssl/uwp/make-openssl.bat b/cmake/ports/openssl/uwp/make-openssl.bat new file mode 100644 index 0000000000..6f6166a24e --- /dev/null +++ b/cmake/ports/openssl/uwp/make-openssl.bat @@ -0,0 +1,16 @@ +set build=%1 + +perl Configure no-asm no-hw no-dso VC-WINUNIVERSAL -FS -FIWindows.h + +for /D %%f in ("%WindowsSdkDir%References\%WindowsSDKLibVersion%Windows.Foundation.FoundationContract\*") do set LibPath=%LibPath%;%%f\ +for /D %%f in ("%WindowsSdkDir%References\%WindowsSDKLibVersion%Windows.Foundation.UniversalApiContract\*") do set LibPath=%LibPath%;%%f\ +for /D %%f in ("%WindowsSdkDir%References\Windows.Foundation.FoundationContract\*") do set LibPath=%LibPath%;%%f\ +for /D %%f in ("%WindowsSdkDir%References\Windows.Foundation.UniversalApiContract\*") do set LibPath=%LibPath%;%%f\ + +call ms\do_winuniversal.bat + +mkdir inc32\openssl + +jom -j %NUMBER_OF_PROCESSORS% -k -f ms\ntdll.mak +REM due to a race condition in the build, we need to have a second single-threaded pass. +nmake -f ms\ntdll.mak diff --git a/cmake/ports/openssl/uwp/portfile.cmake b/cmake/ports/openssl/uwp/portfile.cmake new file mode 100644 index 0000000000..bb8379dcec --- /dev/null +++ b/cmake/ports/openssl/uwp/portfile.cmake @@ -0,0 +1,155 @@ +vcpkg_find_acquire_program(JOM) +get_filename_component(JOM_EXE_PATH ${JOM} DIRECTORY) +vcpkg_add_to_path("${PERL_EXE_PATH}") + +set(OPENSSL_SHARED no-shared) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(OPENSSL_SHARED shared) +endif() + +vcpkg_find_acquire_program(NASM) +get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) +vcpkg_add_to_path(PREPEND "${NASM_EXE_PATH}") + +set(CONFIGURE_COMMAND ${PERL} Configure + enable-static-engine + enable-capieng + no-unit-test + no-ssl2 + no-asm + no-uplink + no-tests + -utf-8 + ${OPENSSL_SHARED} +) + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(OPENSSL_ARCH VC-WIN32-UWP) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(OPENSSL_ARCH VC-WIN64A-UWP) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") + set(OPENSSL_ARCH VC-WIN32-ARM-UWP) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(OPENSSL_ARCH VC-WIN64-ARM-UWP) +else() + message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}") +endif() + +set(OPENSSL_MAKEFILE "makefile") + +file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + + # Copy openssl sources. + message(STATUS "Copying openssl release source files...") + file(GLOB OPENSSL_SOURCE_FILES "${SOURCE_PATH}/*") + foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES}) + file(COPY ${SOURCE_FILE} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + endforeach() + message(STATUS "Copying openssl release source files... done") + set(SOURCE_PATH_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + + set(OPENSSLDIR_RELEASE "${CURRENT_PACKAGES_DIR}") + + message(STATUS "Configure ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_RELEASE}" "--openssldir=${OPENSSLDIR_RELEASE}" -FS + WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}" + LOGNAME configure-perl-${TARGET_TRIPLET}-${VCPKG_BUILD_TYPE}-rel + ) + message(STATUS "Configure ${TARGET_TRIPLET}-rel done") + + message(STATUS "Build ${TARGET_TRIPLET}-rel") + # Openssl's buildsystem has a race condition which will cause JOM to fail at some point. + # This is ok; we just do as much work as we can in parallel first, then follow up with a single-threaded build. + make_directory("${SOURCE_PATH_RELEASE}/inc32/openssl") + execute_process( + COMMAND "${JOM}" -k -j ${VCPKG_CONCURRENCY} -f "${OPENSSL_MAKEFILE}" build_libs + WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}" + OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-out.log" + ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-err.log" + ) + vcpkg_execute_required_process( + COMMAND nmake -f "${OPENSSL_MAKEFILE}" install_dev + WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}" + LOGNAME build-${TARGET_TRIPLET}-rel-1) + + message(STATUS "Build ${TARGET_TRIPLET}-rel done") +endif() + + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + # Copy openssl sources. + message(STATUS "Copying openssl debug source files...") + file(GLOB OPENSSL_SOURCE_FILES ${SOURCE_PATH}/*) + foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES}) + file(COPY "${SOURCE_FILE}" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + endforeach() + message(STATUS "Copying openssl debug source files... done") + set(SOURCE_PATH_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + + set(OPENSSLDIR_DEBUG "${CURRENT_PACKAGES_DIR}/debug") + + message(STATUS "Configure ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${CONFIGURE_COMMAND} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS + WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}" + LOGNAME configure-perl-${TARGET_TRIPLET}-${VCPKG_BUILD_TYPE}-dbg + ) + message(STATUS "Configure ${TARGET_TRIPLET}-dbg done") + + message(STATUS "Build ${TARGET_TRIPLET}-dbg") + make_directory("${SOURCE_PATH_DEBUG}/inc32/openssl") + execute_process( + COMMAND "${JOM}" -k -j ${VCPKG_CONCURRENCY} -f "${OPENSSL_MAKEFILE}" build_libs + WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}" + OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-out.log" + ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-err.log" + ) + vcpkg_execute_required_process( + COMMAND nmake -f "${OPENSSL_MAKEFILE}" install_dev + WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}" + LOGNAME build-${TARGET_TRIPLET}-dbg-1) + + message(STATUS "Build ${TARGET_TRIPLET}-dbg done") +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/certs") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/private") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/engines-1_1") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/certs") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/engines-1_1") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/private") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(REMOVE + "${CURRENT_PACKAGES_DIR}/bin/openssl.exe" + "${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe" + "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf" + "${CURRENT_PACKAGES_DIR}/openssl.cnf" + "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf" + "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf.dist" + "${CURRENT_PACKAGES_DIR}/openssl.cnf.dist" + "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf" + "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf.dist" + "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf.dist" +) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + # They should be empty, only the exes deleted above were in these directories + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin/") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin/") +endif() + +file(READ "${CURRENT_PACKAGES_DIR}/include/openssl/dtls1.h" _contents) +string(REPLACE "" "" _contents "${_contents}") +file(WRITE "${CURRENT_PACKAGES_DIR}/include/openssl/dtls1.h" "${_contents}") + +file(READ "${CURRENT_PACKAGES_DIR}/include/openssl/rand.h" _contents) +string(REPLACE "# include " "#ifndef _WINSOCKAPI_\n#define _WINSOCKAPI_\n#endif\n# include " _contents "${_contents}") +file(WRITE "${CURRENT_PACKAGES_DIR}/include/openssl/rand.h" "${_contents}") + +vcpkg_copy_pdbs() + +file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in b/cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in index 5008112c35..123364f9a8 100644 --- a/cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in +++ b/cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in @@ -3,9 +3,9 @@ cmake_policy(SET CMP0012 NEW) cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0057 NEW) -set(OPENSSL_VERSION_MAJOR @OPENSSL_VERSION_MAJOR@) -set(OPENSSL_VERSION_MINOR @OPENSSL_VERSION_MINOR@) -set(OPENSSL_VERSION_FIX @OPENSSL_VERSION_FIX@) +set(OPENSSL_VERSION_MAJOR 3) +set(OPENSSL_VERSION_MINOR 0) +set(OPENSSL_VERSION_FIX 5) if(OPENSSL_USE_STATIC_LIBS) if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "dynamic") diff --git a/cmake/ports/openssl/vcpkg.json b/cmake/ports/openssl/vcpkg.json index 9f49558ce9..fdafd63474 100644 --- a/cmake/ports/openssl/vcpkg.json +++ b/cmake/ports/openssl/vcpkg.json @@ -1,6 +1,6 @@ { "name": "openssl", - "version": "3.1.1", + "version": "3.0.5", "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", @@ -15,17 +15,8 @@ }, { "name": "vcpkg-cmake-get-vars", - "host": true + "host": true, + "platform": "windows & !mingw & !uwp" } - ], - "features": { - "fips": { - "description": "Enable fips", - "supports": "!static" - }, - "tools": { - "description": "Install openssl executable and scripts", - "supports": "!uwp" - } - } + ] } diff --git a/cmake/ports/openssl/windows/flags.patch b/cmake/ports/openssl/windows/flags.patch new file mode 100644 index 0000000000..69b203c0dd --- /dev/null +++ b/cmake/ports/openssl/windows/flags.patch @@ -0,0 +1,35 @@ +diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf +index 66bc81d..2364633 100644 +--- a/Configurations/10-main.conf ++++ b/Configurations/10-main.conf +@@ -1302,7 +1302,7 @@ my %targets = ( + inherit_from => [ "BASE_Windows" ], + template => 1, + CC => "cl", +- CPP => '"$(CC)" /EP /C', ++ CPP => '$(CC) /EP /C', + CFLAGS => "/W3 /wd4090 /nologo", + coutflag => "/Fo", + LD => "link", +diff --git a/Configure b/Configure +index 8b234f6..e031768 100644 +--- a/Configure ++++ b/Configure +@@ -680,7 +680,7 @@ my $list_separator_re = + # (we supported those before the change to "make variable" support. + my %user = ( + AR => env('AR'), +- ARFLAGS => [], ++ ARFLAGS => [ env('ARFLAGS') || () ], + AS => undef, + ASFLAGS => [], + CC => env('CC'), +@@ -693,7 +693,7 @@ my %user = ( + CPPINCLUDES => [], # Alternative for -I + CROSS_COMPILE => env('CROSS_COMPILE'), + HASHBANGPERL=> env('HASHBANGPERL') || env('PERL'), +- LD => undef, ++ LD => env('LD'), + LDFLAGS => [ env('LDFLAGS') || () ], # -L, -Wl, + LDLIBS => [ env('LDLIBS') || () ], # -l + MT => undef, diff --git a/cmake/ports/openssl/windows/install-layout.patch b/cmake/ports/openssl/windows/install-layout.patch deleted file mode 100644 index be9df768b3..0000000000 --- a/cmake/ports/openssl/windows/install-layout.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl -index f71f3bf..116954f 100644 ---- a/Configurations/windows-makefile.tmpl -+++ b/Configurations/windows-makefile.tmpl -@@ -223,7 +223,7 @@ MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath); - splitpath($modulesprefix, 1); - our $modulesdir_dev = $modulesprefix_dev; - our $modulesdir_dir = -- catdir($modulesprefix_dir, "ossl-modules"); -+ catdir($modulesprefix_dir, "../bin"); - our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir); - our $enginesdir_dev = $modulesprefix_dev; - our $enginesdir_dir = diff --git a/cmake/ports/openssl/windows/install-pdbs.patch b/cmake/ports/openssl/windows/install-pdbs.patch deleted file mode 100644 index 379c525a4f..0000000000 --- a/cmake/ports/openssl/windows/install-pdbs.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl -index 5946c89..f71f3bf 100644 ---- a/Configurations/windows-makefile.tmpl -+++ b/Configurations/windows-makefile.tmpl -@@ -556,6 +556,7 @@ install_dev: install_runtime_libs - @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)" - @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)" - @if "$(SHLIBS)"=="" \ -+ @if "$(INSTALL_PDBS)"=="ON" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)" - - uninstall_dev: -@@ -569,6 +570,7 @@ install_engines: _install_modules_deps - @if not "$(INSTALL_ENGINES)"=="" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)" - @if not "$(INSTALL_ENGINES)"=="" \ -+ @if "$(INSTALL_PDBS)"=="ON" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)" - - uninstall_engines: -@@ -580,6 +582,7 @@ install_modules: _install_modules_deps - @if not "$(INSTALL_MODULES)"=="" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)" - @if not "$(INSTALL_MODULES)"=="" \ -+ @if "$(INSTALL_PDBS)"=="ON" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)" - - uninstall_modules: -@@ -593,6 +596,7 @@ install_runtime_libs: build_libs - @if not "$(SHLIBS)"=="" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin" - @if not "$(SHLIBS)"=="" \ -+ @if "$(INSTALL_PDBS)"=="ON" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \ - "$(INSTALLTOP)\bin" - -@@ -605,6 +609,7 @@ install_programs: install_runtime_libs build_programs - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \ - "$(INSTALLTOP)\bin" - @if not "$(INSTALL_PROGRAMS)"=="" \ -+ @if "$(INSTALL_PDBS)"=="ON" \ - "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \ - "$(INSTALLTOP)\bin" - @if not "$(INSTALL_PROGRAMS)"=="" \ diff --git a/cmake/ports/openssl/windows/portfile.cmake b/cmake/ports/openssl/windows/portfile.cmake index c1ce277453..b2b6d17af6 100644 --- a/cmake/ports/openssl/windows/portfile.cmake +++ b/cmake/ports/openssl/windows/portfile.cmake @@ -2,9 +2,45 @@ vcpkg_find_acquire_program(NASM) get_filename_component(NASM_EXE_PATH "${NASM}" DIRECTORY) vcpkg_add_to_path(PREPEND "${NASM_EXE_PATH}") -vcpkg_find_acquire_program(PERL) -get_filename_component(PERL_EXE_PATH "${PERL}" DIRECTORY) -vcpkg_add_to_path("${PERL_EXE_PATH}") +vcpkg_find_acquire_program(JOM) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(OPENSSL_SHARED shared) +else() + set(OPENSSL_SHARED no-shared no-module) +endif() + +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") + +set(ENV{CC} "${VCPKG_DETECTED_CMAKE_C_COMPILER}") +set(ENV{CXX} "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") +set(ENV{AR} "${VCPKG_DETECTED_CMAKE_AR}") +set(ENV{LD} "${VCPKG_DETECTED_CMAKE_LINKER}") + +# OpenSSL's buildsystem hardcodes certain PDB manipulations, so we cannot use Z7 +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_C_FLAGS_RELEASE "${VCPKG_COMBINED_C_FLAGS_RELEASE}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_CXX_FLAGS_RELEASE "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") +string(REGEX REPLACE "(^| )-Z7($| )" " " VCPKG_COMBINED_CXX_FLAGS_DEBUG "${VCPKG_COMBINED_CXX_FLAGS_DEBUG}") + +set(CONFIGURE_OPTIONS + enable-static-engine + enable-capieng + no-ssl2 + no-tests + ${OPENSSL_SHARED} +) + +if(DEFINED OPENSSL_USE_NOPINSHARED) + set(CONFIGURE_OPTIONS ${CONFIGURE_OPTIONS} no-pinshared) +endif() + +if(OPENSSL_NO_AUTOLOAD_CONFIG) + set(CONFIGURE_OPTIONS ${CONFIGURE_OPTIONS} no-autoload-config) +endif() + +set(CONFIGURE_COMMAND "${PERL}" Configure ${CONFIGURE_OPTIONS}) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") set(OPENSSL_ARCH VC-WIN32) @@ -18,116 +54,154 @@ else() message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}") endif() -if(VCPKG_TARGET_IS_UWP) - vcpkg_list(APPEND CONFIGURE_OPTIONS - no-unit-test - no-asm - no-uplink +set(OPENSSL_MAKEFILE "makefile") + +file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + # Copy openssl sources. + message(STATUS "Copying openssl release source files...") + file(GLOB OPENSSL_SOURCE_FILES ${SOURCE_PATH}/*) + foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES}) + file(COPY ${SOURCE_FILE} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + endforeach() + message(STATUS "Copying openssl release source files... done") + set(SOURCE_PATH_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + + set(OPENSSLDIR_RELEASE ${CURRENT_PACKAGES_DIR}) + + set(ENV{CFLAGS} "${VCPKG_COMBINED_C_FLAGS_RELEASE}") + set(ENV{CXXFLAGS} "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") + set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}") + set(ENV{ARFLAGS} "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_RELEASE}") + + message(STATUS "Configure ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_RELEASE}" "--openssldir=${OPENSSLDIR_RELEASE}" -FS + WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + LOGNAME configure-perl-${TARGET_TRIPLET}-rel ) - string(APPEND OPENSSL_ARCH "-UWP") + message(STATUS "Configure ${TARGET_TRIPLET}-rel done") + + message(STATUS "Build ${TARGET_TRIPLET}-rel") + # Openssl's buildsystem has a race condition which will cause JOM to fail at some point. + # This is ok; we just do as much work as we can in parallel first, then follow up with a single-threaded build. + make_directory(${SOURCE_PATH_RELEASE}/inc32/openssl) + execute_process( + COMMAND "${JOM}" -k -j "${VCPKG_CONCURRENCY}" -f "${OPENSSL_MAKEFILE}" + WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-out.log" + ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-err.log" + ) + vcpkg_execute_required_process( + COMMAND "${JOM}" -j 1 -f "${OPENSSL_MAKEFILE}" install_sw install_ssldirs + WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + LOGNAME build-${TARGET_TRIPLET}-rel-1) + + message(STATUS "Build ${TARGET_TRIPLET}-rel done") endif() -if(VCPKG_CONCURRENCY GREATER "1") - vcpkg_list(APPEND CONFIGURE_OPTIONS no-makedepend) -endif() -cmake_path(NATIVE_PATH CURRENT_PACKAGES_DIR NORMALIZE install_dir_native) - -vcpkg_cmake_get_vars(cmake_vars_file) -include("${cmake_vars_file}") - -# Clang always uses /Z7; Patching /Zi /Fd out of openssl requires more work. -set(OPENSSL_BUILD_MAKES_PDBS ON) -if (VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "Clang" OR VCPKG_LIBRARY_LINKAGE STREQUAL "static") - set(OPENSSL_BUILD_MAKES_PDBS OFF) -endif() - -cmake_path(NATIVE_PATH NASM NORMALIZE as) -cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_C_COMPILER NORMALIZE cc) -cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_AR NORMALIZE ar) -cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_LINKER NORMALIZE ld) - -vcpkg_build_nmake( - SOURCE_PATH "${SOURCE_PATH}" - PREFER_JOM - CL_LANGUAGE NONE - PRERUN_SHELL_RELEASE "${PERL}" Configure - ${CONFIGURE_OPTIONS} - ${OPENSSL_ARCH} - "--prefix=${install_dir_native}" - "--openssldir=${install_dir_native}" - "AS=${as}" - "CC=${cc}" - "CFLAGS=${VCPKG_COMBINED_C_FLAGS_RELEASE}" - "AR=${ar}" - "ARFLAGS=${VCPKG_COMBINED_STATIC_LINKER_FLAGS_RELEASE}" - "LD=${ld}" - "LDFLAGS=${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}" - PRERUN_SHELL_DEBUG "${PERL}" Configure - ${CONFIGURE_OPTIONS} - ${OPENSSL_ARCH} - --debug - "--prefix=${install_dir_native}\\debug" - "--openssldir=${install_dir_native}\\debug" - "AS=${as}" - "CC=${cc}" - "CFLAGS=${VCPKG_COMBINED_C_FLAGS_DEBUG}" - "AR=${ar}" - "ARFLAGS=${VCPKG_COMBINED_STATIC_LINKER_FLAGS_DEBUG}" - "LD=${ld}" - "LDFLAGS=${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}" - PROJECT_NAME "makefile" - TARGET install_dev install_modules ${INSTALL_FIPS} - LOGFILE_ROOT install - OPTIONS - "INSTALL_PDBS=${OPENSSL_BUILD_MAKES_PDBS}" # install-pdbs.patch - OPTIONS_RELEASE - install_runtime install_ssldirs # extra targets -) - -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") - if("fips" IN_LIST FEATURES) - file(RENAME "${CURRENT_PACKAGES_DIR}/fipsmodule.cnf" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/fipsmodule.cnf") - endif() - 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}") +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + # Copy openssl sources. + message(STATUS "Copying openssl debug source files...") + file(GLOB OPENSSL_SOURCE_FILES ${SOURCE_PATH}/*) + foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES}) + file(COPY ${SOURCE_FILE} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") endforeach() - vcpkg_copy_tools(TOOL_NAMES openssl AUTO_CLEAN) -else() - file(REMOVE "${CURRENT_PACKAGES_DIR}/openssl.cnf") - file(REMOVE "${CURRENT_PACKAGES_DIR}/fipsmodule.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() + message(STATUS "Copying openssl debug source files... done") + set(SOURCE_PATH_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + + set(OPENSSLDIR_DEBUG ${CURRENT_PACKAGES_DIR}/debug) + + set(ENV{CFLAGS} "${VCPKG_COMBINED_C_FLAGS_DEBUG}") + set(ENV{CXXFLAGS} "${VCPKG_COMBINED_CXX_FLAGS_DEBUG}") + set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}") + set(ENV{ARFLAGS} "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_DEBUG}") + + message(STATUS "Configure ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${CONFIGURE_COMMAND} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS + WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} + LOGNAME configure-perl-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Configure ${TARGET_TRIPLET}-dbg done") + + message(STATUS "Build ${TARGET_TRIPLET}-dbg") + make_directory("${SOURCE_PATH_DEBUG}/inc32/openssl") + execute_process( + COMMAND "${JOM}" -k -j "${VCPKG_CONCURRENCY}" -f "${OPENSSL_MAKEFILE}" + WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} + OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-out.log" + ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-err.log" + ) + vcpkg_execute_required_process( + COMMAND "${JOM}" -j 1 -f "${OPENSSL_MAKEFILE}" install_sw install_ssldirs + WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} + LOGNAME build-${TARGET_TRIPLET}-dbg-1) + + message(STATUS "Build ${TARGET_TRIPLET}-dbg done") + + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/ossl-modules/legacy.pdb" "${CURRENT_PACKAGES_DIR}/debug/bin/legacy.pdb") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/ossl-modules/legacy.pdb" "${CURRENT_PACKAGES_DIR}/bin/legacy.pdb") + endif() endif() -vcpkg_copy_pdbs() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/certs") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/private") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/engines-1_1") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/engines-3") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/certs") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/engines-1_1") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/engines-3") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/private") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + if(NOT VCPKG_BUILD_TYPE) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/ossl-modules/legacy.dll" "${CURRENT_PACKAGES_DIR}/debug/bin/legacy.dll") + endif() + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/ossl-modules/legacy.dll" "${CURRENT_PACKAGES_DIR}/bin/legacy.dll") +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/ossl-modules") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/ossl-modules") -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/certs" - "${CURRENT_PACKAGES_DIR}/misc" - "${CURRENT_PACKAGES_DIR}/private" - "${CURRENT_PACKAGES_DIR}/lib/engines-3" - "${CURRENT_PACKAGES_DIR}/debug/certs" - "${CURRENT_PACKAGES_DIR}/debug/misc" - "${CURRENT_PACKAGES_DIR}/debug/lib/engines-3" - "${CURRENT_PACKAGES_DIR}/debug/private" - "${CURRENT_PACKAGES_DIR}/debug/include" -) file(REMOVE "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf" "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf.dist" "${CURRENT_PACKAGES_DIR}/openssl.cnf.dist" + "${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe" "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf" "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf.dist" "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf" "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf.dist" - "${CURRENT_PACKAGES_DIR}/debug/fipsmodule.cnf" ) + +file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/openssl/") +file(RENAME "${CURRENT_PACKAGES_DIR}/bin/openssl.exe" "${CURRENT_PACKAGES_DIR}/tools/openssl/openssl.exe") +file(RENAME "${CURRENT_PACKAGES_DIR}/openssl.cnf" "${CURRENT_PACKAGES_DIR}/tools/openssl/openssl.cnf") + +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/openssl") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + # They should be empty, only the exes deleted above were in these directories + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin/") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin/") +endif() + +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/openssl/dtls1.h" + "" + "" +) + +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/openssl/rand.h" + "# include " + "#ifndef _WINSOCKAPI_\n#define _WINSOCKAPI_\n#endif\n# include " +) + +vcpkg_copy_pdbs() + +file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/ports/vcpkg-cmake-config/copyright b/cmake/ports/vcpkg-cmake-config/copyright new file mode 100644 index 0000000000..2e4eac8264 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-config/copyright @@ -0,0 +1,23 @@ +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/cmake/ports/vcpkg-cmake-config/portfile.cmake b/cmake/ports/vcpkg-cmake-config/portfile.cmake new file mode 100644 index 0000000000..fc3dbafd51 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-config/portfile.cmake @@ -0,0 +1,12 @@ +if(NOT TARGET_TRIPLET STREQUAL _HOST_TRIPLET) + # make FATAL_ERROR in CI when issue #16773 fixed + message(WARNING "vcpkg-cmake-config is a host-only port; please mark it as a host port in your dependencies.") +endif() + +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_config_fixup.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + "${CMAKE_CURRENT_LIST_DIR}/copyright" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake b/cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake new file mode 100644 index 0000000000..980d411315 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_config_fixup.cmake") diff --git a/cmake/ports/vcpkg-cmake-config/vcpkg.json b/cmake/ports/vcpkg-cmake-config/vcpkg.json new file mode 100644 index 0000000000..db965341a7 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-config/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "vcpkg-cmake-config", + "version-date": "2022-02-06", + "port-version": 1, + "documentation": "https://vcpkg.io/en/docs/README.html", + "license": "MIT" +} diff --git a/cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake b/cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake new file mode 100644 index 0000000000..368e5809ac --- /dev/null +++ b/cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake @@ -0,0 +1,258 @@ +include_guard(GLOBAL) + +function(vcpkg_cmake_config_fixup) + cmake_parse_arguments(PARSE_ARGV 0 "arg" "DO_NOT_DELETE_PARENT_CONFIG_PATH;NO_PREFIX_CORRECTION" "PACKAGE_NAME;CONFIG_PATH;TOOLS_PATH" "") + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vcpkg_cmake_config_fixup was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + if(NOT arg_PACKAGE_NAME) + set(arg_PACKAGE_NAME "${PORT}") + endif() + if(NOT arg_CONFIG_PATH) + set(arg_CONFIG_PATH "share/${arg_PACKAGE_NAME}") + endif() + if(NOT arg_TOOLS_PATH) + set(arg_TOOLS_PATH "tools/${PORT}") + endif() + set(target_path "share/${arg_PACKAGE_NAME}") + + string(REPLACE "." "\\." EXECUTABLE_SUFFIX "${VCPKG_TARGET_EXECUTABLE_SUFFIX}") + + set(debug_share "${CURRENT_PACKAGES_DIR}/debug/${target_path}") + set(release_share "${CURRENT_PACKAGES_DIR}/${target_path}") + + if(NOT arg_CONFIG_PATH STREQUAL "share/${arg_PACKAGE_NAME}") + if(arg_CONFIG_PATH STREQUAL "share") + set(arg_CONFIG_PATH z_vcpkg_share) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/debug/${arg_CONFIG_PATH}") + file(RENAME "${CURRENT_PACKAGES_DIR}/share" "${CURRENT_PACKAGES_DIR}/${arg_CONFIG_PATH}") + endif() + + set(debug_config "${CURRENT_PACKAGES_DIR}/debug/${arg_CONFIG_PATH}") + set(release_config "${CURRENT_PACKAGES_DIR}/${arg_CONFIG_PATH}") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + if(NOT EXISTS "${debug_config}") + message(FATAL_ERROR "'${debug_config}' does not exist.") + endif() + + # This roundabout handling enables CONFIG_PATH = share + file(MAKE_DIRECTORY "${debug_share}") + file(GLOB files "${debug_config}/*") + file(COPY ${files} DESTINATION "${debug_share}") + file(REMOVE_RECURSE "${debug_config}") + endif() + + file(GLOB files "${release_config}/*") + file(COPY ${files} DESTINATION "${release_share}") + file(REMOVE_RECURSE "${release_config}") + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + get_filename_component(debug_config_dir_name "${debug_config}" NAME) + string(TOLOWER "${debug_config_dir_name}" debug_config_dir_name) + if(debug_config_dir_name STREQUAL "cmake" AND NOT arg_DO_NOT_DELETE_PARENT_CONFIG_PATH) + file(REMOVE_RECURSE "${debug_config}") + else() + get_filename_component(debug_config_parent_dir "${debug_config}" DIRECTORY) + get_filename_component(debug_config_dir_name "${debug_config_parent_dir}" NAME) + string(TOLOWER "${debug_config_dir_name}" debug_config_dir_name) + if(debug_config_dir_name STREQUAL "cmake" AND NOT arg_DO_NOT_DELETE_PARENT_CONFIG_PATH) + file(REMOVE_RECURSE "${debug_config_parent_dir}") + endif() + endif() + endif() + + get_filename_component(release_config_dir_name "${release_config}" NAME) + string(TOLOWER "${release_config_dir_name}" release_config_dir_name) + if(release_config_dir_name STREQUAL "cmake" AND NOT arg_DO_NOT_DELETE_PARENT_CONFIG_PATH) + file(REMOVE_RECURSE "${release_config}") + else() + get_filename_component(release_config_parent_dir "${release_config}" DIRECTORY) + get_filename_component(release_config_dir_name "${release_config_parent_dir}" NAME) + string(TOLOWER "${release_config_dir_name}" release_config_dir_name) + if(release_config_dir_name STREQUAL "cmake" AND NOT arg_DO_NOT_DELETE_PARENT_CONFIG_PATH) + file(REMOVE_RECURSE "${release_config_parent_dir}") + endif() + endif() + endif() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + if(NOT EXISTS "${debug_share}") + message(FATAL_ERROR "'${debug_share}' does not exist.") + endif() + endif() + + file(GLOB_RECURSE release_targets + "${release_share}/*-release.cmake" + ) + foreach(release_target IN LISTS release_targets) + file(READ "${release_target}" contents) + string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" contents "${contents}") + string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+${EXECUTABLE_SUFFIX})" "\${_IMPORT_PREFIX}/${arg_TOOLS_PATH}/\\1" contents "${contents}") + file(WRITE "${release_target}" "${contents}") + endforeach() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(GLOB_RECURSE debug_targets + "${debug_share}/*-debug.cmake" + ) + foreach(debug_target IN LISTS debug_targets) + file(RELATIVE_PATH debug_target_rel "${debug_share}" "${debug_target}") + + file(READ "${debug_target}" contents) + string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" contents "${contents}") + string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \";]+${EXECUTABLE_SUFFIX})" "\${_IMPORT_PREFIX}/${arg_TOOLS_PATH}/\\1" contents "${contents}") + string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" contents "${contents}") + string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" contents "${contents}") + file(WRITE "${release_share}/${debug_target_rel}" "${contents}") + + file(REMOVE "${debug_target}") + endforeach() + endif() + + #Fix ${_IMPORT_PREFIX} and absolute paths in cmake generated targets and configs; + #Since those can be renamed we have to check in every *.cmake, but only once. + file(GLOB_RECURSE main_cmakes "${release_share}/*.cmake") + if(NOT DEFINED Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP) + vcpkg_list(SET Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP) + endif() + foreach(already_fixed_up IN LISTS Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP) + vcpkg_list(REMOVE_ITEM main_cmakes "${already_fixed_up}") + endforeach() + vcpkg_list(APPEND Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP ${main_cmakes}) + set(Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP "${Z_VCPKG_CMAKE_CONFIG_ALREADY_FIXED_UP}" CACHE INTERNAL "") + + foreach(main_cmake IN LISTS main_cmakes) + file(READ "${main_cmake}" contents) + # Note: I think the following comment is no longer true, since we now require the path to be `share/blah` + # however, I don't know it for sure. + # - nimazzuc + + #This correction is not correct for all cases. To make it correct for all cases it needs to consider + #original folder deepness to CURRENT_PACKAGES_DIR in comparison to the moved to folder deepness which + #is always at least (>=) 2, e.g. share/${PORT}. Currently the code assumes it is always 2 although + #this requirement is only true for the *Config.cmake. The targets are not required to be in the same + #folder as the *Config.cmake! + if(NOT arg_NO_PREFIX_CORRECTION) + string(REGEX REPLACE +[[get_filename_component\(_IMPORT_PREFIX "\${CMAKE_CURRENT_LIST_FILE}" PATH\)( +get_filename_component\(_IMPORT_PREFIX "\${_IMPORT_PREFIX}" PATH\))*]] +[[get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]] + contents "${contents}") # see #1044 for details why this replacement is necessary. See #4782 why it must be a regex. + string(REGEX REPLACE +[[get_filename_component\(PACKAGE_PREFIX_DIR "\${CMAKE_CURRENT_LIST_DIR}/\.\./(\.\./)*" ABSOLUTE\)]] +[[get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)]] + contents "${contents}") + string(REGEX REPLACE +[[get_filename_component\(PACKAGE_PREFIX_DIR "\${CMAKE_CURRENT_LIST_DIR}/\.\.((\\|/)\.\.)*" ABSOLUTE\)]] +[[get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)]] + contents "${contents}") # This is a meson-related workaround, see https://github.com/mesonbuild/meson/issues/6955 + endif() + + # Merge release and debug configurations of target property INTERFACE_LINK_LIBRARIES. + string(REPLACE "${release_share}/" "${debug_share}/" debug_cmake "${main_cmake}") + if(DEFINED VCPKG_BUILD_TYPE) + # Skip. Warning: A release-only port in a dual-config installation + # may pull release dependencies into the debug configuration. + elseif(NOT contents MATCHES "INTERFACE_LINK_LIBRARIES") + # Skip. No relevant properties. + elseif(NOT contents MATCHES "# Generated CMake target import file\\.") + # Skip. No safe assumptions about a matching debug import file. + elseif(NOT EXISTS "${debug_cmake}") + message(SEND_ERROR "Did not find a debug import file matching '${main_cmake}'") + else() + file(READ "${debug_cmake}" debug_contents) + while(contents MATCHES "set_target_properties\\(([^ \$]*) PROPERTIES[^)]*\\)") + set(matched_command "${CMAKE_MATCH_0}") + string(REPLACE "+" "\\+" target "${CMAKE_MATCH_1}") + if(NOT debug_contents MATCHES "set_target_properties\\(${target} PROPERTIES[^)]*\\)") + message(SEND_ERROR "Did not find a debug configuration for target '${target}'.") + endif() + set(debug_command "${CMAKE_MATCH_0}") + string(REGEX MATCH " INTERFACE_LINK_LIBRARIES \"([^\"]*)\"" release_line "${matched_command}") + set(release_libs "${CMAKE_MATCH_1}") + string(REGEX MATCH " INTERFACE_LINK_LIBRARIES \"([^\"]*)\"" debug_line "${debug_command}") + set(debug_libs "${CMAKE_MATCH_1}") + z_vcpkg_cmake_config_fixup_merge(merged_libs release_libs debug_libs) + string(REPLACE "${release_line}" " INTERFACE_LINK_LIBRARIES \"${merged_libs}\"" updated_command "${matched_command}") + string(REPLACE "set_target_properties" "set_target_properties::done" updated_command "${updated_command}") # Prevend 2nd match + string(REPLACE "${matched_command}" "${updated_command}" contents "${contents}") + endwhile() + string(REPLACE "set_target_properties::done" "set_target_properties" contents "${contents}") # Restore original command + endif() + + #Fix absolute paths to installed dir with ones relative to ${CMAKE_CURRENT_LIST_DIR} + #This happens if vcpkg built libraries are directly linked to a target instead of using + #an imported target. + string(REPLACE "${CURRENT_INSTALLED_DIR}" [[${VCPKG_IMPORT_PREFIX}]] contents "${contents}") + file(TO_CMAKE_PATH "${CURRENT_PACKAGES_DIR}" cmake_current_packages_dir) + string(REPLACE "${cmake_current_packages_dir}" [[${VCPKG_IMPORT_PREFIX}]] contents "${contents}") + # If ${VCPKG_IMPORT_PREFIX} was actually used, inject a definition of it: + string(FIND "${contents}" [[${VCPKG_IMPORT_PREFIX}]] index) + if (NOT index STREQUAL "-1") + get_filename_component(main_cmake_dir "${main_cmake}" DIRECTORY) + # Calculate relative to be a sequence of "../" + file(RELATIVE_PATH relative "${main_cmake_dir}" "${cmake_current_packages_dir}") + string(PREPEND contents "get_filename_component(VCPKG_IMPORT_PREFIX \"\${CMAKE_CURRENT_LIST_DIR}\/${relative}\" ABSOLUTE)\n") + endif() + + file(WRITE "${main_cmake}" "${contents}") + endforeach() + + file(GLOB_RECURSE unused_files + "${debug_share}/*[Tt]argets.cmake" + "${debug_share}/*[Cc]onfig.cmake" + "${debug_share}/*[Cc]onfigVersion.cmake" + "${debug_share}/*[Cc]onfig-version.cmake" + ) + foreach(unused_file IN LISTS unused_files) + file(REMOVE "${unused_file}") + endforeach() + + # Remove /debug// if it's empty. + file(GLOB_RECURSE remaining_files "${debug_share}/*") + if(remaining_files STREQUAL "") + file(REMOVE_RECURSE "${debug_share}") + endif() + + # Remove /debug/share/ if it's empty. + file(GLOB_RECURSE remaining_files "${CURRENT_PACKAGES_DIR}/debug/share/*") + if(remaining_files STREQUAL "") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + endif() +endfunction() + +# Merges link interface library lists for release and debug +# into a single expression which use generator expression as necessary. +function(z_vcpkg_cmake_config_fixup_merge out_var release_var debug_var) + set(release_libs "VCPKG;${${release_var}}") + string(REGEX REPLACE ";optimized;([^;]*)" ";\\1" release_libs "${release_libs}") + string(REGEX REPLACE ";debug;([^;]*)" ";" release_libs "${release_libs}") + list(REMOVE_AT release_libs 0) + list(FILTER release_libs EXCLUDE REGEX [[^\\[$]<\\[$]:]]) + list(TRANSFORM release_libs REPLACE [[^\\[$]<\\[$]>:(.*)>$]] "\\1") + + set(debug_libs "VCPKG;${${debug_var}}") + string(REGEX REPLACE ";optimized;([^;]*)" ";" debug_libs "${debug_libs}") + string(REGEX REPLACE ";debug;([^;]*)" ";\\1" debug_libs "${debug_libs}") + list(REMOVE_AT debug_libs 0) + list(FILTER debug_libs EXCLUDE REGEX [[^\\[$]<\\[$]>:]]) + list(TRANSFORM debug_libs REPLACE [[^\\[$]<\\[$]:(.*)>$]] "\\1") + + set(merged_libs "") + foreach(release_lib debug_lib IN ZIP_LISTS release_libs debug_libs) + if(release_lib STREQUAL debug_lib) + list(APPEND merged_libs "${release_lib}") + else() + if(release_lib) + list(APPEND merged_libs "\\\$<\\\$>:${release_lib}>") + endif() + if(debug_lib) + list(APPEND merged_libs "\\\$<\\\$:${debug_lib}>") + endif() + endif() + endforeach() + set("${out_var}" "${merged_libs}" PARENT_SCOPE) +endfunction() diff --git a/cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt b/cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt new file mode 100644 index 0000000000..1b95a70ca8 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt @@ -0,0 +1,204 @@ +cmake_minimum_required(VERSION 3.20) + +set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project") + +set(OUTPUT_STRING) +# Build default checklists +list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING + CMAKE_SYSTEM_NAME + CMAKE_HOST_SYSTEM_NAME + CMAKE_SYSTEM_PROCESSOR + CMAKE_HOST_SYSTEM_PROCESSOR + CMAKE_SIZEOF_VOID_P + MSVC + MSVC_VERSION) +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET + CMAKE_OSX_SYSROOT) +endif() +# Programs to check +set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER) +foreach(prog IN LISTS PROGLIST) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}) +endforeach() +set(COMPILERS ${VCPKG_LANGUAGES} RC) +foreach(prog IN LISTS COMPILERS) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER_ID) +endforeach() +# Variables to check +foreach(_lang IN LISTS VCPKG_LANGUAGES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_INCLUDE_DIRECTORIES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_LIBRARIES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILE_FEATURES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_EXTENSION) + # Probably never required since implicit. + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_LIBRARIES) +endforeach() +list(REMOVE_DUPLICATES VCPKG_DEFAULT_VARS_TO_CHECK) + +# Environment variables to check. +list(APPEND VCPKG_DEFAULT_ENV_VARS_TO_CHECK PATH INCLUDE C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) +list(REMOVE_DUPLICATES VCPKG_DEFAULT_ENV_VARS_TO_CHECK) + +#Flags to check. Flags are a bit special since they are configuration aware. +set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER) +foreach(flag IN LISTS FLAGS) + list(APPEND VCPKG_DEFAULT_FLAGS_TO_CHECK CMAKE_${flag}_FLAGS) +endforeach() +list(REMOVE_DUPLICATES VCPKG_DEFAULT_FLAGS_TO_CHECK) + +#Language-specific flags. +foreach(_lang IN LISTS VCPKG_LANGUAGES) + list(APPEND VCPKG_LANG_FLAGS CMAKE_${_lang}_FLAGS) +endforeach() +list(REMOVE_DUPLICATES VCPKG_LANG_FLAGS) + +# TODO if ever necessary: Properties to check + +set(VCPKG_VAR_PREFIX "VCPKG_DETECTED" CACHE STRING "Variable prefix to use for detected flags") +set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") +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") +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") + else() + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"$ENV{${_env}}\")\n") + endif() +endforeach() + +set(EXTRA_FLAGS "") + +if(APPLE) + if(CMAKE_OSX_SYSROOT) + string(APPEND EXTRA_FLAGS " -isysroot \"${CMAKE_OSX_SYSROOT}\"") + endif() + foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES) + string(APPEND EXTRA_FLAGS " -arch ${arch}") + endforeach() + if(CMAKE_OSX_DEPLOYMENT_TARGET) + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + string(APPEND EXTRA_FLAGS " -mios-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + string(APPEND EXTRA_FLAGS " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() + endif() +endif() +if(CMAKE_CXX_COMPILER_TARGET) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + string(APPEND EXTRA_FLAGS " \"${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}\"") + elseif(CMAKE_CXX_COMPILE_OPTIONS_TARGET) + string(APPEND EXTRA_FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_TARGET} \"${CMAKE_CXX_COMPILER_TARGET}\"") + endif() +endif() +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() + +foreach(flags CXX C SHARED_LINKER EXE_LINKER) + set(${flags}_FLAGS "${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}} ${EXTRA_FLAGS}") +endforeach() + +foreach(flags STATIC_LINKER RC) + set(${flags}_FLAGS "${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}}") +endforeach() + +foreach(incdir IN LISTS CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES) + string(APPEND CXX_FLAGS " \"${CMAKE_INCLUDE_FLAG_CXX}${incdir}\"") +endforeach() + +foreach(incdir IN LISTS CMAKE_C_STANDARD_INCLUDE_DIRECTORIES) + string(APPEND C_FLAGS " \"${CMAKE_INCLUDE_FLAG_C}${incdir}\"") +endforeach() + +foreach(flag CXX C SHARED_LINKER EXE_LINKER STATIC_LINKER RC) + # When using MSVC, maybe transform /flags to -flags. + # When cross compiling, "/flags" may be an absolute path starting with /, so don't transform. + # Otherwise, transform to improve compatibility with scripts interpreting "/flags" as a path. + if(MSVC AND "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Windows") + # This implementation is imperfect because it fails on directories with trailing spaces, + # but those are rare. + string(REGEX REPLACE "(^| )/" "\\1-" ${flag}_FLAGS "${${flag}_FLAGS}") + if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + if("${flag}" STREQUAL "CXX") + string(APPEND ${flag}_FLAGS " -ZW:nostdlib") + 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") +endforeach() + +file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") + +# Programs: +# CMAKE_AR +# CMAKE__COMPILER_AR (Wrapper) +# CMAKE_RANLIB +# CMAKE__COMPILER_RANLIB +# CMAKE_STRIP +# CMAKE_NM +# CMAKE_OBJDUMP +# CMAKE_DLLTOOL +# CMAKE_MT +# CMAKE_LINKER +# CMAKE_C_COMPILER +# CMAKE_CXX_COMPILER +# CMAKE_RC_COMPILER + +# Program details: +# CMAKE__COMPILER_ID +# MSVC +# MSVC_VERSION + +# Flags: +# CMAKE__FLAGS +# CMAKE__FLAGS_ +# CMAKE_RC_FLAGS +# CMAKE_SHARED_LINKER_FLAGS +# CMAKE_SHARED_LINKER_FLAGS_ +# CMAKE_STATIC_LINKER_FLAGS +# CMAKE_STATIC_LINKER_FLAGS_ +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS_ + +# Additional information: +# CMAKE_SIZEOF_VOID_P +# CMAKE_CROSSCOMPILING +# CMAKE_SYSTEM_NAME +# CMAKE_HOST_SYSTEM_NAME +# CMAKE_SYSTEM_PROCESSOR +# CMAKE_HOST_SYSTEM_PROCESSOR diff --git a/cmake/ports/vcpkg-cmake-get-vars/portfile.cmake b/cmake/ports/vcpkg-cmake-get-vars/portfile.cmake new file mode 100644 index 0000000000..4f3183adfd --- /dev/null +++ b/cmake/ports/vcpkg-cmake-get-vars/portfile.cmake @@ -0,0 +1,14 @@ +if(VCPKG_CROSSCOMPILING) + # make FATAL_ERROR in CI when issue #16773 fixed + message(WARNING "vcpkg-cmake-get-vars is a host-only port; please mark it as a host port in your dependencies.") +endif() + +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_get_vars.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_get_vars" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +file(INSTALL "${VCPKG_ROOT_DIR}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled) + diff --git a/cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake b/cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake new file mode 100644 index 0000000000..d5b5c2b1ca --- /dev/null +++ b/cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake @@ -0,0 +1,2 @@ +include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-cmake/vcpkg-port-config.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_get_vars.cmake") diff --git a/cmake/ports/vcpkg-cmake-get-vars/vcpkg.json b/cmake/ports/vcpkg-cmake-get-vars/vcpkg.json new file mode 100644 index 0000000000..33b5478822 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-get-vars/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "vcpkg-cmake-get-vars", + "version-date": "2022-05-10", + "port-version": 1, + "documentation": "https://vcpkg.io/en/docs/README.html", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake b/cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake new file mode 100644 index 0000000000..8ce706bdf9 --- /dev/null +++ b/cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake @@ -0,0 +1,34 @@ +include_guard(GLOBAL) + +set(Z_VCPKG_CMAKE_GET_VARS_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "") + +function(vcpkg_cmake_get_vars out_file) + cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "") + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED CACHE{Z_VCPKG_CMAKE_GET_VARS_FILE}) + set(Z_VCPKG_CMAKE_GET_VARS_FILE "${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}.cmake.log" + CACHE PATH "The file to include to access the CMake variables from a generated project.") + vcpkg_cmake_configure( + SOURCE_PATH "${Z_VCPKG_CMAKE_GET_VARS_CURRENT_LIST_DIR}/cmake_get_vars" + OPTIONS_DEBUG "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}-dbg.cmake.log" + OPTIONS_RELEASE "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}-rel.cmake.log" + LOGFILE_BASE cmake-get-vars-${TARGET_TRIPLET} + Z_CMAKE_GET_VARS_USAGE # be quiet, don't set variables... + ) + + set(include_string "") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-get-vars-${TARGET_TRIPLET}-rel.cmake.log\")\n") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-get-vars-${TARGET_TRIPLET}-dbg.cmake.log\")\n") + endif() + file(WRITE "${Z_VCPKG_CMAKE_GET_VARS_FILE}" "${include_string}") + endif() + + set("${out_file}" "${Z_VCPKG_CMAKE_GET_VARS_FILE}" PARENT_SCOPE) +endfunction() diff --git a/cmake/ports/vcpkg-cmake/portfile.cmake b/cmake/ports/vcpkg-cmake/portfile.cmake new file mode 100644 index 0000000000..0b7dd50201 --- /dev/null +++ b/cmake/ports/vcpkg-cmake/portfile.cmake @@ -0,0 +1,14 @@ +if(VCPKG_CROSSCOMPILING) + # make FATAL_ERROR in CI when issue #16773 fixed + message(WARNING "vcpkg-cmake is a host-only port; please mark it as a host port in your dependencies.") +endif() + +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_configure.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_build.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_install.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +file(INSTALL "${VCPKG_ROOT_DIR}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled) diff --git a/cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake b/cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake new file mode 100644 index 0000000000..f2a973d4eb --- /dev/null +++ b/cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake @@ -0,0 +1,3 @@ +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_configure.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_build.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_install.cmake") diff --git a/cmake/ports/vcpkg-cmake/vcpkg.json b/cmake/ports/vcpkg-cmake/vcpkg.json new file mode 100644 index 0000000000..bf449abfa0 --- /dev/null +++ b/cmake/ports/vcpkg-cmake/vcpkg.json @@ -0,0 +1,6 @@ +{ + "name": "vcpkg-cmake", + "version-date": "2022-07-02", + "documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-cmake.html", + "license": "MIT" +} diff --git a/cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake b/cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake new file mode 100644 index 0000000000..efdb194fa1 --- /dev/null +++ b/cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake @@ -0,0 +1,91 @@ +include_guard(GLOBAL) + +function(vcpkg_cmake_build) + cmake_parse_arguments(PARSE_ARGV 0 "arg" "DISABLE_PARALLEL;ADD_BIN_TO_PATH" "TARGET;LOGFILE_BASE" "") + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vcpkg_cmake_build was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + if(NOT DEFINED arg_LOGFILE_BASE) + set(arg_LOGFILE_BASE "build") + endif() + vcpkg_list(SET build_param) + vcpkg_list(SET parallel_param) + vcpkg_list(SET no_parallel_param) + + if("${Z_VCPKG_CMAKE_GENERATOR}" STREQUAL "Ninja") + vcpkg_list(SET build_param "-v") # verbose output + vcpkg_list(SET parallel_param "-j${VCPKG_CONCURRENCY}") + vcpkg_list(SET no_parallel_param "-j1") + elseif("${Z_VCPKG_CMAKE_GENERATOR}" MATCHES "^Visual Studio") + vcpkg_list(SET build_param + "/p:VCPkgLocalAppDataDisabled=true" + "/p:UseIntelMKL=No" + ) + vcpkg_list(SET parallel_param "/m") + elseif("${Z_VCPKG_CMAKE_GENERATOR}" STREQUAL "NMake Makefiles") + # No options are currently added for nmake builds + elseif(Z_VCPKG_CMAKE_GENERATOR STREQUAL "Unix Makefiles") + vcpkg_list(SET build_args "VERBOSE=1") + vcpkg_list(SET parallel_args "-j${VCPKG_CONCURRENCY}") + vcpkg_list(SET no_parallel_args "") + elseif(Z_VCPKG_CMAKE_GENERATOR STREQUAL "Xcode") + vcpkg_list(SET parallel_args -jobs "${VCPKG_CONCURRENCY}") + vcpkg_list(SET no_parallel_args -jobs 1) + else() + message(WARNING "Unrecognized GENERATOR setting from vcpkg_cmake_configure().") + endif() + + vcpkg_list(SET target_param) + if(arg_TARGET) + vcpkg_list(SET target_param "--target" "${arg_TARGET}") + endif() + + foreach(build_type IN ITEMS debug release) + if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "${build_type}") + if("${build_type}" STREQUAL "debug") + set(short_build_type "dbg") + set(config "Debug") + else() + set(short_build_type "rel") + set(config "Release") + endif() + + message(STATUS "Building ${TARGET_TRIPLET}-${short_build_type}") + + if(arg_ADD_BIN_TO_PATH) + vcpkg_backup_env_variables(VARS PATH) + if("${build_type}" STREQUAL "debug") + vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin") + else() + vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin") + endif() + endif() + + if(arg_DISABLE_PARALLEL) + vcpkg_execute_build_process( + COMMAND + "${CMAKE_COMMAND}" --build . --config "${config}" ${target_param} + -- ${build_param} ${no_parallel_param} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_build_type}" + LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}-${short_build_type}" + ) + else() + vcpkg_execute_build_process( + COMMAND + "${CMAKE_COMMAND}" --build . --config "${config}" ${target_param} + -- ${build_param} ${parallel_param} + NO_PARALLEL_COMMAND + "${CMAKE_COMMAND}" --build . --config "${config}" ${target_param} + -- ${build_param} ${no_parallel_param} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_build_type}" + LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}-${short_build_type}" + ) + endif() + + if(arg_ADD_BIN_TO_PATH) + vcpkg_restore_env_variables(VARS PATH) + endif() + endif() + endforeach() +endfunction() diff --git a/cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake b/cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake new file mode 100644 index 0000000000..37b29d6725 --- /dev/null +++ b/cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake @@ -0,0 +1,311 @@ +include_guard(GLOBAL) + +macro(z_vcpkg_cmake_configure_both_set_or_unset var1 var2) + if(DEFINED ${var1} AND NOT DEFINED ${var2}) + message(FATAL_ERROR "If ${var1} is set, then ${var2} must be set.") + elseif(NOT DEFINED ${var1} AND DEFINED ${var2}) + message(FATAL_ERROR "If ${var2} is set, then ${var1} must be set.") + endif() +endmacro() + +function(vcpkg_cmake_configure) + cmake_parse_arguments(PARSE_ARGV 0 "arg" + "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;WINDOWS_USE_MSBUILD;NO_CHARSET_FLAG;Z_CMAKE_GET_VARS_USAGE" + "SOURCE_PATH;GENERATOR;LOGFILE_BASE" + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES" + ) + + if(NOT arg_Z_CMAKE_GET_VARS_USAGE AND DEFINED CACHE{Z_VCPKG_CMAKE_GENERATOR}) + message(WARNING "${CMAKE_CURRENT_FUNCTION} already called; this function should only be called once.") + endif() + if(arg_PREFER_NINJA) + message(WARNING "PREFER_NINJA has been deprecated in ${CMAKE_CURRENT_FUNCTION}. Please remove it from the portfile!") + endif() + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED arg_SOURCE_PATH) + message(FATAL_ERROR "SOURCE_PATH must be set") + endif() + if(NOT DEFINED arg_LOGFILE_BASE) + set(arg_LOGFILE_BASE "config-${TARGET_TRIPLET}") + endif() + + set(manually_specified_variables "") + + if(arg_Z_CMAKE_GET_VARS_USAGE) + set(configuring_message "Getting CMake variables for ${TARGET_TRIPLET}") + else() + set(configuring_message "Configuring ${TARGET_TRIPLET}") + + foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG) + if("${option}" MATCHES "^-D([^:=]*)[:=]") + vcpkg_list(APPEND manually_specified_variables "${CMAKE_MATCH_1}") + endif() + endforeach() + vcpkg_list(REMOVE_DUPLICATES manually_specified_variables) + foreach(maybe_unused_var IN LISTS arg_MAYBE_UNUSED_VARIABLES) + vcpkg_list(REMOVE_ITEM manually_specified_variables "${maybe_unused_var}") + endforeach() + debug_message("manually specified variables: ${manually_specified_variables}") + endif() + + if(CMAKE_HOST_WIN32) + if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) + set(host_architecture "$ENV{PROCESSOR_ARCHITEW6432}") + else() + set(host_architecture "$ENV{PROCESSOR_ARCHITECTURE}") + endif() + endif() + + set(ninja_can_be_used ON) # Ninja as generator + set(ninja_host ON) # Ninja as parallel configurator + + if(host_architecture STREQUAL "x86") + # Prebuilt ninja binaries are only provided for x64 hosts + set(ninja_can_be_used OFF) + set(ninja_host OFF) + endif() + + set(generator "Ninja") + if(DEFINED arg_GENERATOR) + set(generator "${arg_GENERATOR}") + elseif(arg_WINDOWS_USE_MSBUILD OR NOT ninja_can_be_used) + set(generator "") + set(arch "") + z_vcpkg_get_visual_studio_generator(OUT_GENERATOR generator OUT_ARCH arch) + endif() + + if(NOT generator) + if(NOT VCPKG_CMAKE_SYSTEM_NAME) + set(VCPKG_CMAKE_SYSTEM_NAME "Windows") + endif() + message(FATAL_ERROR "Unable to determine appropriate generator for: " + "${VCPKG_CMAKE_SYSTEM_NAME}-${VCPKG_TARGET_ARCHITECTURE}-${VCPKG_PLATFORM_TOOLSET}") + endif() + + # If we use Ninja, make sure it's on PATH + if(generator STREQUAL "Ninja" AND NOT DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES}) + vcpkg_find_acquire_program(NINJA) + get_filename_component(ninja_path "${NINJA}" DIRECTORY) + vcpkg_add_to_path("${ninja_path}") + vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}") + endif() + + set(build_dir_release "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + set(build_dir_debug "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + file(REMOVE_RECURSE + "${build_dir_release}" + "${build_dir_debug}") + file(MAKE_DIRECTORY "${build_dir_release}") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(MAKE_DIRECTORY "${build_dir_debug}") + endif() + + if(DEFINED VCPKG_CMAKE_SYSTEM_NAME) + vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}") + if(VCPKG_TARGET_IS_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + set(VCPKG_CMAKE_SYSTEM_VERSION 10.0) + elseif(VCPKG_TARGET_IS_ANDROID AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + set(VCPKG_CMAKE_SYSTEM_VERSION 21) + endif() + endif() + + if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}") + endif() + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_list(APPEND arg_OPTIONS "-DBUILD_SHARED_LIBS=ON") + elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_list(APPEND arg_OPTIONS "-DBUILD_SHARED_LIBS=OFF") + else() + message(FATAL_ERROR + "Invalid setting for VCPKG_LIBRARY_LINKAGE: \"${VCPKG_LIBRARY_LINKAGE}\". " + "It must be \"static\" or \"dynamic\"") + endif() + + z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS_DEBUG VCPKG_C_FLAGS_DEBUG) + z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS_RELEASE VCPKG_C_FLAGS_RELEASE) + z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS VCPKG_C_FLAGS) + + set(VCPKG_SET_CHARSET_FLAG ON) + if(arg_NO_CHARSET_FLAG) + set(VCPKG_SET_CHARSET_FLAG OFF) + endif() + + if(NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE) + z_vcpkg_select_default_vcpkg_chainload_toolchain() + endif() + + list(JOIN VCPKG_TARGET_ARCHITECTURE "\;" target_architecture_string) + vcpkg_list(APPEND arg_OPTIONS + "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" + "-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}" + "-DVCPKG_SET_CHARSET_FLAG=${VCPKG_SET_CHARSET_FLAG}" + "-DVCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}" + "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" + "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" + "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" + "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DVCPKG_APPLOCAL_DEPS=OFF" + "-DCMAKE_TOOLCHAIN_FILE=${SCRIPTS}/buildsystems/vcpkg.cmake" + "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" + "-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}" + "-DVCPKG_CXX_FLAGS_RELEASE=${VCPKG_CXX_FLAGS_RELEASE}" + "-DVCPKG_CXX_FLAGS_DEBUG=${VCPKG_CXX_FLAGS_DEBUG}" + "-DVCPKG_C_FLAGS=${VCPKG_C_FLAGS}" + "-DVCPKG_C_FLAGS_RELEASE=${VCPKG_C_FLAGS_RELEASE}" + "-DVCPKG_C_FLAGS_DEBUG=${VCPKG_C_FLAGS_DEBUG}" + "-DVCPKG_CRT_LINKAGE=${VCPKG_CRT_LINKAGE}" + "-DVCPKG_LINKER_FLAGS=${VCPKG_LINKER_FLAGS}" + "-DVCPKG_LINKER_FLAGS_RELEASE=${VCPKG_LINKER_FLAGS_RELEASE}" + "-DVCPKG_LINKER_FLAGS_DEBUG=${VCPKG_LINKER_FLAGS_DEBUG}" + "-DVCPKG_TARGET_ARCHITECTURE=${target_architecture_string}" + "-DCMAKE_INSTALL_LIBDIR:STRING=lib" + "-DCMAKE_INSTALL_BINDIR:STRING=bin" + "-D_VCPKG_ROOT_DIR=${VCPKG_ROOT_DIR}" + "-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}" + "-DVCPKG_MANIFEST_INSTALL=OFF" + ) + + if(DEFINED arch AND NOT arch STREQUAL "") + vcpkg_list(APPEND arg_OPTIONS "-A${arch}") + endif() + + # Sets configuration variables for macOS builds + foreach(config_var IN ITEMS INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES) + if(DEFINED VCPKG_${config_var}) + vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_${config_var}=${VCPKG_${config_var}}") + endif() + endforeach() + + # Allow overrides / additional configuration variables from triplets + if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS) + vcpkg_list(APPEND arg_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS}) + endif() + if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE) + vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE}) + endif() + if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG) + vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG}) + endif() + + vcpkg_list(SET rel_command + "${CMAKE_COMMAND}" "${arg_SOURCE_PATH}" + -G "${generator}" + "-DCMAKE_BUILD_TYPE=Release" + "-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}" + ${arg_OPTIONS} ${arg_OPTIONS_RELEASE}) + vcpkg_list(SET dbg_command + "${CMAKE_COMMAND}" "${arg_SOURCE_PATH}" + -G "${generator}" + "-DCMAKE_BUILD_TYPE=Debug" + "-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug" + ${arg_OPTIONS} ${arg_OPTIONS_DEBUG}) + + if(ninja_host AND CMAKE_HOST_WIN32 AND NOT arg_DISABLE_PARALLEL_CONFIGURE) + vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON") + + vcpkg_find_acquire_program(NINJA) + if(NOT DEFINED ninja_path) + # if ninja_path was defined above, we've already done this + get_filename_component(ninja_path "${NINJA}" DIRECTORY) + vcpkg_add_to_path("${ninja_path}") + endif() + + #parallelize the configure step + set(ninja_configure_contents + "rule CreateProcess\n command = \$process\n\n" + ) + + if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release") + z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents ".." "rel") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug") + z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents "../../${TARGET_TRIPLET}-dbg" "dbg") + endif() + + file(MAKE_DIRECTORY "${build_dir_release}/vcpkg-parallel-configure") + file(WRITE + "${build_dir_release}/vcpkg-parallel-configure/build.ninja" + "${ninja_configure_contents}") + + message(STATUS "${configuring_message}") + vcpkg_execute_required_process( + COMMAND "${NINJA}" -v + WORKING_DIRECTORY "${build_dir_release}/vcpkg-parallel-configure" + LOGNAME "${arg_LOGFILE_BASE}" + SAVE_LOG_FILES ../../${TARGET_TRIPLET}-dbg/CMakeCache.txt ../CMakeCache.txt + ) + + vcpkg_list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-out.log" + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-err.log") + else() + if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug") + message(STATUS "${configuring_message}-dbg") + vcpkg_execute_required_process( + COMMAND ${dbg_command} + WORKING_DIRECTORY "${build_dir_debug}" + LOGNAME "${arg_LOGFILE_BASE}-dbg" + SAVE_LOG_FILES CMakeCache.txt + ) + vcpkg_list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-out.log" + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-err.log") + endif() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release") + message(STATUS "${configuring_message}-rel") + vcpkg_execute_required_process( + COMMAND ${rel_command} + WORKING_DIRECTORY "${build_dir_release}" + LOGNAME "${arg_LOGFILE_BASE}-rel" + SAVE_LOG_FILES CMakeCache.txt + ) + vcpkg_list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-out.log" + "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-err.log") + endif() + endif() + + set(all_unused_variables) + foreach(config_log IN LISTS config_logs) + if(NOT EXISTS "${config_log}") + continue() + endif() + file(READ "${config_log}" log_contents) + debug_message("Reading configure log ${config_log}...") + if(NOT log_contents MATCHES "Manually-specified variables were not used by the project:\n\n(( [^\n]*\n)*)") + continue() + endif() + string(STRIP "${CMAKE_MATCH_1}" unused_variables) # remove leading ` ` and trailing `\n` + string(REPLACE "\n " ";" unused_variables "${unused_variables}") + debug_message("unused variables: ${unused_variables}") + foreach(unused_variable IN LISTS unused_variables) + if(unused_variable IN_LIST manually_specified_variables) + debug_message("manually specified unused variable: ${unused_variable}") + vcpkg_list(APPEND all_unused_variables "${unused_variable}") + else() + debug_message("unused variable (not manually specified): ${unused_variable}") + endif() + endforeach() + endforeach() + + if(DEFINED all_unused_variables) + vcpkg_list(REMOVE_DUPLICATES all_unused_variables) + vcpkg_list(JOIN all_unused_variables "\n " all_unused_variables) + message(WARNING "The following variables are not used in CMakeLists.txt: + ${all_unused_variables} +Please recheck them and remove the unnecessary options from the `vcpkg_cmake_configure` call. +If these options should still be passed for whatever reason, please use the `MAYBE_UNUSED_VARIABLES` argument.") + endif() + + if(NOT arg_Z_CMAKE_GET_VARS_USAGE) + set(Z_VCPKG_CMAKE_GENERATOR "${generator}" CACHE INTERNAL "The generator which was used to configure CMake.") + endif() +endfunction() diff --git a/cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake b/cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake new file mode 100644 index 0000000000..2bd8b4ea75 --- /dev/null +++ b/cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake @@ -0,0 +1,21 @@ +include_guard(GLOBAL) + +function(vcpkg_cmake_install) + cmake_parse_arguments(PARSE_ARGV 0 "arg" "DISABLE_PARALLEL;ADD_BIN_TO_PATH" "" "") + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vcpkg_cmake_install was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + set(args) + foreach(arg IN ITEMS DISABLE_PARALLEL ADD_BIN_TO_PATH) + if(arg_${arg}) + list(APPEND args "${arg}") + endif() + endforeach() + + vcpkg_cmake_build( + ${args} + LOGFILE_BASE install + TARGET install + ) +endfunction() diff --git a/hifi_qt.py b/hifi_qt.py index f163bf6d46..f22d8099ef 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -139,7 +139,7 @@ endif() return if 'Windows' == system: - self.qtUrl = self.assets_url + '/dependencies/qt5/qt5-install-5.15.5-qtwebengine-5.15.11-2022.08.01-kde_9480de754ec97f4b63c2b5176672903f80e3f22ff59d3acf0ddd8c68f58c1ed8-windows-x86_64.tar.xz' + self.qtUrl = self.assets_url + '/dependencies/qt5/qt5-install-5.15.10-qtwebengine-5.15.15-2023.06.17-kde1742cc4f85f1b57c5f8ef51d62ff0b958f38912de57a9094aa3a3e3bf35ae6cb-windows-x86_64.tar.xz' elif 'Darwin' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: