|
1 | 1 | cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
|
2 |
| - |
3 | 2 | set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
|
4 | 3 |
|
5 |
| -project(Keyak C) |
6 |
| - |
7 |
| -if(NOT CMAKE_VS_PLATFORM_NAME) |
8 |
| - set(CMAKE_VS_PLATFORM_NAME "x64") |
9 |
| -endif() |
10 |
| -message("${CMAKE_VS_PLATFORM_NAME} architecture in use") |
| 4 | +project(OceanKeyak C) |
11 | 5 |
|
12 |
| -if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64" |
13 |
| - OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")) |
14 |
| - message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!") |
15 |
| -endif() |
| 6 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
16 | 7 |
|
17 |
| -################################################################################ |
18 |
| -# Global configuration types |
19 |
| -################################################################################ |
20 |
| -set(CMAKE_CONFIGURATION_TYPES |
21 |
| - "Debug" |
22 |
| - "Release" |
23 |
| - CACHE STRING "" FORCE |
24 |
| -) |
25 | 8 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
26 |
| -find_package(Sodium REQUIRED) |
27 |
| - |
28 |
| - |
29 |
| -################################################################################ |
30 |
| -# Nuget packages function stub. |
31 |
| -################################################################################ |
32 |
| -function(use_package TARGET PACKAGE VERSION) |
33 |
| - message(WARNING "No implementation of use_package. Create yours. " |
34 |
| - "Package \"${PACKAGE}\" with version \"${VERSION}\" " |
35 |
| - "for target \"${TARGET}\" is ignored!") |
36 |
| -endfunction() |
37 |
| - |
38 | 9 |
|
39 |
| - |
40 |
| -################################################################################ |
41 |
| -# Use solution folders feature |
42 |
| -################################################################################ |
43 |
| -set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 10 | +find_package(Sodium REQUIRED) |
44 | 11 |
|
45 | 12 | ################################################################################
|
46 | 13 | # Sub-projects
|
47 | 14 | ################################################################################
|
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 |
| -set(PROJECT_NAME Keyak) |
76 |
| - |
77 |
| -################################################################################ |
78 |
| -# Source groups |
79 |
| -################################################################################ |
80 |
| -set(Header_Files |
81 |
| - "align.h" |
82 |
| - "api.h" |
83 |
| - "brg_endian.h" |
84 |
| - "config.h" |
85 |
| - "crypto_aead.h" |
86 |
| - "encrypt.h" |
87 |
| - "KeccakP-1600-times4-SIMD256.c" |
88 |
| - "KeccakP-1600-times4-SnP.h" |
89 |
| - "KeccakP-1600-unrolling.macros" |
90 |
| - "Keyakv2.h" |
91 |
| - "Keyakv2.inc" |
92 |
| - "Motorist.inc" |
93 |
| - "SIMD256-config.h" |
94 |
| -) |
95 |
| -source_group("Header Files" FILES ${Header_Files}) |
96 |
| - |
97 |
| -set(Source_Files |
98 |
| - "encrypt.c" |
99 |
| - "Keyak.c" |
100 |
| - "main.c" |
101 |
| -) |
102 |
| -source_group("Source Files" FILES ${Source_Files}) |
103 |
| - |
104 |
| -set(ALL_FILES |
105 |
| - ${Header_Files} |
106 |
| - ${Source_Files} |
107 |
| -) |
108 |
| - |
109 |
| -################################################################################ |
110 |
| -# Target |
111 |
| -################################################################################ |
112 |
| -add_executable(${PROJECT_NAME} ${ALL_FILES}) |
113 |
| - |
114 |
| -set(ROOT_NAMESPACE Keyak) |
115 |
| - |
116 |
| - |
117 |
| - |
118 |
| -################################################################################ |
119 |
| -# Compile and link options |
120 |
| -################################################################################ |
121 |
| -if(MSVC) |
122 |
| - |
123 |
| - set_target_properties(${PROJECT_NAME} PROPERTIES |
124 |
| - VS_GLOBAL_KEYWORD "Win32Proj" |
125 |
| - ) |
126 |
| - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") |
127 |
| - set_target_properties(${PROJECT_NAME} PROPERTIES |
128 |
| - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" |
129 |
| - ) |
130 |
| - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") |
131 |
| - set_target_properties(${PROJECT_NAME} PROPERTIES |
132 |
| - INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE" |
133 |
| - ) |
134 |
| - endif() |
135 |
| - ################################################################################ |
136 |
| - # Include directories |
137 |
| - ################################################################################ |
138 |
| - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") |
139 |
| - target_include_directories(${PROJECT_NAME} PUBLIC |
140 |
| - "${CMAKE_CURRENT_SOURCE_DIR}/" |
141 |
| - "D:/dev/c/libsodium/include" |
142 |
| - ) |
143 |
| - endif() |
144 |
| - |
145 |
| - ################################################################################ |
146 |
| - # Compile definitions |
147 |
| - ################################################################################ |
148 |
| - |
149 |
| - |
150 |
| - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") |
151 |
| - target_compile_definitions(${PROJECT_NAME} PRIVATE |
152 |
| - "$<$<CONFIG:Debug>:" |
153 |
| - "_CRT_SECURE_NO_WARNINGS;" |
154 |
| - "_DEBUG" |
155 |
| - ">" |
156 |
| - "$<$<CONFIG:Release>:" |
157 |
| - "NDEBUG" |
158 |
| - ">" |
159 |
| - "_CONSOLE;" |
160 |
| - "UNICODE;" |
161 |
| - "_UNICODE" |
162 |
| - ) |
163 |
| - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") |
164 |
| - target_compile_definitions(${PROJECT_NAME} PRIVATE |
165 |
| - "$<$<CONFIG:Debug>:" |
166 |
| - "_DEBUG" |
167 |
| - ">" |
168 |
| - "$<$<CONFIG:Release>:" |
169 |
| - "NDEBUG" |
170 |
| - ">" |
171 |
| - "WIN32;" |
172 |
| - "_CONSOLE;" |
173 |
| - "UNICODE;" |
174 |
| - "_UNICODE" |
175 |
| - ) |
176 |
| - endif() |
177 |
| - |
178 |
| - if (sodium_USE_STATIC_LIBS) |
179 |
| - string(APPEND _LINK_TYPE "/MT") |
180 |
| - else() |
181 |
| - string(APPEND _LINK_TYPE "/MT") |
182 |
| - endif() |
183 |
| - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") |
184 |
| - target_compile_options(${PROJECT_NAME} PRIVATE |
185 |
| - $<$<CONFIG:Release>: |
186 |
| - /Oi; |
187 |
| - /Gy |
188 |
| - > |
189 |
| - /permissive-; |
190 |
| - /sdl; |
191 |
| - /W3; |
192 |
| - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; |
193 |
| - ${DEFAULT_CXX_EXCEPTION_HANDLING}; |
194 |
| - ${_LINK_TYPE} |
195 |
| - ) |
196 |
| - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") |
197 |
| - target_compile_options(${PROJECT_NAME} PRIVATE |
198 |
| - $<$<CONFIG:Release>: |
199 |
| - /Oi; |
200 |
| - /Gy |
201 |
| - > |
202 |
| - /permissive-; |
203 |
| - /sdl; |
204 |
| - /W3; |
205 |
| - ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; |
206 |
| - ${DEFAULT_CXX_EXCEPTION_HANDLING}; |
207 |
| - ${_LINK_TYPE} |
208 |
| - ) |
209 |
| - endif() |
210 |
| - if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") |
211 |
| - target_link_options(${PROJECT_NAME} PRIVATE |
212 |
| - $<$<CONFIG:Debug>: |
213 |
| - /INCREMENTAL |
214 |
| - > |
215 |
| - $<$<CONFIG:Release>: |
216 |
| - /OPT:REF; |
217 |
| - /OPT:ICF; |
218 |
| - /INCREMENTAL:NO |
219 |
| - > |
220 |
| - /DEBUG; |
221 |
| - /SUBSYSTEM:CONSOLE |
222 |
| - ) |
223 |
| - elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86") |
224 |
| - target_link_options(${PROJECT_NAME} PRIVATE |
225 |
| - $<$<CONFIG:Debug>: |
226 |
| - /INCREMENTAL |
227 |
| - > |
228 |
| - $<$<CONFIG:Release>: |
229 |
| - /OPT:REF; |
230 |
| - /OPT:ICF; |
231 |
| - /INCREMENTAL:NO |
232 |
| - > |
233 |
| - /DEBUG; |
234 |
| - /SUBSYSTEM:CONSOLE |
235 |
| - ) |
236 |
| - endif() |
237 |
| -else() |
238 |
| - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2") |
239 |
| - # target_compile_definitions(${PROJECT_NAME} PRIVATE "-msse2") |
240 |
| -endif() |
241 |
| - |
242 |
| - |
243 |
| -target_link_libraries(${PROJECT_NAME} PUBLIC sodium PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") |
244 |
| - |
| 15 | +add_subdirectory(src) |
| 16 | +add_subdirectory(tests) |
0 commit comments