-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
101 lines (84 loc) · 2.67 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
cmake_minimum_required(VERSION 3.8)
set(DDON_BRUTEFORCE_EXE ddon_common_key_bruteforce)
set(DDON_ENABLE_SIMD 0)
set(DDON_ENABLE_ASM 0)
if (DDON_ENABLE_SIMD)
message("SIMD enabled")
endif ()
if (DDON_ENABLE_ASM)
message("ASM enabled")
endif ()
project(${DDON_BRUTEFORCE_EXE})
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
message(FATAL_ERROR "Cannot be compiled clang-cl due to https://github.com/p-ranav/argparse/issues/136.")
endif ()
endif ()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
message(Project: ${PROJECT_NAME})
message(BuildType: ${CMAKE_BUILD_TYPE})
message(CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID})
message(CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME})
IF (CMAKE_BUILD_TYPE MATCHES Debug)
set(DDON_DEBUG TRUE)
ENDIF()
# Set MSVC optimization flags
if (MSVC)
set(CMAKE_CXX_FLAGS "/O2 /Oi /Ot /Oy /EHsc")
endif ()
set(DDON_BRUTEFORCE_EXE_SOURCES
src/seeded_xorshift_128.hpp
src/ctpl_stl.h
src/camellia.h
src/camellia.c
src/argparse.hpp
src/main.cpp
src/depth_brute_force.h
src/ddon_random.hpp
)
add_executable(${DDON_BRUTEFORCE_EXE} ${DDON_BRUTEFORCE_EXE_SOURCES})
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
IF (DDON_DEBUG)
message([LOWL] Setting Debug Flags)
target_compile_options(${DDON_BRUTEFORCE_EXE} PRIVATE
-O0
-Werror
)
ELSE()
message([LOWL] Setting Release Flags)
target_compile_options(${DDON_BRUTEFORCE_EXE} PRIVATE
-O2
-Werror
)
ENDIF ()
endif ()
if (DDON_ENABLE_SIMD)
# camellia_simd
target_compile_definitions(${DDON_BRUTEFORCE_EXE} PUBLIC DDON_SIMD_ENABLED)
set(CAMELLIA_SIMD camellia_simd_lib)
if (DDON_ENABLE_ASM)
enable_language(ASM)
set(CAMELLIA_SIMD_SOURCES
camellia-simd-aesni/camellia_simd128_x86-64_aesni_avx.S
)
else ()
set(CAMELLIA_SIMD_SOURCES
camellia-simd-aesni/camellia_simd128_with_aes_instruction_set.c
)
endif ()
add_library(${CAMELLIA_SIMD} STATIC ${CAMELLIA_SIMD_SOURCES})
target_include_directories(${CAMELLIA_SIMD} PUBLIC camellia-simd-aesni/)
target_compile_options(${CAMELLIA_SIMD} PUBLIC
-maes
-mavx2
#-msse4.1
-mtune=native
-march=sandybridge
)
#target_link_options(${CAMELLIA_SIMD} PUBLIC
# LINKER:-lcrypto
# )
target_link_libraries(${DDON_BRUTEFORCE_EXE} PUBLIC ${CAMELLIA_SIMD})
endif ()