2025-12-04 21:13:31 +05:30
|
|
|
cmake_minimum_required(VERSION 3.30)
|
2021-03-07 23:46:39 +05:30
|
|
|
project(blowfish VERSION 1.0.0 LANGUAGES CXX)
|
2021-02-16 17:52:55 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
|
|
|
|
message(STATUS "Project version: ${PROJECT_VERSION}")
|
2021-02-16 17:52:55 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
# ===== compiler settings =====
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2021-03-07 23:46:39 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2021-02-16 17:52:55 +05:30
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2025-12-04 21:13:31 +05:30
|
|
|
message(STATUS "Using C++ standard c++${CMAKE_CXX_STANDARD}")
|
2021-02-16 17:52:55 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
set(BF_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
|
2021-03-07 23:46:39 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
# ===== blowfish library =====
|
|
|
|
|
add_library(blowfish)
|
|
|
|
|
target_compile_features(blowfish PUBLIC cxx_std_17)
|
2021-02-16 17:52:55 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
target_sources(blowfish
|
|
|
|
|
PRIVATE
|
|
|
|
|
src/blowfish.cc
|
|
|
|
|
PUBLIC FILE_SET HEADERS
|
|
|
|
|
BASE_DIRS ${BF_INCLUDE_DIR}
|
|
|
|
|
FILES include/blowfish/blowfish.h
|
2021-02-16 17:52:55 +05:30
|
|
|
)
|
|
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
target_include_directories(blowfish PUBLIC ${BF_INCLUDE_DIR})
|
2021-02-16 17:52:55 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
# ===== blowfish2 library =====
|
|
|
|
|
add_library(blowfish2)
|
|
|
|
|
target_compile_features(blowfish2 PUBLIC cxx_std_14)
|
2024-09-05 21:08:04 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
target_sources(blowfish2
|
|
|
|
|
PRIVATE
|
|
|
|
|
src/blowfish2.cc
|
|
|
|
|
PUBLIC FILE_SET HEADERS
|
|
|
|
|
BASE_DIRS ${BF_INCLUDE_DIR}
|
|
|
|
|
FILES include/blowfish/blowfish2.h
|
|
|
|
|
)
|
2024-09-05 21:08:04 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
target_include_directories(blowfish2 PUBLIC ${BF_INCLUDE_DIR})
|
2024-09-05 21:08:04 +05:30
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
# ===== Tests =====
|
|
|
|
|
include(CTest)
|
2025-12-06 18:23:08 +05:30
|
|
|
if (BUILD_TESTING)
|
|
|
|
|
|
|
|
|
|
# ---- Blowfish Test ----
|
|
|
|
|
add_executable(bf_test
|
|
|
|
|
tests/Main.cpp
|
|
|
|
|
tests/test_framework.h
|
|
|
|
|
tests/test_vectors.cpp
|
|
|
|
|
tests/test_roundtrip.cpp
|
|
|
|
|
tests/test_avalanche.cpp
|
|
|
|
|
tests/test_properties.cpp
|
|
|
|
|
)
|
2025-12-04 21:13:31 +05:30
|
|
|
target_link_libraries(bf_test PRIVATE blowfish)
|
2025-12-06 18:23:08 +05:30
|
|
|
add_test(NAME BlowfishTests COMMAND bf_test)
|
2024-09-05 21:08:04 +05:30
|
|
|
|
2025-12-06 18:23:08 +05:30
|
|
|
# ---- Blowfish2 Test ----
|
|
|
|
|
add_executable(bf2_test
|
|
|
|
|
tests/Main2.cpp
|
|
|
|
|
tests/test_framework.h
|
|
|
|
|
tests/bf2_test_vectors.cpp
|
|
|
|
|
tests/bf2_test_roundtrip.cpp
|
|
|
|
|
tests/bf2_test_avalanche.cpp
|
|
|
|
|
tests/bf2_test_properties.cpp
|
|
|
|
|
)
|
2025-12-04 21:13:31 +05:30
|
|
|
target_link_libraries(bf2_test PRIVATE blowfish2)
|
2025-12-06 18:23:08 +05:30
|
|
|
add_test(NAME Blowfish2Tests COMMAND bf2_test)
|
|
|
|
|
|
2025-12-04 21:13:31 +05:30
|
|
|
endif()
|