-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
72 lines (61 loc) · 2.31 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
cmake_minimum_required(VERSION 3.4)
project(pocket-tensor-project)
# Define build options:
option(PT_BUILD_ALL "Build all pocket-tensor artefacts" OFF)
option(PT_BUILD_TESTS "Build pocket-tensor tests" OFF)
option(PT_BUILD_BENCHMARK "Build pocket-tensor benchmark" OFF)
# Define C++ version:
if(PT_BUILD_BENCHMARK OR PT_BUILD_ALL)
# Enable C++14:
set(CMAKE_CXX_STANDARD 14)
else()
# Enable C++11:
set(CMAKE_CXX_STANDARD 11)
endif()
# Detect Clang:
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif()
# Set compiler warnings
# (https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md#compilers)
# (https://stackoverflow.com/questions/3375697/useful-gcc-flags-for-c)
# (https://stackoverflow.com/questions/5088460/flags-to-enable-thorough-and-verbose-g-warnings):
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANGXX)
add_definitions("-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wcast-qual -Wunused
-Woverloaded-virtual -Wpedantic -Wdouble-promotion -Wformat=2 -Wfloat-equal -Wpointer-arith
-Wwrite-strings -Wswitch-enum -Wunreachable-code -Winit-self -Wuninitialized
-Wno-unused-result -Wctor-dtor-privacy -Wdisabled-optimization -Wmissing-declarations
-Wredundant-decls -Wno-unused")
endif()
# Add fast math support
# (https://stackoverflow.com/questions/7420665/what-does-gccs-ffast-math-actually-do):
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANGXX)
add_definitions("-ffast-math")
elseif(MSVC)
add_definitions("/fp:fast")
endif()
# Add native CPU features support:
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANGXX)
if(CMAKE_CXX_COMPILER_ID MATCHES "Android")
# See documentation
else()
add_definitions("-march=native")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
add_definitions("-mfpu=neon")
endif()
endif()
elseif(MSVC)
add_definitions("/arch:AVX")
endif()
# Define libsimdpp library path:
set(PT_LIBSIMDPP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/libsimdpp" CACHE STRING "libsimdpp library path")
# Add library subdirectory:
add_subdirectory(lib)
# Add tests subdirectory:
if(PT_BUILD_TESTS OR PT_BUILD_ALL)
add_subdirectory(tests)
endif()
# Add benchmark subdirectory:
if(PT_BUILD_BENCHMARK OR PT_BUILD_ALL)
add_subdirectory(benchmark)
endif()