Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ctaocrypt/src/src/
*.cache
.dirstamp
*.user
configure
configure
config.*
!cmake/config.in
*Debug/
Expand Down
55 changes: 42 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ endif()

# SHA224
set(SHA224_DEFAULT "no")
if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
if(("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64") OR
("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
if(NOT WOLFSSL_AFALG AND NOT WOLFSSL_DEVCRYPTO AND
(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2")))
Expand All @@ -562,7 +562,7 @@ add_option("WOLFSSL_SHA224"

# SHA3
set(SHA3_DEFAULT "no")
if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
if(("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64") OR
("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
if(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2"))
set(SHA3_DEFAULT "yes")
Expand Down Expand Up @@ -1048,7 +1048,7 @@ endif()

# Base64
set(BASE64_ENCODE_DEFAULT "no")
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64")
set(BASE64_ENCODE_DEFAULT "yes")
endif()

Expand Down Expand Up @@ -1526,15 +1526,15 @@ if(WOLFSSL_FAST_MATH)
set(WOLFSSL_SLOWMATH "no")
endif()

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
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

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64")
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_X86_64_BUILD")
endif()

Expand Down Expand Up @@ -1833,10 +1833,6 @@ if(WOLFSSL_USER_SETTINGS)
endif()
endif()

# TODO: Applying definitions to everything like this, rather than
# individual targets, is discouraged in CMake.
add_definitions(${WOLFSSL_DEFINITIONS})

add_option("WOLFSSL_CONFIG_H"
"Enable generation of config.h and define HAVE_CONFIG_H (default: enabled)"
"yes" "yes;no")
Expand All @@ -1858,7 +1854,7 @@ message("Generating user options header...")
if (${CMAKE_DISABLE_SOURCE_CHANGES})
set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "${CMAKE_DISABLE_SOURCE_CHANGES}")
else()
set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "no")
set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "yes")
endif()
add_option("WOLFSSL_BUILD_OUT_OF_TREE"
"Don't generate files in the source tree (default: ${WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT})"
Expand Down Expand Up @@ -1920,7 +1916,13 @@ set(LIB_SOURCES "")
# Corresponds to the instances of "src_libwolfssl_la_SOURCES += ..."
# in the *.am files.
generate_lib_src_list("${LIB_SOURCES}")
add_library(wolfssl ${LIB_SOURCES})
if(BUILD_SHARED_LIBS)
add_library(wolfssl SHARED ${LIB_SOURCES})
else()
add_library(wolfssl STATIC ${LIB_SOURCES})
endif()

add_library(wolfssl::wolfssl ALIAS wolfssl)

set_target_properties(wolfssl
PROPERTIES
Expand All @@ -1932,6 +1934,7 @@ target_compile_definitions(wolfssl PRIVATE "BUILDING_WOLFSSL")
if(${BUILD_SHARED_LIBS})
target_compile_definitions(wolfssl PUBLIC "WOLFSSL_DLL")
endif()
target_compile_definitions(wolfssl PUBLIC ${WOLFSSL_DEFINITIONS})

####################################################
# Include Directories
Expand All @@ -1954,7 +1957,7 @@ target_link_libraries(wolfssl PUBLIC ${WOLFSSL_LINK_LIBS})
if(WIN32)
# For Windows link ws2_32
target_link_libraries(wolfssl PUBLIC
$<$<PLATFORM_ID:Windows>:ws2_32>)
$<$<PLATFORM_ID:Windows>:ws2_32 crypt32>)
elseif(APPLE)
if(WOLFSSL_SYS_CA_CERTS)
target_link_libraries(wolfssl PUBLIC
Expand Down Expand Up @@ -2275,7 +2278,8 @@ install(FILES
# Install the export set
install(EXPORT wolfssl-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl
FILE wolfssl-config.cmake)
FILE wolfssl-targets.cmake
NAMESPACE wolfssl::)

# TODO: Distro build + rules for what to include in the distro.
# See various include.am files.
Expand All @@ -2289,3 +2293,28 @@ 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
)

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
)
3 changes: 3 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@
Comment thread
oltolm marked this conversation as resolved.

include ( "${CMAKE_CURRENT_LIST_DIR}/wolfssl-targets.cmake" )
1 change: 1 addition & 0 deletions cmake/include.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
EXTRA_DIST += cmake/Config.cmake.in
EXTRA_DIST += cmake/config.in
EXTRA_DIST += cmake/functions.cmake
EXTRA_DIST += cmake/modules/FindOQS.cmake
2 changes: 1 addition & 1 deletion wolfssl/wolfcrypt/sp_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ extern "C" {
#ifndef SP_WORD_SIZE
#ifdef NO_64BIT
#define SP_WORD_SIZE 16
#elif !defined(HAVE___UINT128_T)
#elif !defined(HAVE___UINT128_T) || defined(_WIN32)
#define SP_WORD_SIZE 32
#else
#define SP_WORD_SIZE 64
Expand Down
2 changes: 1 addition & 1 deletion wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ decouple library dependencies with standard string, memory and so on.
#define WC_STRINGIFY(str) _WC_STRINGIFY_L2(str)

/* try to set SIZEOF_LONG or SIZEOF_LONG_LONG if user didn't */
#if defined(_MSC_VER) || defined(HAVE_LIMITS_H)
#if defined(_WIN32) || defined(HAVE_LIMITS_H)
/* make sure both SIZEOF_LONG_LONG and SIZEOF_LONG are set,
* otherwise causes issues with CTC_SETTINGS */
#if !defined(SIZEOF_LONG_LONG) || !defined(SIZEOF_LONG)
Expand Down