-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
128 lines (91 loc) · 3.27 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required(VERSION 3.16)
# disable in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR “In-source build detected!”)
endif()
# if CMAKE_BUILD_TYPE is specified use it; otherwise set the default
# build type to "Release" prior to calling project().
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type")
else()
# set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose build type")
endif()
# set the project name
project(bil LANGUAGES C CXX Fortran)
option(ENABLE_OPENMP "Enable OpenMP parallelization" OFF)
option(ENABLE_PTHREADS "Enable Pthreads parallelization" OFF)
option(ENABLE_MPI "Enable MPI parallelization" OFF)
# Add the CMake directory for custon CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Bil full path
# -------------
set(BIL_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# Bil informations
# ----------------
include(SetBilInfos)
# Directories of Bil
# ------------------
set(BIL_LIBDIR ${BIL_PATH}/lib)
set(BIL_BINDIR ${BIL_PATH}/bin)
set(BIL_SRCDIR ${BIL_PATH}/src)
set(BIL_INCLUDEDIR ${BIL_PATH}/include)
# Installation directories
# ------------------------
include(GNUInstallDirs)
set(BIL_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
set(BIL_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
set(BIL_INSTALL_FULL_MAN1DIR ${CMAKE_INSTALL_FULL_MANDIR}/man1)
set(BIL_INSTALL_FULL_DOCDIR ${CMAKE_INSTALL_FULL_DOCDIR})
set(BIL_INSTALL_FULL_INFODIR ${CMAKE_INSTALL_FULL_INFODIR})
set(BIL_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}/bil)
# Library of Bil
# ----------------
set(BIL_LIB bil-${BIL_VERSION}-${CMAKE_BUILD_TYPE})
# Bil executable
# --------------
set(BIL_EXE ${BIL_LIB}.exe)
# Extra-libraries
# ---------------
set(BILEXTRALIBS_H BilExtraLibs.h)
set(BIL_EXTRALIBS)
include(Extralibs)
include(SetCompilerFlags)
# Bil options
# -----------
include(SetBilConfig)
# the executable and the library
add_subdirectory(src)
# the documentations
add_subdirectory(doc)
# Custom targets
# --------------
# Target rules for memcheck through valgrind.
# To pass the variable "foo" to make, use the command-line: make memcheck arg="foo"
find_program(VALGRIND valgrind)
if(VALGRIND)
add_custom_target(memcheck
COMMAND ${VALGRIND} --tool=memcheck --leak-check=full --read-var-info=yes ${BIL_EXE} ${arg}
)
endif()
# Epilogue
message("")
message("Bil has been configured for the OS: " ${BIL_OS})
message("with the following options: " ${BIL_CONFIG_OPTIONS})
message("")
message("C compiler: ${CMAKE_C_COMPILER}")
message("C++ compiler: ${CMAKE_CXX_COMPILER}")
message("Fortran compiler: ${CMAKE_Fortran_COMPILER}")
message("C compiler flags: ${CMAKE_C_FLAGS}")
message("C++ compiler flags: ${CMAKE_CXX_FLAGS}")
message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS}")
if(CMAKE_BUILD_TYPE)
message("Build type: ${CMAKE_BUILD_TYPE}")
endif()
if(CMAKE_BUILD_PARALLEL_LEVEL)
message("Build parallel level: ${CMAKE_BUILD_PARALLEL_LEVEL}")
endif()
message("Install prefix: ${CMAKE_INSTALL_PREFIX}")
message("")
message("Run 'ccmake ${CMAKE_CURRENT_SOURCE_DIR}' to fine-tune the configuration.")
message("")