-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·103 lines (93 loc) · 3.02 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
#
# MIT License
#
# Copyright (c) 2019 Philip Kovacs
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
project(matrix C)
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(GNUInstallDirs)
find_package(MPI REQUIRED)
# ------------
# Local checks
# ------------
include(FindHeaders)
include(FindFunctions)
include(FindSymbols)
include(FindLibraries)
include(TestCompiler)
# -------------------
# Set project version
# -------------------
set(MATRIX_VERSION_MAJOR 0)
set(MATRIX_VERSION_MINOR 1)
set(MATRIX_VERSION_PATCH 0)
# -----------------
# Set compile flags
# -----------------
string(CONCAT LOCAL_C_FLAGS
"-std=c11 -Wformat -Wformat-security -Wunused-result "
"-Wall -Wextra -Werror -pedantic")
list(APPEND CMAKE_C_FLAGS ${LOCAL_C_FLAGS})
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
if(NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)
# --------------
# Build config.h
# --------------
configure_file(
${CMAKE_SOURCE_DIR}/config.h.in
${CMAKE_BINARY_DIR}/config.h
)
add_definitions(-DHAVE_CONFIG_H)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
# -------------------
# Include directories
# -------------------
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}
)
# ------------------
# Add subdirectories
# ------------------
add_subdirectory(cannon)
add_subdirectory(summa)
# -----------------
# Add CPack support
# -----------------
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${MATRIX_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${MATRIX_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${MATRIX_VERSION_PATCH})
string(CONCAT CPACK_PACKAGE_VERSION
"${MATRIX_VERSION_MAJOR}."
"${MATRIX_VERSION_MINOR}."
"${MATRIX_VERSION_PATCH}")
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
include(CPack)