-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
139 lines (118 loc) · 4.87 KB
/
Copy pathCMakeLists.txt
File metadata and controls
139 lines (118 loc) · 4.87 KB
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
139
cmake_minimum_required(VERSION 3.11.0 FATAL_ERROR)
project(corax)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(simd)
include(warningFlags)
# GoogleTest needs at least C++14; we decided against C++17 for now, as it's not widely available on
# cluster systems.
set(CMAKE_CXX_STANDARD 14)
include(CTest)
# Enable ctest for the current subdirectory and below.
enable_testing()
# Options - user settable
option(CORAX_BUILD_DOCS "Build (Doxygen) documentation" Off)
option(CORAX_BUILD_TESTS "Build the automatic tests" Off)
option(CORAX_BUILD_BENCHMARKS "Build the benchmarks" Off)
option(CORAX_BUILD_DIFFICULTY_PREDICTION "Build difficulty prediction module" Off)
option(CORAX_ENABLE_SSE "Enable SSE SIMD kernels if supported by compiler" On)
option(CORAX_ENABLE_AVX "Enable AVX SIMD kernels if supported by compiler" On)
option(CORAX_ENABLE_AVX2 "Enable AVX2 SIMD kernels if supported by compiler" On)
option(CORAX_ENABLE_NEON "Enable NEON SIMD kernels if supported by compiler" On)
option(CORAX_BUILD_SHARED "Build a shared library" Off)
option(CORAX_BUILD_PORTABLE "Build a shared library" Off)
# Uncomment to build a semi-portable binary, e.g. for Intel Haswell and above:
#set(CORAX_BUILD_PORTABLE_ARCH "haswell")
# Options - user overridable (hidden)
set(CORAX_ENABLE_AUTOVEC_KERNELS On CACHE BOOL "Enable auto-vectorization of generic kernels")
set(CORAX_ENABLE_AUTOVEC_OTHER On CACHE BOOL "Enable auto-vectorization of non-kernel code")
if (DEFINED BUILD_SHARED_LIBS AND NOT (CORAX_BUILD_SHARED))
message(
WARNING
"BUILD_SHARED_LIBS is set, but CORAX_BUILD_SHARED is Off. Setting CORAX_BUILD_SHARED to On."
)
set(CORAX_BUILD_SHARED On)
endif ()
# Default the build type to Release
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type" FORCE
)
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release")
endif ()
#check whether to use compiler auto-vectorization
if (CORAX_BUILD_PORTABLE)
if((CMAKE_VERSION VERSION_LESS "3.18") AND (CORAX_BUILD_PORTABLE_ARCH STREQUAL "x86-64"))
message(FATAL_ERROR "Fully portable builds are not supported with CMake <3.18.\n"
"You can add e.g. -DCORAX_BUILD_PORTABLE_ARCH=haswell to build for modern x86 CPUs.")
endif()
set(CORAX_ENABLE_AUTOVEC_KERNELS Off CACHE BOOL "Enable auto-vectorization of generic kernels" FORCE)
set(CORAX_ENABLE_AUTOVEC_OTHER Off CACHE BOOL "Enable auto-vectorization of non-kernel code" FORCE)
endif()
# Check for available SIMD variants and disable not available ones.
check_sse_available()
if (NOT SSE_AVAILABLE)
message(STATUS "SSE SIMD not supported -> disabling")
set(CORAX_ENABLE_SSE Off)
endif ()
check_avx_available()
if (NOT AVX_AVAILABLE)
message(STATUS "AVX SIMD not supported -> disabling")
set(CORAX_ENABLE_AVX Off)
endif ()
check_avx2_available()
if (NOT AVX2_AVAILABLE)
message(STATUS "AVX2 SIMD not supported -> disabling")
set(CORAX_ENABLE_AVX2 Off)
endif ()
if (NOT DEFINED CORAX_ENABLE_SSE2NEON)
SET(CORAX_ENABLE_SSE2NEON On)
endif ()
if(CORAX_ENABLE_SSE2NEON)
check_sse2neon_available()
if (NOT SSE2NEON_AVAILABLE)
message(STATUS "NEON SIMD not supported -> disabling")
set(CORAX_ENABLE_SSE2NEON Off)
endif ()
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if (CORAX_BUILD_SHARED)
message(STATUS "Building coraxlib as a shared library.")
else ()
message(STATUS "Building coraxlib as a static library.")
endif ()
message(STATUS "Building documentation: ${CORAX_BUILD_DOCS}")
message(STATUS "Building tests: ${CORAX_BUILD_TESTS}")
message(STATUS "Building benchmarks: ${CORAX_BUILD_BENCHMARKS}")
message(STATUS "Building difficulty prediction: ${CORAX_BUILD_DIFFICULTY_PREDICTION}")
message(STATUS "Build portable library: ${CORAX_BUILD_PORTABLE}")
message(STATUS "Enable SSE SIMD kernels: ${CORAX_ENABLE_SSE}")
message(STATUS "Enable AVX SIMD kernels: ${CORAX_ENABLE_AVX}")
message(STATUS "Enable AVX2 SIMD kernels: ${CORAX_ENABLE_AVX2}")
message(STATUS "Enable NEON SIMD kernels: ${CORAX_ENABLE_SSE2NEON}")
# Configuration which is not user settable
set(CORAX_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/src
CACHE INTERNAL "${PROJECT_NAME}: Include dirs"
)
# Build the difficulty prediction if requested.
if (CORAX_BUILD_DIFFICULTY_PREDICTION)
add_subdirectory(lib/difficulty_prediction)
endif ()
# Build the corax library
add_subdirectory(src/corax)
# Build the documentation if requested.
if (CORAX_BUILD_DOCS)
add_subdirectory(docs)
endif ()
# Build the tests if requested.
if (CORAX_BUILD_TESTS)
add_subdirectory(test)
if(CORAX_BUILD_DIFFICULTY_PREDICTION)
add_subdirectory(lib/difficulty_prediction/test)
endif()
endif (CORAX_BUILD_TESTS)
# Build the benchmarks if requested.
if (CORAX_BUILD_BENCHMARKS)
add_subdirectory(bench)
endif (CORAX_BUILD_BENCHMARKS)