-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (101 loc) · 3.04 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 3.12)
project(SEALCRYPT VERSION 1.0.0 LANGUAGES CXX)
# Enable testing
include(CTest)
enable_testing()
# Set C++ standard (SEAL requires C++17 or higher)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find Microsoft SEAL package
find_package(SEAL REQUIRED)
# Function to check SEAL configuration
if(NOT SEAL_FOUND)
message(FATAL_ERROR "Microsoft SEAL not found. Please install SEAL or provide its location.")
endif()
# Check if SEAL was built with the required features
if(SEAL_USE_CXX17)
message(STATUS "SEAL C++17 support: YES")
else()
message(WARNING "SEAL was not built with C++17 support. This might cause issues.")
endif()
# Optional: Check for specific SEAL components you need
if(SEAL_USE_ZLIB)
message(STATUS "SEAL ZLIB support: YES")
else()
message(STATUS "SEAL ZLIB support: NO")
endif()
# Define source files for the library
set(SEALCRYPT_LIB_SOURCES
src/encrypt.cpp
src/decrypt.cpp
src/file_handler.cpp
)
# Define headers
set(SEALCRYPT_HEADERS
include/sealcrypt/encrypt.hpp
include/sealcrypt/decrypt.hpp
include/sealcrypt/file_handler.hpp
)
# Create library target
add_library(sealcrypt ${SEALCRYPT_LIB_SOURCES})
add_library(sealcrypt::sealcrypt ALIAS sealcrypt)
# Set include directories and link with SEAL
target_include_directories(sealcrypt
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Link against SEAL
target_link_libraries(sealcrypt
PUBLIC
SEAL::seal
)
# Create executable if this is the main project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(src)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
endif()
# Installation rules
install(TARGETS sealcrypt
EXPORT sealcrypt-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
install(FILES ${SEALCRYPT_HEADERS}
DESTINATION include/sealcrypt
)
install(EXPORT sealcrypt-targets
FILE sealcrypt-targets.cmake
NAMESPACE sealcrypt::
DESTINATION lib/cmake/sealcrypt
)
# Create and install package config files
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/sealcrypt-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/sealcrypt-config.cmake"
INSTALL_DESTINATION lib/cmake/sealcrypt
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/sealcrypt-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/sealcrypt-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/sealcrypt-config-version.cmake"
DESTINATION lib/cmake/sealcrypt
)
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()