vcpkg/ports/openssl/portfile.cmake

160 lines
6.2 KiB
CMake
Raw Normal View History

if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
include(${CMAKE_CURRENT_LIST_DIR}/portfile-uwp.cmake)
return()
endif()
2016-09-19 11:50:08 +08:00
include(vcpkg_common_functions)
set(OPENSSL_VERSION 1.0.2n)
set(MASTER_COPY_SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openssl-${OPENSSL_VERSION})
2017-05-24 07:22:17 +08:00
vcpkg_find_acquire_program(PERL)
vcpkg_find_acquire_program(NASM)
2016-09-19 11:50:08 +08:00
get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY)
2017-05-24 07:22:17 +08:00
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
set(ENV{PATH} "${NASM_EXE_PATH};$ENV{PATH};${PERL_EXE_PATH}")
2016-09-19 11:50:08 +08:00
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"
2017-01-29 00:25:17 +08:00
FILENAME "openssl-${OPENSSL_VERSION}.tar.gz"
SHA512 144bf0d6aa27b4af01df0b7b734c39962649e1711554247d42e05e14d8945742b18745aefdba162e2dfc762b941fd7d3b2d5dc6a781ae4ba10a6f5a3cadb0687
2016-09-19 11:50:08 +08:00
)
vcpkg_extract_source_archive(${OPENSSL_SOURCE_ARCHIVE})
vcpkg_apply_patches(
SOURCE_PATH ${MASTER_COPY_SOURCE_PATH}
PATCHES ${CMAKE_CURRENT_LIST_DIR}/ConfigureIncludeQuotesFix.patch
${CMAKE_CURRENT_LIST_DIR}/STRINGIFYPatch.patch
${CMAKE_CURRENT_LIST_DIR}/EmbedSymbolsInStaticLibsZ7.patch
2018-01-25 10:43:19 +08:00
${CMAKE_CURRENT_LIST_DIR}/RemoveNonASCIIChar.patch
)
2016-09-19 11:50:08 +08:00
if(VCPKG_CMAKE_SYSTEM_NAME)
include(${CMAKE_CURRENT_LIST_DIR}/portfile-nonwindows.cmake)
return()
endif()
vcpkg_find_acquire_program(JOM)
set(CONFIGURE_COMMAND ${PERL} Configure
enable-static-engine
enable-capieng
no-ssl2
2017-12-12 09:29:04 +08:00
-utf-8
2016-09-19 11:50:08 +08:00
)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(OPENSSL_ARCH VC-WIN32)
2017-05-24 07:22:17 +08:00
set(OPENSSL_DO "ms\\do_nasm.bat")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(OPENSSL_ARCH VC-WIN64A)
set(OPENSSL_DO "ms\\do_win64a.bat")
else()
message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
2017-05-24 07:22:17 +08:00
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(OPENSSL_MAKEFILE "ms\\ntdll.mak")
else()
set(OPENSSL_MAKEFILE "ms\\nt.mak")
endif()
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
2017-05-24 07:22:17 +08:00
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})
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}-${CMAKE_BUILD_TYPE}-rel
)
vcpkg_execute_required_process(
COMMAND ${OPENSSL_DO}
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
LOGNAME configure-do-${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} -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
)
2017-05-24 07:22:17 +08:00
vcpkg_execute_required_process(
COMMAND ${JOM} -j 1 -f ${OPENSSL_MAKEFILE} install
2017-05-24 07:22:17 +08:00
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
LOGNAME build-${TARGET_TRIPLET}-rel-1)
message(STATUS "Build ${TARGET_TRIPLET}-rel done")
2017-05-24 07:22:17 +08:00
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} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME configure-perl-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE}-dbg
)
vcpkg_execute_required_process(
COMMAND ${OPENSSL_DO}
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME configure-do-${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} -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
)
2017-05-24 07:22:17 +08:00
vcpkg_execute_required_process(
COMMAND ${JOM} -j 1 -f ${OPENSSL_MAKEFILE} install
2017-05-24 07:22:17 +08:00
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME build-${TARGET_TRIPLET}-dbg-1)
message(STATUS "Build ${TARGET_TRIPLET}-dbg done")
2016-09-19 11:50:08 +08:00
2017-05-24 07:22:17 +08:00
2016-09-19 11:50:08 +08:00
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE
${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe
${CURRENT_PACKAGES_DIR}/debug/openssl.cnf
${CURRENT_PACKAGES_DIR}/openssl.cnf
)
2017-09-24 19:15:12 +08:00
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/${PORT}/)
file(RENAME ${CURRENT_PACKAGES_DIR}/bin/openssl.exe ${CURRENT_PACKAGES_DIR}/tools/${PORT}/openssl.exe)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
2016-09-19 11:50:08 +08:00
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl RENAME copyright)
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}")
2017-05-24 07:22:17 +08:00
vcpkg_copy_pdbs()
file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})