2024-12-20 02:03:16 +00:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
|
|
|
|
|
|
project(libaes VERSION 0.0.1 LANGUAGES CXX)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2024-12-20 21:02:40 +00:00
|
|
|
set(SOURCES)
|
|
|
|
if (USE_WIN_CRYPTO)
|
2024-12-21 15:38:37 +00:00
|
|
|
message("Using Windows Crypto API for AES-CBC-128")
|
2024-12-20 21:02:40 +00:00
|
|
|
list(APPEND SOURCES aes_win32.cpp)
|
2024-12-21 15:38:37 +00:00
|
|
|
elseif (USE_OPENSSL)
|
|
|
|
message("Using OpenSSL API for AES-CBC-128")
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
list(APPEND SOURCES aes_openssl.cpp)
|
2024-12-20 21:02:40 +00:00
|
|
|
else ()
|
|
|
|
# Tiny AES in C (https://github.com/kokke/tiny-AES-c/)
|
|
|
|
# is licensed under the Unlicense license.
|
2024-12-21 15:38:37 +00:00
|
|
|
message("Using included AES-CBC-128 implementation")
|
2024-12-20 21:02:40 +00:00
|
|
|
list(APPEND SOURCES aes.cpp)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
add_library(libaes STATIC ${SOURCES})
|
2024-12-20 02:03:16 +00:00
|
|
|
target_include_directories(libaes
|
|
|
|
PUBLIC
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
|
|
|
)
|
2024-12-20 21:02:40 +00:00
|
|
|
if (USE_WIN_CRYPTO)
|
|
|
|
target_link_libraries(libaes PRIVATE bcrypt)
|
|
|
|
target_compile_definitions(libaes PRIVATE USE_WIN_CRYPTO=1)
|
2024-12-21 15:38:37 +00:00
|
|
|
elseif (USE_OPENSSL)
|
|
|
|
target_link_libraries(libaes PRIVATE OpenSSL::Crypto)
|
|
|
|
target_compile_definitions(libaes PRIVATE USE_OPENSSL=1)
|
2024-12-20 21:02:40 +00:00
|
|
|
endif ()
|