-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (65 loc) · 2.56 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
cmake_minimum_required(VERSION 3.14)
project(raw)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Set build type to RELEASE by default:
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type provided, default to RELEASE.")
set(CMAKE_BUILD_TYPE "RELEASE")
endif()
# Options
option(RAW_STATIC "Builds a static library instead of a shared one." OFF)
option(RAW_TEST "Adds target for tests." OFF)
option(RAW_BENCH "Adds target for benchmarks." OFF)
option(RAW_EXAMPLES "Builds examples." OFF)
option(RAW_CUDA "Adds support for CUDA." OFF)
option(RAW_NATIVE "Adds -march=native flag." OFF)
option(RAW_SANITIZE "Adds -fsanitize=address -fsanitize=undefined flags." OFF)
option(RAW_PI "Builds a position-independent library." ON)
# Define a few stuff
if(RAW_STATIC)
set(RAW_LIB_TYPE STATIC)
set(RAW_LIB_NAME "raw_static")
set(SFMT_LIB_NAME "sfmt_static")
add_definitions(-DRAW_STATIC_LIBRARY)
else()
set(RAW_LIB_TYPE SHARED)
set(RAW_LIB_NAME "raw")
set(SFMT_LIB_NAME "sfmt")
add_definitions(-DRAW_SHARED_LIBRARY)
endif()
add_definitions(-DSFMT_MEXP=19937)
# Find packages
find_package(Threads REQUIRED)
find_package(Math)
find_package(BLAS) # https://cmake.org/cmake/help/v3.14/module/FindBLAS.html
# Flags
set(RAW_TO_LINK ${BLAS_LIBRARIES} ${BLAS_LINKER_FLAGS} ${SFMT_LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARIES})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Fingers crossed that it compiles on Windows...
# Subdirectories
include_directories(include include/SFMT src)
add_subdirectory(src)
if(RAW_EXAMPLES)
add_subdirectory(examples)
endif()
if(RAW_TEST)
enable_testing()
add_subdirectory(test)
endif()
if(RAW_BENCH)
add_subdirectory(bench)
endif()
# Summary
message(STATUS "")
message(STATUS "RAW BUILD SUMMARY")
message(STATUS " CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Compiler ID : ${CMAKE_C_COMPILER_ID}")
message(STATUS " BLAS Linker Flags : ${BLAS_LINKER_FLAGS}")
message(STATUS " BLAS Libraries : ${BLAS_LIBRARIES}")
message(STATUS " Library name : ${RAW_LIB_NAME}")
message(STATUS " Library type : ${RAW_LIB_TYPE}")
message(STATUS " Build tests : ${RAW_TEST}")
message(STATUS " Build benchmarks : ${RAW_BENCH}")
message(STATUS " Build examples : ${RAW_EXAMPLES}")
message(STATUS " Position-independent library : ${RAW_PI}")
message(STATUS "")