2016-11-08 13:54:23 +08:00
|
|
|
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)
|
2018-03-29 00:07:37 +08:00
|
|
|
set(OPENSSL_VERSION 1.0.2o)
|
2017-03-21 06:48:13 +08:00
|
|
|
set(MASTER_COPY_SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openssl-${OPENSSL_VERSION})
|
2017-05-24 07:22:17 +08:00
|
|
|
|
2018-03-14 02:35:19 +08:00
|
|
|
vcpkg_find_acquire_program(PERL)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY)
|
2018-03-21 20:26:19 +08:00
|
|
|
set(ENV{PATH} "$ENV{PATH};${PERL_EXE_PATH}")
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
vcpkg_download_distfile(OPENSSL_SOURCE_ARCHIVE
|
2017-05-26 02:41:59 +08:00
|
|
|
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"
|
2018-03-29 00:07:37 +08:00
|
|
|
SHA512 8a2c93657c85143e76785bb32ee836908c31a6f5f8db993fa9777acba6079e630cdddd03edbad65d1587199fc13a1507789eacf038b56eb99139c2091d9df7fd
|
2016-09-19 11:50:08 +08:00
|
|
|
)
|
|
|
|
|
2017-03-21 04:54:57 +08:00
|
|
|
vcpkg_extract_source_archive(${OPENSSL_SOURCE_ARCHIVE})
|
|
|
|
vcpkg_apply_patches(
|
2017-03-21 06:48:13 +08:00
|
|
|
SOURCE_PATH ${MASTER_COPY_SOURCE_PATH}
|
2017-12-09 05:21:32 +08:00
|
|
|
PATCHES ${CMAKE_CURRENT_LIST_DIR}/ConfigureIncludeQuotesFix.patch
|
2017-03-21 04:54:57 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/STRINGIFYPatch.patch
|
2017-09-09 08:24:25 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/EmbedSymbolsInStaticLibsZ7.patch
|
2017-03-21 04:54:57 +08:00
|
|
|
)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2018-03-12 14:41:51 +08:00
|
|
|
if(VCPKG_CMAKE_SYSTEM_NAME)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/portfile-nonwindows.cmake)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2018-03-21 20:26:19 +08:00
|
|
|
vcpkg_find_acquire_program(NASM)
|
|
|
|
get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
|
|
|
|
set(ENV{PATH} "${NASM_EXE_PATH};$ENV{PATH}")
|
|
|
|
|
2018-03-12 14:41:51 +08:00
|
|
|
vcpkg_find_acquire_program(JOM)
|
|
|
|
|
2017-03-21 06:48:13 +08:00
|
|
|
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
|
|
|
)
|
|
|
|
|
2017-10-17 22:15:37 +08:00
|
|
|
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
2017-03-21 06:48:13 +08:00
|
|
|
set(OPENSSL_ARCH VC-WIN32)
|
2017-05-24 07:22:17 +08:00
|
|
|
set(OPENSSL_DO "ms\\do_nasm.bat")
|
2017-10-17 22:15:37 +08:00
|
|
|
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
2017-03-21 06:48:13 +08:00
|
|
|
set(OPENSSL_ARCH VC-WIN64A)
|
|
|
|
set(OPENSSL_DO "ms\\do_win64a.bat")
|
|
|
|
else()
|
2017-10-17 22:15:37 +08:00
|
|
|
message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
|
2017-03-21 06:48:13 +08:00
|
|
|
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()
|
|
|
|
|
2017-03-21 06:48:13 +08:00
|
|
|
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
|
|
|
|
|
2017-05-24 07:22:17 +08:00
|
|
|
|
2017-03-21 06:48:13 +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})
|
|
|
|
|
2017-08-02 08:12:59 +08:00
|
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-rel")
|
2016-09-20 08:38:38 +08:00
|
|
|
vcpkg_execute_required_process(
|
2017-06-08 17:15:58 +08:00
|
|
|
COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_RELEASE}" "--openssldir=${OPENSSLDIR_RELEASE}" -FS
|
2017-03-21 06:48:13 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
|
|
|
|
LOGNAME configure-perl-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE}-rel
|
2016-09-20 08:38:38 +08:00
|
|
|
)
|
2017-03-21 06:48:13 +08:00
|
|
|
vcpkg_execute_required_process(
|
|
|
|
COMMAND ${OPENSSL_DO}
|
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
|
|
|
|
LOGNAME configure-do-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE}-rel
|
|
|
|
)
|
2017-08-02 08:12:59 +08:00
|
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-rel done")
|
|
|
|
|
|
|
|
message(STATUS "Build ${TARGET_TRIPLET}-rel")
|
2017-06-08 17:15:58 +08:00
|
|
|
# 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(
|
2018-03-29 00:07:37 +08:00
|
|
|
COMMAND nmake -f ${OPENSSL_MAKEFILE} install
|
2017-05-24 07:22:17 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
|
2017-06-08 17:15:58 +08:00
|
|
|
LOGNAME build-${TARGET_TRIPLET}-rel-1)
|
2017-03-21 06:48:13 +08:00
|
|
|
|
2016-09-20 08:38:38 +08:00
|
|
|
message(STATUS "Build ${TARGET_TRIPLET}-rel done")
|
|
|
|
|
2017-05-24 07:22:17 +08:00
|
|
|
|
2017-08-02 08:12:59 +08:00
|
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-dbg")
|
2017-03-21 06:48:13 +08:00
|
|
|
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(
|
2017-06-08 17:15:58 +08:00
|
|
|
COMMAND ${CONFIGURE_COMMAND} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS
|
2017-03-21 06:48:13 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
|
|
|
|
LOGNAME configure-perl-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE}-dbg
|
|
|
|
)
|
2016-09-20 08:38:38 +08:00
|
|
|
vcpkg_execute_required_process(
|
2017-03-21 06:48:13 +08:00
|
|
|
COMMAND ${OPENSSL_DO}
|
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
|
|
|
|
LOGNAME configure-do-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE}-dbg
|
2016-09-20 08:38:38 +08:00
|
|
|
)
|
2017-08-02 08:12:59 +08:00
|
|
|
message(STATUS "Configure ${TARGET_TRIPLET}-dbg done")
|
|
|
|
|
|
|
|
message(STATUS "Build ${TARGET_TRIPLET}-dbg")
|
2017-06-08 17:15:58 +08:00
|
|
|
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(
|
2018-03-29 00:07:37 +08:00
|
|
|
COMMAND nmake -f ${OPENSSL_MAKEFILE} install
|
2017-05-24 07:22:17 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
|
2017-06-08 17:15:58 +08:00
|
|
|
LOGNAME build-${TARGET_TRIPLET}-dbg-1)
|
2017-03-21 06:48:13 +08:00
|
|
|
|
2016-09-20 08:38:38 +08:00
|
|
|
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
|
|
|
|
)
|
2016-10-26 07:10:43 +08:00
|
|
|
|
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)
|
2016-10-26 07:10:43 +08:00
|
|
|
|
2016-11-01 03:34:04 +08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
2016-10-26 07:10:43 +08:00
|
|
|
# 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()
|
2016-11-01 03:34:04 +08:00
|
|
|
|
2018-03-21 16:13:27 +08:00
|
|
|
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}")
|
|
|
|
|
2018-03-31 06:21:22 +08:00
|
|
|
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}")
|
|
|
|
|
2017-05-24 07:22:17 +08:00
|
|
|
vcpkg_copy_pdbs()
|
2017-11-17 15:54:55 +08:00
|
|
|
|
|
|
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
|