This repository was archived by the owner on Apr 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (85 loc) · 3.61 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
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(psrs C)
# the short system name, e.g. "Linux", "FreeBSD" or "Windows"
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# unfortunately I have not actually tested my code
# on windows using mingw/cygwin
# so feel free to report any bugs encoutered when you are using them
if(NOT MINGW AND NOT CYGWIN)
message(FATAL_ERROR
"Non-MinGW/Cygwin build system is not supported!")
endif()
endif()
# remember to override this variable if debug info is not needed
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are:
None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
# add support for YCM
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
# all the targets generated by this master file requires c99
set(CMAKE_C_STANDARD 99)
# prevent the previous one from "decaying" to previous standards;
# i.e. make the c99 standard a requirement
set(CMAKE_C_STANDARD_REQUIRED ON)
# -------------------------------- GCC FLAGS ----------------------------------
# note that this compiler option should work for all compilers that support
# the same flag as gcc: so clang, mingw, and cygwin are all valid candidates
# GCC has built-ins that can help identify common memory-related bugs
# set(GCC_SANITIZE_ADDRESS_FLAG "-fsanitize=address")
# set(GCC_SANITIZE_LEAK_FLAG "-fsanitize=leak")
# set(GCC_SANITIZE_UNDEFINED_FLAG "-fsanitize=undefined")
set(GCC_WARN_ALL "-Wall")
# set(GCC_WARN_EXTRA "-Wextra")
# issue warning if comparison operators are directly used for floats
set(GCC_WARN_FLOAT_EQUAL_FLAG "-Wfloat-equal")
# issue warning if local identifers shadow other identifiers outside the scope
set(GCC_WARN_SHADOW_FLAG "-Wshadow")
# issue warning if pointer arithmetic is performed on pointers to
# either function or void
set(GCC_WARN_POINTER_ARITH "-Wpointer-arith")
# generate assembly trap instructions if signed integer types overflow;
# this would abort the program in most platforms
set(GCC_SIGNED_OVERFLOW_TRAP_FLAG "-ftrapv")
# use pipes to communicate among different stages of compilation;
# speed up the compilation when GNU Assembler is available
set(GCC_PIPE "-pipe")
# from the cmake documentation: "Adds options to the compiler command line for
# sources in the current directory and below", so it is used rather than
# add_definitions(), which seems to be reserved for macros
add_compile_options(
# ${GCC_SANITIZE_ADDRESS_FLAG}
# ${GCC_SANITIZE_LEAK_FLAG}
# ${GCC_SANITIZE_UNDEFINED_FLAG}
${GCC_WARN_ALL}
# ${GCC_WARN_EXTRA}
${GCC_WARN_FLOAT_EQUAL_FLAG}
${GCC_WARN_SHADOW_FLAG}
${GCC_WARN_POINTER_ARITH}
${GCC_SIGNED_OVERFLOW_TRAP_FLAG}
${GCC_PIPE})
# -------------------------------- GCC FLAGS ----------------------------------
# make sure that our source directory is on the current cmake module path so
# that we can include cmake files from this directory
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# test the existence of MPI run-time on the system
find_package(MPI REQUIRED)
# test the existence of python 3 interpreter
set(Python_ADDITIONAL_VERSIONS 3.5)
find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
message(WARNING "Python 3.5 is required to run the plotting program!")
endif()
find_package(Matplotlib)
if(NOT MATPLOTLIB_FOUND)
message(WARNING "Matplotlib is required to plot the speed graph!")
endif()
# common header(s) reside(s) in the include directory in the
# relative root directory of this project
include_directories(
${PROJECT_SOURCE_DIR}/include
${MPI_C_INCLUDE_PATH}
)
add_subdirectory(src)