diff --git a/CMakeLists.txt b/CMakeLists.txt index 338dacf4ea..99fdc57ee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,8 @@ if(WOLFSSL_REPRODUCIBLE_BUILD) set(CMAKE_C_ARCHIVE_FINISH " -D ") endif() +add_option("WOLFSSL_INSTALL" "Create install target for WolfSSL project" "no" "yes;no") + # Support for forcing 32-bit mode # TODO: detect platform from other options add_option("WOLFSSL_32BIT" @@ -1568,17 +1570,14 @@ if(WOLFSSL_FAST_MATH) list(APPEND WOLFSSL_DEFINITIONS "-DUSE_FAST_MATH") set(WOLFSSL_SLOWMATH "no") endif() - - if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64") - # Have settings.h set FP_MAX_BITS higher if user didn't set directly - list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_X86_64_BUILD") - endif() endif() # TODO: - Fast huge math # Set processor-specific build macros if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64") + set(WOLFSSL_X86_64_BUILD ON) + add_option("WOLFSSL_X86_64_BUILD_ASM" "Build ASM files" "yes" "yes;no") list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_X86_64_BUILD") elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64|arm64") list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AARCH64_BUILD") @@ -2413,82 +2412,86 @@ list(JOIN HEADER_EXCLUDE "|" EXCLUDED_HEADERS_REGEX) string(PREPEND EXCLUDED_HEADERS_REGEX "(") string(APPEND EXCLUDED_HEADERS_REGEX ")") -set(INSTALLED_EXAMPLES - ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client-dtls.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server-dtls.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c - ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c) - -# Install the library -install(TARGETS wolfssl - EXPORT wolfssl-targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - ) -# Install the headers -install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/wolfssl/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl - FILES_MATCHING PATTERN "*.h" - REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl - FILES_MATCHING PATTERN "*.h" - REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE) - -# Install the examples -install(FILES ${INSTALLED_EXAMPLES} - DESTINATION ${CMAKE_INSTALL_DOCDIR}/example) -# Install README.txt and taoCert.txt -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/doc/README.txt - ${CMAKE_CURRENT_SOURCE_DIR}/certs/taoCert.txt - DESTINATION ${CMAKE_INSTALL_DOCDIR}) -# Install the export set -install(EXPORT wolfssl-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl - FILE wolfssl-targets.cmake - NAMESPACE wolfssl::) - -# TODO: Distro build + rules for what to include in the distro. -# See various include.am files. - -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix "\${prefix}") -set(libdir "\${exec_prefix}/lib") -set(includedir "\${prefix}/include") -set(VERSION ${PROJECT_VERSION}) - -configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - -include(CMakePackageConfigHelpers) -configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl" - NO_SET_AND_CHECK_MACRO - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) +if(WOLFSSL_INSTALL) + + set(INSTALLED_EXAMPLES + ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client-dtls.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server-dtls.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c + ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c) -export(EXPORT wolfssl-targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-targets.cmake" - NAMESPACE wolfssl:: -) -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config-version.cmake" - VERSION "${wolfssl_VERSION_MAJOR}.${wolfssl_VERSION_MINOR}" - COMPATIBILITY AnyNewerVersion -) + # Install the library + install(TARGETS wolfssl + EXPORT wolfssl-targets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + ) + # Install the headers + install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/wolfssl/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl + FILES_MATCHING PATTERN "*.h" + REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl + FILES_MATCHING PATTERN "*.h" + REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE) + + # Install the examples + install(FILES ${INSTALLED_EXAMPLES} + DESTINATION ${CMAKE_INSTALL_DOCDIR}/example) + # Install README.txt and taoCert.txt + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/doc/README.txt + ${CMAKE_CURRENT_SOURCE_DIR}/certs/taoCert.txt + DESTINATION ${CMAKE_INSTALL_DOCDIR}) + # Install the export set + install(EXPORT wolfssl-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl + FILE wolfssl-targets.cmake + NAMESPACE wolfssl::) + + # TODO: Distro build + rules for what to include in the distro. + # See various include.am files. + + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix "\${prefix}") + set(libdir "\${exec_prefix}/lib") + set(includedir "\${prefix}/include") + set(VERSION ${PROJECT_VERSION}) + + configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + + include(CMakePackageConfigHelpers) + configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl -) + export(EXPORT wolfssl-targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-targets.cmake" + NAMESPACE wolfssl:: + ) + + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config-version.cmake" + VERSION "${wolfssl_VERSION_MAJOR}.${wolfssl_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/wolfssl-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl + ) +endif() diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 47ab832653..757054a251 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -280,7 +280,7 @@ function(generate_build_flags) if(WOLFSSL_SP_ARM_CORTEX_ASM OR WOLFSSL_USER_SETTINGS) set(BUILD_SP_ARM_CORTEX "yes" PARENT_SCOPE) endif() - if(WOLFSSL_SP_X86_64_ASM OR WOLFSSL_USER_SETTINGS) + if(WOLFSSL_X86_64_BUILD AND (WOLFSSL_SP_X86_64_ASM OR WOLFSSL_USER_SETTINGS)) set(BUILD_SP_X86_64 "yes" PARENT_SCOPE) endif() if(WOLFSSL_SP_MATH OR WOLFSSL_SP_MATH_ALL OR WOLFSSL_USER_SETTINGS) @@ -510,9 +510,10 @@ function(generate_lib_src_list LIB_SOURCES) endif() if(BUILD_SP_X86_64) - list(APPEND LIB_SOURCES - wolfcrypt/src/sp_x86_64.c - wolfcrypt/src/sp_x86_64_asm.S) + list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64.c) + if(WOLFSSL_X86_64_BUILD_ASM) + list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64_asm.S) + endif() endif() if(NOT BUILD_FIPS_V2 AND BUILD_SP_ARM32)