forked from catid/siamese
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (110 loc) · 3.47 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
132
133
134
135
136
137
138
cmake_minimum_required(VERSION 3.5)
project(siamese LANGUAGES C CXX)
################################################################################
# Configuration
# Verbose compilation?
#set(CMAKE_VERBOSE_MAKEFILE ON)
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(arm_neon.h HAVE_ARM_NEON_H)
################################################################################
# Build Settings
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# In debug mode, add -DDEBUG
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
# Warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
# Remove Asio warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
# Static library: -fPIC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# Gprof Profiling
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -fstack-protector")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions -Os -Wall -Wextra -ffunction-sections -Wl,--gc-sections")
################################################################################
# Dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
################################################################################
# Source Files
set(INCLUDE_FILES
gf256.h
Logger.h
PacketAllocator.h
SiameseCommon.h
SiameseDecoder.h
SiameseEncoder.h
siamese.h
SiameseSerializers.h
SiameseTools.h
)
set(SOURCE_FILES
${INCLUDE_FILES}
gf256.cpp
Logger.cpp
PacketAllocator.cpp
SiameseCommon.cpp
siamese.cpp
SiameseDecoder.cpp
SiameseEncoder.cpp
SiameseTools.cpp
)
if(BUILD_TEST)
set(TEST_FILES
${SOURCE_FILES}
#tests/gentab_primes.cpp
#tests/GF256Matrix.cpp
#tests/GF256Matrix.h
#tests/test_allocator.cpp
#tests/test_custom_bitset.cpp
#tests/test_invert_rate.cpp
#tests/test_recovery_sort.cpp
#tests/test_serializers.cpp
tests/TestTools.cpp
tests/TestTools.h
tests/unit_test.cpp
)
endif(BUILD_TEST)
################################################################################
# Targets
# library
add_library(siamese STATIC ${SOURCE_FILES})
target_link_libraries(siamese
Threads::Threads
)
#install(TARGETS siamese DESTINATION lib)
set_target_properties(siamese PROPERTIES PUBLIC_HEADER "gf256.h;Logger.h;PacketAllocator.h;SiameseCommon.h;SiameseDecoder.h;SiameseEncoder.h;siamese.h;SiameseSerializers.h;SiameseTools.h")
INSTALL(TARGETS siamese
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
target_include_directories(siamese PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR})
# Application (unit test)
if(BUILD_TEST)
add_executable(unit_test ${TEST_FILES})
enable_testing()
add_test(unit
bin/unit_test
)
target_link_libraries(unit_test
Threads::Threads
)
install(TARGETS unit_test DESTINATION bin)
endif(BUILD_TEST)