-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
62 lines (58 loc) · 2.71 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 3.9)
project(libQuickAES++ VERSION 1.0 DESCRIPTION "Encrypts and decrypts with AES cipher")
enable_testing()
include(GNUInstallDirs)
option(DECRYPTION_ENABLE "Disable it if you use this library only with CTR, OFB or CTR" ON)
option(ECB_ENABLE "Enable ECB" ON)
option(CBC_ENABLE "Enable CBC" ON)
option(OFB_ENABLE "Enable OFB" ON)
option(CTR_ENABLE "Enable CTR" ON)
option(CFB_ENABLE "Enable CFB" ON)
option(CFB8_ENABLE "Enable CFB8" ON)
option(BUILD_STATIC "Build static library" ON)
option(BUILD_TESTING "Build test" OFF)
option(INSTALL_CMAKE_FIND "Install CMake find file" ON)
if(UNIX)
option(INSTALL_PKGCONFIG_MODULE "Install pkg-config module" ON)
else()
option(INSTALL_PKGCONFIG_MODULE "Install pkg-config module" OFF)
endif()
if(BUILD_TESTING)
find_package(GTest REQUIRED)
include(GoogleTest)
endif()
configure_file(${CMAKE_SOURCE_DIR}/QuickAESOptions.hpp.in ${CMAKE_BINARY_DIR}/QuickAESOptions.hpp)
if(INSTALL_PKGCONFIG_MODULE)
configure_file(${CMAKE_SOURCE_DIR}/libQuickAES++.pc.in ${CMAKE_BINARY_DIR}/libQuickAES++.pc @ONLY)
endif()
if(INSTALL_CMAKE_FIND)
configure_file(${CMAKE_SOURCE_DIR}/FindQuickAES++.cmake.in ${CMAKE_BINARY_DIR}/FindQuickAES++.cmake @ONLY)
endif()
include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include)
add_library(QuickAES++_shared SHARED ${CMAKE_SOURCE_DIR}/src/AES.cpp ${CMAKE_SOURCE_DIR}/src/CipherModes.cpp)
if(BUILD_STATIC)
add_library(QuickAES++_static STATIC ${CMAKE_SOURCE_DIR}/src/AES.cpp ${CMAKE_SOURCE_DIR}/src/CipherModes.cpp)
set_target_properties(QuickAES++_static PROPERTIES OUTPUT_NAME QuickAES++ ARCHIVE_OUTPUT_DIRECTORY Static)
endif()
set_target_properties(QuickAES++_shared PROPERTIES OUTPUT_NAME QuickAES++)
if(BUILD_TESTING)
add_executable(Test ${CMAKE_SOURCE_DIR}/src/AES.cpp ${CMAKE_SOURCE_DIR}/src/CipherModes.cpp ${CMAKE_SOURCE_DIR}/test/Test.cpp)
target_link_libraries(Test GTest::gtest GTest::gtest_main)
gtest_add_tests(TARGET Test TEST_SUFFIX .noArgs AUTO)
endif()
install(TARGETS QuickAES++_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(BUILD_STATIC)
install(TARGETS QuickAES++_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${CMAKE_SOURCE_DIR}/include/QuickAES++.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/QuickAESOptions.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(INSTALL_PKGCONFIG_MODULE)
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
install(FILES ${CMAKE_BINARY_DIR}/libQuickAES++.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig)
else()
install(FILES ${CMAKE_BINARY_DIR}/libQuickAES++.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
endif()
if(INSTALL_CMAKE_FIND)
install(FILES ${CMAKE_BINARY_DIR}/FindQuickAES++.cmake DESTINATION ${CMAKE_ROOT}/Modules)
endif()