forked from neilharan/openafis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (69 loc) · 2.5 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
cmake_minimum_required (VERSION 3.9)
project(openafis CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
include(CheckCXXCompilerFlag)
include(AddCXXCompilerFlag)
if (MSVC)
string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
add_cxx_compiler_flag(/GS-)
add_cxx_compiler_flag(/Ob2)
add_cxx_compiler_flag(/Oi)
add_cxx_compiler_flag(/Ot)
add_cxx_compiler_flag(/Oy)
add_cxx_compiler_flag(/GT)
add_cxx_compiler_flag(/Zc:__cplusplus)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_cxx_compiler_flag(/QIntel-jcc-erratum)
add_cxx_compiler_flag(/fp:fast)
else()
add_cxx_compiler_flag(-march=native)
endif()
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REPLACE /GR /GR- "${flag_var}" "${${flag_var}}")
string(REPLACE /EHsc /EHsc- "${flag_var}" "${${flag_var}}")
endforeach()
add_definitions(-D_HAS_EXCEPTIONS=0)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
add_cxx_compiler_flag(-O3)
add_cxx_compiler_flag(-march=native)
add_cxx_compiler_flag(-mtune=native)
add_cxx_compiler_flag(-Wall)
add_cxx_compiler_flag(-Wextra)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror)
add_cxx_compiler_flag(-pedantic)
add_cxx_compiler_flag(-pedantic-errors)
add_cxx_compiler_flag(-Wshorten-64-to-32)
add_cxx_compiler_flag(-fstrict-aliasing)
add_cxx_compiler_flag(-Wno-deprecated)
add_cxx_compiler_flag(-fno-exceptions)
add_cxx_compiler_flag(-Wthread-safety)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
find_program(GCC_AR gcc-ar)
if (GCC_AR)
set(CMAKE_AR ${GCC_AR})
endif()
find_program(GCC_RANLIB gcc-ranlib)
if (GCC_RANLIB)
set(CMAKE_RANLIB ${GCC_RANLIB})
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
include(llvm-toolchain)
endif()
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
add_subdirectory(lib)
add_subdirectory(cli)