-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathCMakeLists.txt
132 lines (113 loc) · 4.07 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
123
124
125
126
127
128
129
130
131
cmake_minimum_required(VERSION 3.5)
message(STATUS "CMake version ${CMAKE_VERSION}")
project(Whitebox_crypto_AES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
option(NTL_NO_DEFAULT_PATH "Using just given paths when searching for NTL" OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCE_FILES
base.h
base.cpp
BGEAttack.cpp
BGEAttack.h
GenericAES.cpp
GenericAES.h
LinearAffineEq.cpp
LinearAffineEq.h
LinearAffineEq_test.cpp
md5.c
md5.h
MixingBijections.cpp
MixingBijections.h
NTLUtils.cpp
NTLUtils.h
WBAES.cpp
WBAES.h
WBAESGenerator.cpp
WBAESGenerator.h
RingBuffer.h
RingBuffer.cpp
EncTools.cpp
EncTools.h
InputObject.cpp
InputObject.h
InputObjectBuffer.cpp
InputObjectBuffer.h
InputObjectIstream.cpp
InputObjectIstream.h
InputObjectOstream.cpp
InputObjectOstream.h
InputObjectIOstream.cpp
InputObjectIOstream.h
)
set(TEST_SOURCE_FILES
tests/WBAes.cpp
tests/tester.cpp
tests/Commons.cpp
tests/Commons.h
tests/RingBufferTest.cpp
tests/EncToolsTest.cpp
)
add_executable(main ${SOURCE_FILES} main.cpp)
add_executable(testing ${SOURCE_FILES} testing.cpp testing.h)
add_executable(gtesting ${SOURCE_FILES} ${TEST_SOURCE_FILES})
# GMP
find_library(GMP_LIB NAMES libgmp.a libgmp.so libgmp.dylib gmp PATHS ${CMAKE_CURRENT_SOURCE_DIR} $ENV{HOME}/ntl $ENV{HOME}/ntl/lib /usr/local /opt/local /opt/homebrew /usr ${NTL_MODIF})
if(NOT GMP_LIB)
message(FATAL_ERROR "GMP library not found. Rerun cmake with -DCMAKE_PREFIX_PATH=\"<path to lib1>;<path to lib2>\"")
endif()
message("GMP_LIB: ${GMP_LIB}")
# NTL
if (NTL_NO_DEFAULT_PATH)
set(NTL_MODIF NO_DEFAULT_PATH)
message("Not using default paths for NTL search, ${NTL_MODIF}")
endif (NTL_NO_DEFAULT_PATH)
message("HOME: $ENV{HOME}")
find_path(NTL_INCLUDE_PATH NAMES NTL/mat_GF2.h PATHS $ENV{HOME}/ntl $ENV{HOME}/ntl/include /usr/local /opt/local /opt/homebrew /usr ${NTL_MODIF})
message("NTL_INCLUDE_PATH: ${NTL_INCLUDE_PATH}")
find_library(NTL_LIB ntl PATHS ${CMAKE_CURRENT_SOURCE_DIR} $ENV{HOME}/ntl $ENV{HOME}/ntl/lib /usr/local /opt/local /opt/homebrew /usr ${NTL_MODIF})
if(NOT NTL_LIB)
message(FATAL_ERROR "ntl library not found. Rerun cmake with -DCMAKE_PREFIX_PATH=\"<path to lib1>;<path to lib2>\"")
endif()
message("NTL_LIB: ${NTL_LIB}")
include_directories(${NTL_INCLUDE_PATH})
# BOOST
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS program_options serialization iostreams random)
include_directories(${Boost_INCLUDE_DIRS})
# We need thread support
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package( Threads )
#find_package(Threads REQUIRED)
# CMakeLists-gtest.txt.in
# Download and unpack googletest at configure time
configure_file(CMakeLists-gtest.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download"
)
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download"
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This adds the following targets:
# gtest, gtest_main, gmock and gmock_main
add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src"
"${CMAKE_BINARY_DIR}/googletest-build"
)
if(CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include"
"${gmock_SOURCE_DIR}/include"
)
endif()
# Linking
if(NOT MSVC)
set(PThreadLib -pthread)
endif()
target_link_libraries(main ${NTL_LIB} ${GMP_LIB} ${Boost_LIBRARIES} ${PThreadLib})
target_link_libraries(testing ${NTL_LIB} ${GMP_LIB} ${Boost_LIBRARIES} ${PThreadLib})
target_link_libraries(gtesting ${NTL_LIB} ${GMP_LIB} ${Boost_LIBRARIES} gtest_main ${CMAKE_THREAD_LIBS_INIT} ${PThreadLib})
add_test(NAME WBTests COMMAND gtesting)