Revision: 9679 https://osdn.net/projects/ttssh2/scm/svn/commits/9679 Author: nmaya Date: 2022-01-05 00:47:53 +0900 (Wed, 05 Jan 2022) Log Message: ----------- cmakeビルド, LibreSSL を使えるよう修正 - "-DTTXSSH_LIBRESSL=OFF" とすると、OpenSSL1.1.1 でビルドする - デフォルトでは ON、LibreSSL を使ってビルド - LibreSSL を lib/ でビルド - buildlibressl.cmake merge from libressl_3_4_2_cmake: r9674 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/9674 Modified Paths: -------------- branches/libressl_3_4_2/libs/buildall.cmake branches/libressl_3_4_2/ttssh2/ttxssh/CMakeLists.txt Added Paths: ----------- branches/libressl_3_4_2/libs/buildlibressl.cmake branches/libressl_3_4_2/libs/lib_libressl.cmake Property Changed: ---------------- branches/libressl_3_4_2/ branches/libressl_3_4_2/TTProxy/ branches/libressl_3_4_2/TTXKanjiMenu/ branches/libressl_3_4_2/TTXSamples/ branches/libressl_3_4_2/cygterm/ branches/libressl_3_4_2/teraterm/ branches/libressl_3_4_2/ttpmenu/ -------------- next part -------------- Index: branches/libressl_3_4_2 =================================================================== --- branches/libressl_3_4_2 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2 ___________________________________________________________________ Modified: svn:mergeinfo ## -1,7 +1,7 ## /branches/4-stable:8924,9256-9257 /branches/drag_and_drop:7130,7139,7141,7143-7147 /branches/flowctrl_dsrdtr:7825-7827 -/branches/libressl_3_4_2_cmake:9673,9675 +/branches/libressl_3_4_2_cmake:9673-9675 /branches/move_code_script:9026-9185 /branches/openssl_1_1_1_v2:7785-7786,7788-7808,7811-7812,7814-7815,7819-7822,7829,7832-7834,7838-7843,7846-7847,7855-7856,7858,7861-7863,7873-7877,7880-7881,7884-7888,7890-7892,7894-7895,7898,7900,7902-7903,7909,7924,7934,7954-7957,7959,7973,7975,7979-7980,8019,8208,8256 /branches/openssl_1_1_1_v3:8258,8264-8265 Index: branches/libressl_3_4_2/TTProxy =================================================================== --- branches/libressl_3_4_2/TTProxy 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/TTProxy 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/TTProxy ___________________________________________________________________ Modified: svn:mergeinfo ## -1,5 +1,5 ## /branches/4-stable/TTProxy:9256-9257 -/branches/libressl_3_4_2_cmake/TTProxy:9673,9675 +/branches/libressl_3_4_2_cmake/TTProxy:9673-9675 /branches/openssl_1_1_1_v2/TTProxy:7785-7786,7788-7808,7861-7863,7898,7900,7902-7903,7909,7924,7934,7954-7957,7959,7973,7975,7979-7980 /branches/openssl_1_1_1_v3/TTProxy:8258 /branches/ssh_chacha20poly1305/TTProxy:9209-9212,9217,9229,9248-9253 Index: branches/libressl_3_4_2/TTXKanjiMenu =================================================================== --- branches/libressl_3_4_2/TTXKanjiMenu 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/TTXKanjiMenu 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/TTXKanjiMenu ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,4 ## /branches/4-stable/TTXKanjiMenu:9256-9257 -/branches/libressl_3_4_2_cmake/TTXKanjiMenu:9673,9675 +/branches/libressl_3_4_2_cmake/TTXKanjiMenu:9673-9675 /branches/ssh_chacha20poly1305/TTXKanjiMenu:9209-9212,9217,9229,9248-9253 /branches/vs2015_warn/TTXKanjiMenu:6194-6285 \ No newline at end of property Index: branches/libressl_3_4_2/TTXSamples =================================================================== --- branches/libressl_3_4_2/TTXSamples 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/TTXSamples 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/TTXSamples ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,4 ## /branches/4-stable/TTXSamples:9256-9257 -/branches/libressl_3_4_2_cmake/TTXSamples:9673,9675 +/branches/libressl_3_4_2_cmake/TTXSamples:9673-9675 /branches/ssh_chacha20poly1305/TTXSamples:9209-9212,9217,9229,9248-9253 /branches/vs2015_warn/TTXSamples:6194-6285 \ No newline at end of property Index: branches/libressl_3_4_2/cygterm =================================================================== --- branches/libressl_3_4_2/cygterm 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/cygterm 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/cygterm ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,4 ## /branches/4-stable/cygterm:9256-9257 -/branches/libressl_3_4_2_cmake/cygterm:9673,9675 +/branches/libressl_3_4_2_cmake/cygterm:9673-9675 /branches/openssl_1_1_1_v3/cygterm:8284 /branches/ssh_chacha20poly1305/cygterm:9209-9212,9217,9229,9248-9253 \ No newline at end of property Modified: branches/libressl_3_4_2/libs/buildall.cmake =================================================================== --- branches/libressl_3_4_2/libs/buildall.cmake 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/libs/buildall.cmake 2022-01-04 15:47:53 UTC (rev 9679) @@ -55,5 +55,9 @@ execute_process( COMMAND ${CMAKE_COMMAND} -P argon2.cmake ) +message("libressl") +execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} ${ARCHITECTURE_OPTION} -P buildlibressl.cmake + ) message("done buildall.cmake") Copied: branches/libressl_3_4_2/libs/buildlibressl.cmake (from rev 9674, branches/libressl_3_4_2_cmake/libs/buildlibressl.cmake) =================================================================== --- branches/libressl_3_4_2/libs/buildlibressl.cmake (rev 0) +++ branches/libressl_3_4_2/libs/buildlibressl.cmake 2022-01-04 15:47:53 UTC (rev 9679) @@ -0,0 +1,134 @@ +# for libreSSL +# cmake -DCMAKE_GENERATOR="Visual Studio 16 2019" -DARCHITECTURE=Win32 -P buildlibressl.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P buildlibressl.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P buildlibressl.cmake + +include(script_support.cmake) + +set(SRC_DIR_BASE "libressl-3.4.2") +set(SRC_ARC "libressl-3.4.2.tar.gz") +set(SRC_URL "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.2.tar.gz") +set(SRC_ARC_HASH_SHA256 cb82ca7d547336917352fbd23db2fc483c6c44d35157b32780214ec74197b3ce) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/libressl") +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/libressl/src") +set(SRC_DIR "${EXTRACT_DIR}/${SRC_DIR_BASE}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/libressl_${TOOLSET}") +set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/libressl/build_${TOOLSET}") +if(("${CMAKE_GENERATOR}" MATCHES "Win64") OR ("$ENV{MSYSTEM_CHOST}" STREQUAL "x86_64-w64-mingw32") OR ("${ARCHITECTURE}" MATCHES "x64") OR ("${CMAKE_COMMAND}" MATCHES "mingw64")) + set(INSTALL_DIR "${INSTALL_DIR}_x64") + set(BUILD_DIR "${BUILD_DIR}_x64") +endif() + +#message("BUILD_DIR=${BUILD_DIR}") +#message("INSTALL_DIR=${INSTALL_DIR}") + +######################################## + +# Configure + Generate +function(cmake_generate GENERATOR SRC_DIR WORKING_DIR OPTIONS) + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} .. -G "${GENERATOR}" ${OPTIONS} + WORKING_DIRECTORY "${BUILD_DIR}" + ENCODING AUTO + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() +endfunction() + +# build + install +function(cmake_build WORKING_DIR OPTIONS BUILD_TOOL_OPTIONS) + execute_process( + COMMAND ${CMAKE_COMMAND} --build . ${OPTIONS} --target install -- ${BUILD_TOOL_OPTIONS} + WORKING_DIRECTORY "${BUILD_DIR}" + ENCODING AUTO + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() +endfunction() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/README.md) + + file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA256=${SRC_ARC_HASH_SHA256} + SHOW_PROGRESS + ) + + file(MAKE_DIRECTORY ${EXTRACT_DIR}) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + + file(COPY + ${SRC_DIR}/COPYING + DESTINATION ${CMAKE_CURRENT_LIST_DIR}/doc_help + ) + file(RENAME + ${CMAKE_CURRENT_LIST_DIR}/doc_help/COPYING + ${CMAKE_CURRENT_LIST_DIR}/doc_help/LibreSSL-LICENSE.txt) +endif() + +######################################## + +file(MAKE_DIRECTORY "${BUILD_DIR}") + +if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # multi-configuration + + unset(GENERATE_OPTIONS) + list(APPEND GENERATE_OPTIONS -A ${ARCHITECTURE}) + list(APPEND GENERATE_OPTIONS "-DCMAKE_DEBUG_POSTFIX=d") + list(APPEND GENERATE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + list(APPEND GENERATE_OPTIONS "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}") + list(APPEND GENERATE_OPTIONS "-DLIBRESSL_TESTS=off") + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + list(APPEND GENERATE_OPTIONS "-DMSVC=on") + list(APPEND GENERATE_OPTIONS "-DUSE_STATIC_MSVC_RUNTIMES=on") + endif() + + cmake_generate("${CMAKE_GENERATOR}" "${SRC_DIR}" "${BUILD_DIR}" "${GENERATE_OPTIONS}") + + unset(BUILD_OPTIONS) + list(APPEND BUILD_OPTIONS "--config Debug") + cmake_build("${BUILD_DIR}" "${BUILD_OPTIONS}" "") + + unset(BUILD_OPTIONS) + list(APPEND BUILD_OPTIONS "--config Release") + cmake_build("${BUILD_DIR}" "${BUILD_OPTIONS}" "") + + return() + else() + # single-configuration + unset(GENERATE_OPTIONS) + if(CMAKE_HOST_UNIX) + list(APPEND GENERATE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_LIST_DIR}/../mingw.toolchain.cmake") + endif(CMAKE_HOST_UNIX) + list(APPEND GENERATE_OPTIONS "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}") + list(APPEND GENERATE_OPTIONS "-DCMAKE_BUILD_TYPE=Release") + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + list(APPEND GENERATE_OPTIONS "-DMSVC=on") + list(APPEND GENERATE_OPTIONS "-DUSE_STATIC_MSVC_RUNTIMES=on") + endif() + + cmake_generate("${CMAKE_GENERATOR}" "${SRC_DIR}" "${BUILD_DIR}" "${GENERATE_OPTIONS}") + + if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles") + set(APPEND BUILD_TOOL_OPTIONS "-j") + endif() + + unset(BUILD_OPTIONS) + cmake_build("${BUILD_DIR}" "${BUILD_OPTIONS}" "${BUILD_TOOL_OPTIONS}") + + endif() +endif() Copied: branches/libressl_3_4_2/libs/lib_libressl.cmake (from rev 9674, branches/libressl_3_4_2_cmake/libs/lib_libressl.cmake) =================================================================== --- branches/libressl_3_4_2/libs/lib_libressl.cmake (rev 0) +++ branches/libressl_3_4_2/libs/lib_libressl.cmake 2022-01-04 15:47:53 UTC (rev 9679) @@ -0,0 +1,27 @@ + +include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake) + +set(REBRESSL_ROOT ${CMAKE_CURRENT_LIST_DIR}/libressl_${TOOLSET}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(REBRESSL_ROOT "${REBRESSL_ROOT}_x64") +endif() + +if(MINGW) + set(LIBRESSL_INCLUDE_DIRS + ${REBRESSL_ROOT}/include + ) + + set(LIBRESSL_LIB + ${REBRESSL_ROOT}/lib/libcrypto-47.a + bcrypt + ) +else() + set(LIBRESSL_INCLUDE_DIRS + ${REBRESSL_ROOT}/include + ) + + set(LIBRESSL_LIB + debug ${REBRESSL_ROOT}/lib/crypto-47d.lib + optimized ${REBRESSL_ROOT}/lib/crypto-47d.lib + ) +endif() Index: branches/libressl_3_4_2/teraterm =================================================================== --- branches/libressl_3_4_2/teraterm 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/teraterm 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/teraterm ___________________________________________________________________ Modified: svn:mergeinfo ## -1,7 +1,7 ## /branches/4-stable/teraterm:8924,9256-9257 /branches/drag_and_drop/teraterm:7130,7139,7141,7143-7147 /branches/flowctrl_dsrdtr/teraterm:7825-7827 -/branches/libressl_3_4_2_cmake/teraterm:9673,9675 +/branches/libressl_3_4_2_cmake/teraterm:9673-9675 /branches/move_code_script/teraterm:9026-9185 /branches/openssl_1_1_1_v2/teraterm:7819-7822,7829,7832-7834,7838-7843,7846-7847,7855-7856,7858,7861-7863,7979-7980 /branches/openssl_1_1_1_v3/teraterm:8258 Index: branches/libressl_3_4_2/ttpmenu =================================================================== --- branches/libressl_3_4_2/ttpmenu 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/ttpmenu 2022-01-04 15:47:53 UTC (rev 9679) Property changes on: branches/libressl_3_4_2/ttpmenu ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,4 ## /branches/4-stable/ttpmenu:9256-9257 -/branches/libressl_3_4_2_cmake/ttpmenu:9673,9675 +/branches/libressl_3_4_2_cmake/ttpmenu:9673-9675 /branches/ssh_chacha20poly1305/ttpmenu:9209-9212,9217,9229,9248-9253 /branches/vs2015_warn/ttpmenu:6194-6285 \ No newline at end of property Modified: branches/libressl_3_4_2/ttssh2/ttxssh/CMakeLists.txt =================================================================== --- branches/libressl_3_4_2/ttssh2/ttxssh/CMakeLists.txt 2022-01-04 15:41:56 UTC (rev 9678) +++ branches/libressl_3_4_2/ttssh2/ttxssh/CMakeLists.txt 2022-01-04 15:47:53 UTC (rev 9679) @@ -1,9 +1,15 @@ set(PACKAGE_NAME "ttxssh") +option(TTXSSH_LIBRESSL "User LibreSSL" on) + project(${PACKAGE_NAME}) include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_zlib.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_openssl.cmake) +if(TTXSSH_LIBRESSL) + include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_libressl.cmake) +else() + include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_openssl.cmake) +endif() add_library( ${PACKAGE_NAME} SHARED @@ -156,10 +162,23 @@ ../../teraterm/common ../matcher ../putty - ${OPENSSL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} -) + ) +if(TTXSSH_LIBRESSL) + target_include_directories( + ${PACKAGE_NAME} + PRIVATE + ${LIBRESSL_INCLUDE_DIRS} + ) +else() + target_include_directories( + ${PACKAGE_NAME} + PRIVATE + ${OPENSSL_INCLUDE_DIRS} + ) +endif() + set_target_properties( ${PACKAGE_NAME} PROPERTIES @@ -189,9 +208,24 @@ ttpcmn argon2 ${ZLIB_LIB} - ${OPENSSL_LIB} ) +if(TTXSSH_LIBRESSL) + target_link_libraries( + ${PACKAGE_NAME} + PRIVATE + ${LIBRESSL_LIB} + bcrypt.lib + ) +else() + target_link_libraries( + ${PACKAGE_NAME} + PRIVATE + ${OPENSSL_LIB} + crypt32.lib # TODO このlibを使用しないパッチを適応したら削除すること + ) +endif() + if(SUPPORT_OLD_WINDOWS) target_link_libraries( ${PACKAGE_NAME} @@ -207,8 +241,6 @@ gdi32 comdlg32 comctl32 - # OpenSSL が使用 - crypt32.lib # TODO このlibを使用しないパッチを適応したら削除すること ) ### create puttyversion.h