mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 19:22:16 +02:00
commit
3433596330
42 changed files with 1932 additions and 466 deletions
|
@ -20,13 +20,13 @@ macro(manually_install_openssl_for_qt)
|
|||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
install(
|
||||
FILES "${VCPKG_INSTALL_ROOT}/bin/libcrypto-1_1-x64.dll"
|
||||
FILES "${VCPKG_INSTALL_ROOT}/bin/libcrypto-3-x64.dll"
|
||||
DESTINATION ${TARGET_INSTALL_DIR}
|
||||
COMPONENT ${TARGET_INSTALL_COMPONENT}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${VCPKG_INSTALL_ROOT}/bin/libssl-1_1-x64.dll"
|
||||
FILES "${VCPKG_INSTALL_ROOT}/bin/libssl-3-x64.dll"
|
||||
DESTINATION ${TARGET_INSTALL_DIR}
|
||||
COMPONENT ${TARGET_INSTALL_COMPONENT}
|
||||
)
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
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")
|
||||
set(PLATFORM android)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
set(PLATFORM linux-generic64)
|
||||
else()
|
||||
set(PLATFORM linux-generic32)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(PLATFORM darwin64-x86_64-cc)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
set(PLATFORM BSD-generic64)
|
||||
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_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}")
|
||||
|
||||
set(CFLAGS "${CMAKE_C_FLAGS}")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CFLAGS "-Wno-error=unused-command-line-argument ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_TARGET)
|
||||
set(CFLAGS "${CFLAGS} ${CMAKE_C_COMPILE_OPTIONS_TARGET}${CMAKE_C_COMPILER_TARGET}")
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_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()
|
||||
|
||||
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")
|
||||
set(ENV{CC} "${CMAKE_C_COMPILER}")
|
||||
|
||||
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)
|
||||
|
||||
|
||||
file(READ "${BUILDDIR}/Configure" _contents)
|
||||
string(REPLACE "-mandroid" "" _contents "${_contents}")
|
||||
file(WRITE "${BUILDDIR}/Configure" "${_contents}")
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(SHARED shared)
|
||||
file(STRINGS "${BUILDDIR}/crypto/opensslv.h" SHLIB_VERSION
|
||||
REGEX "^#[\t ]*define[\t ]+SHLIB_VERSION_NUMBER[\t ]+\".*\".*")
|
||||
string(REGEX REPLACE "^.*SHLIB_VERSION_NUMBER[\t ]+\"([^\"]*)\".*$" "\\1"
|
||||
SHLIB_VERSION "${SHLIB_VERSION}")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(LIB_EXT dylib)
|
||||
set(LIB_EXTS ${SHLIB_VERSION}.${LIB_EXT})
|
||||
else()
|
||||
set(LIB_EXT so)
|
||||
set(LIB_EXTS ${LIB_EXT}.${SHLIB_VERSION})
|
||||
endif()
|
||||
list(APPEND LIB_EXTS ${LIB_EXT})
|
||||
else()
|
||||
set(SHARED no-shared)
|
||||
set(LIB_EXTS a)
|
||||
endif()
|
||||
foreach(lib ssl crypto)
|
||||
foreach(ext ${LIB_EXTS})
|
||||
list(APPEND INSTALL_LIBS "${BUILDDIR}/lib${lib}.${ext}")
|
||||
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} 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} "PATH=${MSYS_BIN_DIR}${PATH_VAR}"
|
||||
COMMAND "${PERL}" Configure
|
||||
${SHARED}
|
||||
enable-static-engine
|
||||
no-ssl2
|
||||
no-krb5
|
||||
no-idea
|
||||
no-bf
|
||||
no-cast
|
||||
no-seed
|
||||
no-md2
|
||||
${PLATFORM}
|
||||
"--prefix=${CMAKE_INSTALL_PREFIX}"
|
||||
"--openssldir=/etc/ssl"
|
||||
${CFLAGS}
|
||||
COMMAND "${CMAKE_COMMAND}" "-DDIR=${BUILDDIR}" -P "${CMAKE_CURRENT_LIST_DIR}/remove-deps.cmake"
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY "${BUILDDIR}"
|
||||
)
|
||||
|
||||
add_custom_target(depend
|
||||
COMMAND ${ENV_COMMAND} "PATH=${MSYS_BIN_DIR}${PATH_VAR}"
|
||||
COMMAND "${MAKE}" links # depend MAKEDEPPROG=${CMAKE_C_COMPILER}
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY "${BUILDDIR}"
|
||||
DEPENDS "${BUILDDIR}/Makefile"
|
||||
)
|
||||
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}" build_libs
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY "${BUILDDIR}"
|
||||
DEPENDS depend
|
||||
BYPRODUCTS ${INSTALL_LIBS}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ${INSTALL_LIBS}
|
||||
DESTINATION lib
|
||||
)
|
|
@ -1,3 +0,0 @@
|
|||
Source: openssl-unix
|
||||
Version: 1.0.2s-1
|
||||
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.
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/Configure b/Configure
|
||||
index c98107a..77ad9d3 100644
|
||||
--- a/Configure
|
||||
+++ b/Configure
|
||||
@@ -972,7 +972,7 @@ PROCESS_ARGS:
|
||||
}
|
||||
elsif (/^--with-zlib-include=(.*)$/)
|
||||
{
|
||||
- $withargs{"zlib-include"}="-I$1";
|
||||
+ $withargs{"zlib-include"}="-I\"$1\"";
|
||||
}
|
||||
elsif (/^--with-fipsdir=(.*)$/)
|
||||
{
|
|
@ -1,25 +0,0 @@
|
|||
diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl
|
||||
index dba96cb..5722f6e 100644
|
||||
--- a/util/pl/VC-32.pl
|
||||
+++ b/util/pl/VC-32.pl
|
||||
@@ -154,9 +154,17 @@ else
|
||||
$cflags=$opt_cflags.$base_cflags;
|
||||
}
|
||||
|
||||
-# generate symbols.pdb unconditionally
|
||||
-$app_cflag.=" /Zi /Fd\$(TMP_D)/app";
|
||||
-$lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
|
||||
+# generate symbols.pdb when building dlls and embed symbols when building static libs
|
||||
+if ($shlib)
|
||||
+ {
|
||||
+ $app_cflag.=" /Zi /Fd\$(TMP_D)/app.pdb";
|
||||
+ $lib_cflag.=" /Zi /Fd\$(TMP_D)/lib.pdb";
|
||||
+ }
|
||||
+else
|
||||
+ {
|
||||
+ $app_cflag.=" /Z7";
|
||||
+ $lib_cflag.=" /Z7";
|
||||
+ }
|
||||
$lflags.=" /debug";
|
||||
|
||||
$obj='.obj';
|
|
@ -1,23 +0,0 @@
|
|||
diff --git a/crypto/cversion.c b/crypto/cversion.c
|
||||
index bfff699..17b7912 100644
|
||||
--- a/crypto/cversion.c
|
||||
+++ b/crypto/cversion.c
|
||||
@@ -56,6 +56,9 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
+#define STRINGIFY2(x) #x
|
||||
+#define STRINGIFY(x) STRINGIFY2(x)
|
||||
+
|
||||
#include "cryptlib.h"
|
||||
|
||||
#ifndef NO_WINDOWS_BRAINDEATH
|
||||
@@ -79,7 +82,7 @@ const char *SSLeay_version(int t)
|
||||
}
|
||||
if (t == SSLEAY_CFLAGS) {
|
||||
#ifdef CFLAGS
|
||||
- return (CFLAGS);
|
||||
+ return STRINGIFY(CFLAGS);
|
||||
#else
|
||||
return ("compiler: information not available");
|
||||
#endif
|
|
@ -1,73 +0,0 @@
|
|||
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME)
|
||||
message(FATAL_ERROR "This port is only for openssl on Unix-like systems")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CURRENT_INSTALLED_DIR}/include/openssl/ssl.h")
|
||||
message(WARNING "Can't build openssl if libressl is installed. Please remove libressl, and try install openssl again if you need it. Build will continue but there might be problems since libressl is only a subset of openssl")
|
||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
endif()
|
||||
|
||||
vcpkg_find_acquire_program(PERL)
|
||||
|
||||
set(OPENSSL_VERSION 1.0.2s)
|
||||
|
||||
vcpkg_download_distfile(OPENSSL_SOURCE_ARCHIVE
|
||||
URLS "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" "https://www.openssl.org/source/old/1.0.2/openssl-${OPENSSL_VERSION}.tar.gz"
|
||||
FILENAME "openssl-${OPENSSL_VERSION}.tar.gz"
|
||||
SHA512 9f745452c4f777df694158e95003cde78a2cf8199bc481a563ec36644664c3c1415a774779b9791dd18f2aeb57fa1721cb52b3db12d025955e970071d5b66d2a
|
||||
)
|
||||
|
||||
vcpkg_extract_source_archive_ex(
|
||||
OUT_SOURCE_PATH MASTER_COPY_SOURCE_PATH
|
||||
ARCHIVE ${OPENSSL_SOURCE_ARCHIVE}
|
||||
REF ${OPENSSL_VERSION}
|
||||
PATCHES
|
||||
ConfigureIncludeQuotesFix.patch
|
||||
STRINGIFYPatch.patch
|
||||
EmbedSymbolsInStaticLibsZ7.patch
|
||||
)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
vcpkg_acquire_msys(MSYS_ROOT PACKAGES make)
|
||||
set(BASH ${MSYS_ROOT}/usr/bin/bash.exe)
|
||||
set(MAKE ${MSYS_ROOT}/usr/bin/make.exe)
|
||||
else()
|
||||
find_program(MAKE make)
|
||||
if(NOT MAKE)
|
||||
message(FATAL_ERROR "Could not find make. Please install it through your package manager.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DSOURCE_PATH=${MASTER_COPY_SOURCE_PATH}
|
||||
-DPERL=${PERL}
|
||||
-DMAKE=${MAKE}
|
||||
OPTIONS_RELEASE
|
||||
-DINSTALL_HEADERS=ON
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
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(INSTALL ${RESOLVED_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/openssl)
|
||||
file(INSTALL ${MASTER_COPY_SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl-unix RENAME copyright)
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl)
|
||||
endif()
|
||||
|
||||
vcpkg_test_cmake(PACKAGE_NAME OpenSSL MODULE)
|
|
@ -1,4 +0,0 @@
|
|||
The package openssl is compatible with built-in CMake targets:
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
|
@ -1,10 +0,0 @@
|
|||
_find_package(${ARGS})
|
||||
if(OPENSSL_FOUND)
|
||||
find_library(OPENSSL_DL_LIBRARY NAMES dl)
|
||||
if(OPENSSL_DL_LIBRARY)
|
||||
list(APPEND OPENSSL_LIBRARIES "dl")
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "dl")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
|
@ -1,3 +0,0 @@
|
|||
Source: openssl-windows
|
||||
Version: 1.1.1h
|
||||
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.
|
|
@ -1,142 +0,0 @@
|
|||
if(VCPKG_CMAKE_SYSTEM_NAME)
|
||||
message(FATAL_ERROR "This port is only for building openssl on Windows Desktop")
|
||||
endif()
|
||||
|
||||
set(OPENSSL_VERSION 1.1.1h)
|
||||
set(MASTER_COPY_SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openssl-${OPENSSL_VERSION})
|
||||
|
||||
vcpkg_find_acquire_program(PERL)
|
||||
|
||||
get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY)
|
||||
set(ENV{PATH} "$ENV{PATH};${PERL_EXE_PATH}")
|
||||
|
||||
vcpkg_download_distfile(OPENSSL_SOURCE_ARCHIVE
|
||||
URLS "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" "https://www.openssl.org/source/old/1.1.1/openssl-${OPENSSL_VERSION}.tar.gz"
|
||||
FILENAME "openssl-${OPENSSL_VERSION}.tar.gz"
|
||||
SHA512 da50fd99325841ed7a4367d9251c771ce505a443a73b327d8a46b2c6a7d2ea99e43551a164efc86f8743b22c2bdb0020bf24a9cbd445e9d68868b2dc1d34033a
|
||||
)
|
||||
|
||||
vcpkg_extract_source_archive(${OPENSSL_SOURCE_ARCHIVE})
|
||||
|
||||
vcpkg_find_acquire_program(NASM)
|
||||
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
|
||||
set(ENV{PATH} "${NASM_EXE_PATH};$ENV{PATH}")
|
||||
|
||||
vcpkg_find_acquire_program(JOM)
|
||||
|
||||
set(CONFIGURE_COMMAND ${PERL} Configure
|
||||
enable-static-engine
|
||||
enable-capieng
|
||||
no-ssl2
|
||||
-utf-8
|
||||
)
|
||||
|
||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
||||
set(OPENSSL_ARCH VC-WIN32)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
||||
set(OPENSSL_ARCH VC-WIN64A)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
|
||||
endif()
|
||||
|
||||
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")
|
||||
message(STATUS "Configure ${TARGET_TRIPLET}-rel")
|
||||
file(COPY ${MASTER_COPY_SOURCE_PATH} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
|
||||
set(SOURCE_PATH_RELEASE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/openssl-${OPENSSL_VERSION})
|
||||
set(OPENSSLDIR_RELEASE ${CURRENT_PACKAGES_DIR})
|
||||
|
||||
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}-${CMAKE_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 $ENV{NUMBER_OF_PROCESSORS}
|
||||
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 install
|
||||
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")
|
||||
message(STATUS "Configure ${TARGET_TRIPLET}-dbg")
|
||||
file(COPY ${MASTER_COPY_SOURCE_PATH} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
|
||||
set(SOURCE_PATH_DEBUG ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/openssl-${OPENSSL_VERSION})
|
||||
set(OPENSSLDIR_DEBUG ${CURRENT_PACKAGES_DIR}/debug)
|
||||
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} --debug "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS
|
||||
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
|
||||
LOGNAME configure-perl-${TARGET_TRIPLET}-${CMAKE_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 $ENV{NUMBER_OF_PROCESSORS}
|
||||
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 install
|
||||
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}/lib/engines-1_1)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/private)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/certs)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/engines-1_1)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/private)
|
||||
file(REMOVE
|
||||
${CURRENT_PACKAGES_DIR}/openssl.cnf
|
||||
${CURRENT_PACKAGES_DIR}/openssl.cnf.dist
|
||||
${CURRENT_PACKAGES_DIR}/ct_log_list.cnf
|
||||
${CURRENT_PACKAGES_DIR}/ct_log_list.cnf.dist
|
||||
${CURRENT_PACKAGES_DIR}/debug/openssl.cnf
|
||||
${CURRENT_PACKAGES_DIR}/debug/openssl.cnf.dist
|
||||
${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf
|
||||
${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf.dist
|
||||
${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe
|
||||
)
|
||||
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/openssl/)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/bin/openssl.exe ${CURRENT_PACKAGES_DIR}/tools/openssl/openssl.exe)
|
||||
|
||||
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_copy_pdbs()
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
|
||||
file(INSTALL ${MASTER_COPY_SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
|
||||
|
||||
vcpkg_test_cmake(PACKAGE_NAME OpenSSL MODULE)
|
|
@ -1,4 +0,0 @@
|
|||
The package openssl is compatible with built-in CMake targets:
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
|
@ -1,4 +0,0 @@
|
|||
Source: openssl
|
||||
Version: 0
|
||||
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.
|
||||
Build-Depends: openssl-windows (windows), openssl-android (android), openssl-unix (!android&!windows)
|
32
cmake/ports/openssl/install-pc-files.cmake
Normal file
32
cmake/ports/openssl/install-pc-files.cmake
Normal file
|
@ -0,0 +1,32 @@
|
|||
function(install_pc_file name pc_data)
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${name}.pc" @ONLY)
|
||||
endif()
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${name}.pc" @ONLY)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
install_pc_file(openssl [[
|
||||
Name: OpenSSL
|
||||
Description: Secure Sockets Layer and cryptography libraries and tools
|
||||
Requires: libssl libcrypto
|
||||
]])
|
||||
|
||||
install_pc_file(libssl [[
|
||||
Name: OpenSSL-libssl
|
||||
Description: Secure Sockets Layer and cryptography libraries
|
||||
Libs: -L"${libdir}" -llibssl
|
||||
Requires: libcrypto
|
||||
Cflags: -I"${includedir}"
|
||||
]])
|
||||
|
||||
install_pc_file(libcrypto [[
|
||||
Name: OpenSSL-libcrypto
|
||||
Description: OpenSSL cryptography library
|
||||
Libs: -L"${libdir}" -llibcrypto
|
||||
Libs.private: -lcrypt32 -lws2_32
|
||||
Cflags: -I"${includedir}"
|
||||
]])
|
||||
|
||||
vcpkg_fixup_pkgconfig()
|
6
cmake/ports/openssl/openssl.pc.in
Normal file
6
cmake/ports/openssl/openssl.pc.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
prefix=${pcfiledir}/../..
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
Version: @OPENSSL_VERSION@
|
||||
@pc_data@
|
|
@ -1,2 +1,43 @@
|
|||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
||||
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl/)
|
||||
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/libressl/copyright"
|
||||
OR EXISTS "${CURRENT_INSTALLED_DIR}/share/boringssl/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_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()
|
||||
|
||||
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()
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO openssl/openssl
|
||||
REF openssl-${OPENSSL_VERSION}
|
||||
SHA512 e426f2d48dcd87ad938b246cea69988710198c3ed2f5bb9065aa9e74492161b056336f5b1f29be64e70dfd86a77808fe727ebb46eae10331c76f1ff08e341133
|
||||
PATCHES ${OPENSSL_PATCHES}
|
||||
)
|
||||
|
||||
vcpkg_find_acquire_program(PERL)
|
||||
get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY)
|
||||
vcpkg_add_to_path("${PERL_EXE_PATH}")
|
||||
|
||||
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}")
|
||||
|
|
285
cmake/ports/openssl/unix/CMakeLists.txt
Normal file
285
cmake/ports/openssl/unix/CMakeLists.txt
Normal file
|
@ -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
|
||||
)
|
32
cmake/ports/openssl/unix/portfile.cmake
Normal file
32
cmake/ports/openssl/unix/portfile.cmake
Normal file
|
@ -0,0 +1,32 @@
|
|||
if(CMAKE_HOST_WIN32)
|
||||
vcpkg_acquire_msys(MSYS_ROOT PACKAGES make perl)
|
||||
set(MAKE "${MSYS_ROOT}/usr/bin/make.exe")
|
||||
set(PERL "${MSYS_ROOT}/usr/bin/perl.exe")
|
||||
else()
|
||||
find_program(MAKE make)
|
||||
if(NOT MAKE)
|
||||
message(FATAL_ERROR "Could not find make. Please install it through your package manager.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}"
|
||||
OPTIONS
|
||||
-DSOURCE_PATH=${SOURCE_PATH}
|
||||
-DPERL=${PERL}
|
||||
-DMAKE=${MAKE}
|
||||
-DVCPKG_CONCURRENCY=${VCPKG_CONCURRENCY}
|
||||
)
|
||||
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_fixup_pkgconfig()
|
||||
|
||||
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(INSTALL ${RESOLVED_HEADERS} DESTINATION "${CURRENT_PACKAGES_DIR}/include/openssl")
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
16
cmake/ports/openssl/uwp/make-openssl.bat
Normal file
16
cmake/ports/openssl/uwp/make-openssl.bat
Normal file
|
@ -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
|
155
cmake/ports/openssl/uwp/portfile.cmake
Normal file
155
cmake/ports/openssl/uwp/portfile.cmake
Normal file
|
@ -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 "<winsock.h>" "<winsock2.h>" _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 <windows.h>" "#ifndef _WINSOCKAPI_\n#define _WINSOCKAPI_\n#endif\n# include <windows.h>" _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)
|
82
cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in
Normal file
82
cmake/ports/openssl/vcpkg-cmake-wrapper.cmake.in
Normal file
|
@ -0,0 +1,82 @@
|
|||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0012 NEW)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
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")
|
||||
message(WARNING "OPENSSL_USE_STATIC_LIBS is set, but vcpkg port openssl was built with dynamic linkage")
|
||||
endif()
|
||||
set(OPENSSL_USE_STATIC_LIBS_BAK "${OPENSSL_USE_STATIC_LIBS}")
|
||||
set(OPENSSL_USE_STATIC_LIBS FALSE)
|
||||
endif()
|
||||
|
||||
if(DEFINED OPENSSL_ROOT_DIR)
|
||||
set(OPENSSL_ROOT_DIR_BAK "${OPENSSL_ROOT_DIR}")
|
||||
endif()
|
||||
get_filename_component(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
|
||||
get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR}" DIRECTORY)
|
||||
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATH "${OPENSSL_ROOT_DIR}/include" NO_DEFAULT_PATH)
|
||||
if(MSVC)
|
||||
find_library(LIB_EAY_DEBUG NAMES libcrypto PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
|
||||
find_library(LIB_EAY_RELEASE NAMES libcrypto PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
|
||||
find_library(SSL_EAY_DEBUG NAMES libssl PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
|
||||
find_library(SSL_EAY_RELEASE NAMES libssl PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
|
||||
elseif(WIN32)
|
||||
find_library(LIB_EAY NAMES libcrypto crypto NAMES_PER_DIR)
|
||||
find_library(SSL_EAY NAMES libssl ssl NAMES_PER_DIR)
|
||||
else()
|
||||
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto)
|
||||
find_library(OPENSSL_SSL_LIBRARY NAMES ssl)
|
||||
endif()
|
||||
|
||||
_find_package(${ARGS})
|
||||
|
||||
unset(OPENSSL_ROOT_DIR)
|
||||
if(DEFINED OPENSSL_ROOT_DIR_BAK)
|
||||
set(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR_BAK}")
|
||||
unset(OPENSSL_ROOT_DIR_BAK)
|
||||
endif()
|
||||
|
||||
if(DEFINED OPENSSL_USE_STATIC_LIBS_BAK)
|
||||
set(OPENSSL_USE_STATIC_LIBS "${OPENSSL_USE_STATIC_LIBS_BAK}")
|
||||
unset(OPENSSL_USE_STATIC_LIBS_BAK)
|
||||
endif()
|
||||
|
||||
if(OPENSSL_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
|
||||
if(WIN32)
|
||||
list(APPEND OPENSSL_LIBRARIES crypt32 ws2_32)
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "crypt32;ws2_32")
|
||||
endif()
|
||||
if(TARGET OpenSSL::SSL)
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "crypt32;ws2_32")
|
||||
endif()
|
||||
else()
|
||||
find_library(OPENSSL_DL_LIBRARY NAMES dl)
|
||||
if(OPENSSL_DL_LIBRARY)
|
||||
list(APPEND OPENSSL_LIBRARIES "dl")
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "dl")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("REQUIRED" IN_LIST ARGS)
|
||||
find_package(Threads REQUIRED)
|
||||
else()
|
||||
find_package(Threads)
|
||||
endif()
|
||||
list(APPEND OPENSSL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
|
||||
endif()
|
||||
if(TARGET OpenSSL::SSL)
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
cmake_policy(POP)
|
22
cmake/ports/openssl/vcpkg.json
Normal file
22
cmake/ports/openssl/vcpkg.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "openssl",
|
||||
"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",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-get-vars",
|
||||
"host": true,
|
||||
"platform": "windows & !mingw & !uwp"
|
||||
}
|
||||
]
|
||||
}
|
35
cmake/ports/openssl/windows/flags.patch
Normal file
35
cmake/ports/openssl/windows/flags.patch
Normal file
|
@ -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,
|
207
cmake/ports/openssl/windows/portfile.cmake
Normal file
207
cmake/ports/openssl/windows/portfile.cmake
Normal file
|
@ -0,0 +1,207 @@
|
|||
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(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)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
||||
set(OPENSSL_ARCH VC-WIN64A)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
||||
set(OPENSSL_ARCH VC-WIN32-ARM)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
||||
set(OPENSSL_ARCH VC-WIN64-ARM)
|
||||
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})
|
||||
|
||||
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
|
||||
)
|
||||
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(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)
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
"${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"
|
||||
)
|
||||
|
||||
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"
|
||||
"<winsock.h>"
|
||||
"<winsock2.h>"
|
||||
)
|
||||
|
||||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/openssl/rand.h"
|
||||
"# include <windows.h>"
|
||||
"#ifndef _WINSOCKAPI_\n#define _WINSOCKAPI_\n#endif\n# include <windows.h>"
|
||||
)
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
23
cmake/ports/vcpkg-cmake-config/copyright
Normal file
23
cmake/ports/vcpkg-cmake-config/copyright
Normal file
|
@ -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.
|
12
cmake/ports/vcpkg-cmake-config/portfile.cmake
Normal file
12
cmake/ports/vcpkg-cmake-config/portfile.cmake
Normal file
|
@ -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)
|
1
cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake
Normal file
1
cmake/ports/vcpkg-cmake-config/vcpkg-port-config.cmake
Normal file
|
@ -0,0 +1 @@
|
|||
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_config_fixup.cmake")
|
7
cmake/ports/vcpkg-cmake-config/vcpkg.json
Normal file
7
cmake/ports/vcpkg-cmake-config/vcpkg.json
Normal file
|
@ -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"
|
||||
}
|
258
cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
Normal file
258
cmake/ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
Normal file
|
@ -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/<target_path>/ 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 [[^\\[$]<\\[$]<CONFIG:DEBUG>:]])
|
||||
list(TRANSFORM release_libs REPLACE [[^\\[$]<\\[$]<NOT:\\[$]<CONFIG:DEBUG>>:(.*)>$]] "\\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 [[^\\[$]<\\[$]<NOT:\\[$]<CONFIG:DEBUG>>:]])
|
||||
list(TRANSFORM debug_libs REPLACE [[^\\[$]<\\[$]<CONFIG:DEBUG>:(.*)>$]] "\\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 "\\\$<\\\$<NOT:\\\$<CONFIG:DEBUG>>:${release_lib}>")
|
||||
endif()
|
||||
if(debug_lib)
|
||||
list(APPEND merged_libs "\\\$<\\\$<CONFIG:DEBUG>:${debug_lib}>")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set("${out_var}" "${merged_libs}" PARENT_SCOPE)
|
||||
endfunction()
|
204
cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt
Normal file
204
cmake/ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt
Normal file
|
@ -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_<LANG>_COMPILER_AR (Wrapper)
|
||||
# CMAKE_RANLIB
|
||||
# CMAKE_<LANG>_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_<LANG>_COMPILER_ID
|
||||
# MSVC
|
||||
# MSVC_VERSION
|
||||
|
||||
# Flags:
|
||||
# CMAKE_<LANG>_FLAGS
|
||||
# CMAKE_<LANG>_FLAGS_<CONFIG>
|
||||
# CMAKE_RC_FLAGS
|
||||
# CMAKE_SHARED_LINKER_FLAGS
|
||||
# CMAKE_SHARED_LINKER_FLAGS_<CONFIG>
|
||||
# CMAKE_STATIC_LINKER_FLAGS
|
||||
# CMAKE_STATIC_LINKER_FLAGS_<CONFIG>
|
||||
# CMAKE_EXE_LINKER_FLAGS
|
||||
# CMAKE_EXE_LINKER_FLAGS_<CONFIG>
|
||||
|
||||
# Additional information:
|
||||
# CMAKE_SIZEOF_VOID_P
|
||||
# CMAKE_CROSSCOMPILING
|
||||
# CMAKE_SYSTEM_NAME
|
||||
# CMAKE_HOST_SYSTEM_NAME
|
||||
# CMAKE_SYSTEM_PROCESSOR
|
||||
# CMAKE_HOST_SYSTEM_PROCESSOR
|
14
cmake/ports/vcpkg-cmake-get-vars/portfile.cmake
Normal file
14
cmake/ports/vcpkg-cmake-get-vars/portfile.cmake
Normal file
|
@ -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)
|
||||
|
2
cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake
Normal file
2
cmake/ports/vcpkg-cmake-get-vars/vcpkg-port-config.cmake
Normal file
|
@ -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")
|
13
cmake/ports/vcpkg-cmake-get-vars/vcpkg.json
Normal file
13
cmake/ports/vcpkg-cmake-get-vars/vcpkg.json
Normal file
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
34
cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake
Normal file
34
cmake/ports/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake
Normal file
|
@ -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()
|
14
cmake/ports/vcpkg-cmake/portfile.cmake
Normal file
14
cmake/ports/vcpkg-cmake/portfile.cmake
Normal file
|
@ -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)
|
3
cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake
Normal file
3
cmake/ports/vcpkg-cmake/vcpkg-port-config.cmake
Normal file
|
@ -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")
|
6
cmake/ports/vcpkg-cmake/vcpkg.json
Normal file
6
cmake/ports/vcpkg-cmake/vcpkg.json
Normal file
|
@ -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"
|
||||
}
|
91
cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake
Normal file
91
cmake/ports/vcpkg-cmake/vcpkg_cmake_build.cmake
Normal file
|
@ -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()
|
311
cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Normal file
311
cmake/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Normal file
|
@ -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()
|
21
cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake
Normal file
21
cmake/ports/vcpkg-cmake/vcpkg_cmake_install.cmake
Normal file
|
@ -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()
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue