2024-03-28 05:54:54 +08:00
|
|
|
# Need cmd to pass quoted CC from nmake to mkbuildinf.pl, GH-37134
|
|
|
|
find_program(CMD_EXECUTABLE cmd HINTS ENV PATH NO_DEFAULT_PATH REQUIRED)
|
|
|
|
cmake_path(NATIVE_PATH CMD_EXECUTABLE cmd)
|
|
|
|
set(ENV{COMSPEC} "${cmd}")
|
|
|
|
|
2023-03-01 03:20:45 +08:00
|
|
|
vcpkg_find_acquire_program(PERL)
|
|
|
|
get_filename_component(PERL_EXE_PATH "${PERL}" DIRECTORY)
|
|
|
|
vcpkg_add_to_path("${PERL_EXE_PATH}")
|
2021-07-02 01:21:44 +08:00
|
|
|
|
2023-11-06 01:34:01 +08:00
|
|
|
vcpkg_cmake_get_vars(cmake_vars_file)
|
|
|
|
include("${cmake_vars_file}")
|
|
|
|
|
2020-11-04 14:59:02 +08:00
|
|
|
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")
|
2023-11-06 01:34:01 +08:00
|
|
|
if(VCPKG_TARGET_IS_UWP)
|
|
|
|
set(OPENSSL_ARCH VC-WIN64-ARM)
|
|
|
|
elseif(VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(OPENSSL_ARCH VC-CLANG-WIN64-CLANGASM-ARM)
|
|
|
|
else()
|
|
|
|
set(OPENSSL_ARCH VC-WIN64-CLANGASM-ARM)
|
|
|
|
endif()
|
2020-11-04 14:59:02 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
|
|
|
|
endif()
|
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
if(VCPKG_TARGET_IS_UWP)
|
|
|
|
vcpkg_list(APPEND CONFIGURE_OPTIONS
|
|
|
|
no-unit-test
|
|
|
|
no-asm
|
|
|
|
no-uplink
|
2020-11-04 14:59:02 +08:00
|
|
|
)
|
2022-11-12 06:12:15 +08:00
|
|
|
string(APPEND OPENSSL_ARCH "-UWP")
|
2020-11-04 14:59:02 +08:00
|
|
|
endif()
|
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
if(VCPKG_CONCURRENCY GREATER "1")
|
|
|
|
vcpkg_list(APPEND CONFIGURE_OPTIONS no-makedepend)
|
|
|
|
endif()
|
2020-11-04 14:59:02 +08:00
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
cmake_path(NATIVE_PATH CURRENT_PACKAGES_DIR NORMALIZE install_dir_native)
|
2022-04-07 22:48:06 +08:00
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
# Clang always uses /Z7; Patching /Zi /Fd<Name> out of openssl requires more work.
|
|
|
|
set(OPENSSL_BUILD_MAKES_PDBS ON)
|
|
|
|
if (VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "Clang" OR VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
|
|
set(OPENSSL_BUILD_MAKES_PDBS OFF)
|
2020-11-04 14:59:02 +08:00
|
|
|
endif()
|
|
|
|
|
2023-12-20 08:31:02 +08:00
|
|
|
cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_C_COMPILER NORMALIZE cc)
|
|
|
|
if(OPENSSL_ARCH MATCHES "CLANG")
|
2023-11-06 01:34:01 +08:00
|
|
|
vcpkg_find_acquire_program(CLANG)
|
2023-12-20 08:31:02 +08:00
|
|
|
cmake_path(GET CLANG PARENT_PATH clang_path)
|
2023-11-06 01:34:01 +08:00
|
|
|
vcpkg_add_to_path("${clang_path}")
|
|
|
|
if(VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " --target=aarch64-win32-msvc")
|
|
|
|
string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " --target=aarch64-win32-msvc")
|
|
|
|
endif()
|
2023-12-20 08:31:02 +08:00
|
|
|
endif()
|
|
|
|
if(OPENSSL_ARCH MATCHES "CLANGASM")
|
|
|
|
vcpkg_list(APPEND CONFIGURE_OPTIONS "ASFLAGS=--target=aarch64-win32-msvc")
|
2023-11-06 01:34:01 +08:00
|
|
|
else()
|
2023-12-20 08:31:02 +08:00
|
|
|
vcpkg_find_acquire_program(NASM)
|
2023-11-06 01:34:01 +08:00
|
|
|
cmake_path(NATIVE_PATH NASM NORMALIZE as)
|
2023-12-20 08:31:02 +08:00
|
|
|
cmake_path(GET NASM PARENT_PATH nasm_path)
|
|
|
|
vcpkg_add_to_path("${nasm_path}") # Needed by Configure
|
2023-11-06 01:34:01 +08:00
|
|
|
endif()
|
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_AR NORMALIZE ar)
|
|
|
|
cmake_path(NATIVE_PATH VCPKG_DETECTED_CMAKE_LINKER NORMALIZE ld)
|
|
|
|
|
|
|
|
vcpkg_build_nmake(
|
|
|
|
SOURCE_PATH "${SOURCE_PATH}"
|
|
|
|
PREFER_JOM
|
|
|
|
CL_LANGUAGE NONE
|
|
|
|
PRERUN_SHELL_RELEASE "${PERL}" Configure
|
|
|
|
${CONFIGURE_OPTIONS}
|
|
|
|
${OPENSSL_ARCH}
|
|
|
|
"--prefix=${install_dir_native}"
|
|
|
|
"--openssldir=${install_dir_native}"
|
|
|
|
"AS=${as}"
|
|
|
|
"CC=${cc}"
|
|
|
|
"CFLAGS=${VCPKG_COMBINED_C_FLAGS_RELEASE}"
|
|
|
|
"AR=${ar}"
|
|
|
|
"ARFLAGS=${VCPKG_COMBINED_STATIC_LINKER_FLAGS_RELEASE}"
|
|
|
|
"LD=${ld}"
|
|
|
|
"LDFLAGS=${VCPKG_COMBINED_SHARED_LINKER_FLAGS_RELEASE}"
|
|
|
|
PRERUN_SHELL_DEBUG "${PERL}" Configure
|
|
|
|
${CONFIGURE_OPTIONS}
|
2023-03-01 03:20:45 +08:00
|
|
|
${OPENSSL_ARCH}
|
|
|
|
--debug
|
2022-11-12 06:12:15 +08:00
|
|
|
"--prefix=${install_dir_native}\\debug"
|
|
|
|
"--openssldir=${install_dir_native}\\debug"
|
|
|
|
"AS=${as}"
|
|
|
|
"CC=${cc}"
|
|
|
|
"CFLAGS=${VCPKG_COMBINED_C_FLAGS_DEBUG}"
|
|
|
|
"AR=${ar}"
|
|
|
|
"ARFLAGS=${VCPKG_COMBINED_STATIC_LINKER_FLAGS_DEBUG}"
|
|
|
|
"LD=${ld}"
|
|
|
|
"LDFLAGS=${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}"
|
|
|
|
PROJECT_NAME "makefile"
|
2023-04-22 06:02:05 +08:00
|
|
|
TARGET install_dev install_modules ${INSTALL_FIPS}
|
2022-11-12 06:12:15 +08:00
|
|
|
LOGFILE_ROOT install
|
|
|
|
OPTIONS
|
|
|
|
"INSTALL_PDBS=${OPENSSL_BUILD_MAKES_PDBS}" # install-pdbs.patch
|
|
|
|
OPTIONS_RELEASE
|
|
|
|
install_runtime install_ssldirs # extra targets
|
|
|
|
)
|
|
|
|
|
2023-03-15 05:11:06 +08:00
|
|
|
set(scripts "bin/c_rehash.pl" "misc/CA.pl" "misc/tsget.pl")
|
|
|
|
if("tools" IN_LIST FEATURES)
|
|
|
|
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
|
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/openssl.cnf" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/openssl.cnf")
|
2023-05-05 01:44:41 +08:00
|
|
|
if("fips" IN_LIST FEATURES)
|
|
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/fipsmodule.cnf" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/fipsmodule.cnf")
|
|
|
|
endif()
|
2023-03-15 05:11:06 +08:00
|
|
|
foreach(script IN LISTS scripts)
|
2022-11-12 06:12:15 +08:00
|
|
|
file(COPY "${CURRENT_PACKAGES_DIR}/${script}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
|
|
|
file(REMOVE "${CURRENT_PACKAGES_DIR}/${script}" "${CURRENT_PACKAGES_DIR}/debug/${script}")
|
|
|
|
endforeach()
|
|
|
|
vcpkg_copy_tools(TOOL_NAMES openssl AUTO_CLEAN)
|
2023-03-15 05:11:06 +08:00
|
|
|
else()
|
|
|
|
file(REMOVE "${CURRENT_PACKAGES_DIR}/openssl.cnf")
|
2023-04-28 13:48:59 +08:00
|
|
|
file(REMOVE "${CURRENT_PACKAGES_DIR}/fipsmodule.cnf")
|
2023-03-15 05:11:06 +08:00
|
|
|
foreach(script IN LISTS scripts)
|
|
|
|
file(REMOVE "${CURRENT_PACKAGES_DIR}/${script}" "${CURRENT_PACKAGES_DIR}/debug/${script}")
|
|
|
|
endforeach()
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
|
|
|
endif()
|
2022-04-07 22:48:06 +08:00
|
|
|
endif()
|
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
vcpkg_copy_pdbs()
|
2022-04-07 02:04:46 +08:00
|
|
|
|
2022-11-12 06:12:15 +08:00
|
|
|
file(REMOVE_RECURSE
|
|
|
|
"${CURRENT_PACKAGES_DIR}/certs"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/misc"
|
2024-04-16 02:18:29 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/private"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/lib/engines-3"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/certs"
|
2022-11-12 06:12:15 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/misc"
|
2024-04-16 02:18:29 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/lib/engines-3"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/private"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/include"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/share"
|
2022-11-12 06:12:15 +08:00
|
|
|
)
|
2020-11-04 14:59:02 +08:00
|
|
|
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/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"
|
2023-04-22 06:02:05 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/fipsmodule.cnf"
|
2020-11-04 14:59:02 +08:00
|
|
|
)
|