-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
211 lines (149 loc) · 6.53 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# SixTrackLib
# Authors: R. De Maria, G. Iadarola, D. Pellegrini, H. Jasim, M. Schwinzerl
#
# Copyright 2018 CERN. This software is distributed under the terms of the GNU
# Lesser General Public License version 2.1, copied verbatim in the file
#`COPYING''.
#
# In applying this licence, CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization or
# submit itself to any jurisdiction.
cmake_minimum_required( VERSION 3.8 FATAL_ERROR )
project( sixtracklib LANGUAGES C CXX )
message( STATUS "---- Project sixtracklib" )
message( STATUS "---- Inside main CMakeLists.txt" )
# Set a default build type if none was specified
set( SIXTRL_DEFAULT_BUILD_TYPE "Release" )
if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
message( STATUS "---- Setting build type to '${SIXTRL_DEFAULT_BUILD_TYPE}' as none was specified." )
set( CMAKE_BUILD_TYPE "${SIXTRL_DEFAULT_BUILD_TYPE}"
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
endif()
# ------------------------------------------------------------------------------
# load local settings file -> this is optional, if not loaded then the default
# settings file will be loaded:
set( PATH_TO_DEFAULT_SETTINGS_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/Settings.cmake.default" )
set( PATH_TO_LOCAL_SETTINGS_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/Settings.cmake" )
if( EXISTS ${PATH_TO_LOCAL_SETTINGS_FILE} )
include( ${PATH_TO_LOCAL_SETTINGS_FILE} OPTIONAL
RESULT_VARIABLE STATUS_INCLUDE_LOCAL_SETTINGS_FILE )
if( STATUS_INCLUDE_LOCAL_SETTINGS_FILE )
message( STATUS "---- Loaded local settings file
${PATH_TO_LOCAL_SETTINGS_FILE}" )
endif()
elseif( EXISTS ${PATH_TO_DEFAULT_SETTINGS_FILE} )
include( ${PATH_TO_DEFAULT_SETTINGS_FILE} OPTIONAL
RESULT_VARIABLE STATUS_INCLUDE_DEFAULT_SETTINGS_FILE )
if( STATUS_INCLUDE_DEFAULT_SETTINGS_FILE )
message( STATUS "---- Loaded default settings file
${PATH_TO_DEFAULT_SETTINGS_FILE}" )
endif()
endif()
if( NOT STATUS_INCLUDE_LOCAL_SETTINGS_FILE AND
NOT STATUS_INCLUDE_DEFAULT_SETTINGS_FILE )
message( WARNING "---- -> No settings file (i.e. neither Settings.cmake nor"
" Settings.cmake.default) included" )
endif()
set( SIXTRACKL_VERSION_STR "0.1.0" )
# ==============================================================================
# handle dependencies and external libraries/toolkits:
# ------------------------------------------------------------------------------
# These two abstract lists contain the name of the modules that are know to
# SixTrackLib and "1" and "0" for representing the enabled and disabled state
# of these modules. This is used to generate headers, list, install files, etc.
set( SIXTRACKLIB_SUPPORTED_MODULES )
set( SIXTRACKLIB_SUPPORTED_MODULES_VALUES )
set( SIXTRACKLIB_SUPPORTED_BINDINGS )
set( SIXTRACKLIB_SUPPORTED_BINDINGS_VALUES )
set( SIXTRACKLIB_TESTDATA_DIR
"${CMAKE_SOURCE_DIR}/tests/testdata" CACHE STRING "" FORCE )
set( SIXTRACKLIB_CPU_FLAGS )
set( SIXTRACKLIB_C99_FLAGS )
set( SIXTRACKLIB_CXX_FLAGS )
# ------------------------------------------------------------------------------
# place all contributed cmake modules and snipplets into the cmake subdirectory
# of the project's root folder:
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
message( STATUS "---- cmake_module_path: ${CMAKE_MODULE_PATH}" )
# ------------------------------------------------------------------------------
# Setup language bindings - we have to be first to pull in python (if needed)
# to prevent any module picking a python version we do not wish to support:
include(CheckLanguage)
include( SetupGit )
include( SetupFeatures )
include( SetupC99 )
include( SetupCxx )
include( SetupPython )
# ------------------------------------------------------------------------------
# Unit-testing:
include( SetupUnitTesting )
# ------------------------------------------------------------------------------
# toml:
include( SetupToml )
# ------------------------------------------------------------------------------
# MPFR4:
include( SetupMultiPrecision )
# ------------------------------------------------------------------------------
# Autovectorization and SIMD:
include( SetupAutoVecSIMD )
# ------------------------------------------------------------------------------
# OpenMP:
include( SetupOpenMP )
# ------------------------------------------------------------------------------
# OpenCL:
include( SetupOpenCL )
# ------------------------------------------------------------------------------
# Cuda:
if( SIXTRACKL_ENABLE_CUDA )
check_language( CUDA )
if( CMAKE_CUDA_COMPILER )
message( STATUS "---- enabling CUDA language" )
enable_language( CUDA )
endif()
endif()
include( SetupCuda )
# ------------------------------------------------------------------------------
# Namespace handling:
set( SIXTRACKLIB_NAMESPACE_FLAGS )
if( SIXTRACKL_C_NAMESPACE_PREFIX )
list( APPEND SIXTRACKLIB_NAMESPACE_FLAGS
"__NAMESPACE=${SIXTRACKL_C_NAMESPACE_PREFIX}" )
endif()
if( SIXTRACKL_CXX_NAMESPACE )
list( APPEND SIXTRACKLIB_NAMESPACE_FLAGS
"SIXTRL_NAMESPACE=${SIXTRACKL_CXX_NAMESPACE}" )
endif()
# ==============================================================================
# sixtracklib: C/C++ library ; sixtracklib python bindings
add_subdirectory( external )
add_subdirectory( sixtracklib )
# ------------------------------------------------------------------------------
# Add tools
if( SIXTRACKL_BUILD_TOOLS )
add_subdirectory( tools )
endif()
# ------------------------------------------------------------------------------
# Add sixtracklib Python 3.x bindings
if( SIXTRACKL_ENABLE_PYTHON )
add_subdirectory( python )
endif()
# ==============================================================================
# examples: c99, cxx, python
if( SIXTRACKL_BUILD_EXAMPLES )
add_subdirectory( examples )
endif()
# ==============================================================================
# tests: unit-tests, benchmarks, testdata generators:
if( SIXTRACKL_ENABLE_PROGRAMM_TESTS OR SIXTRACKL_ENABLE_BENCHMARK_TESTS OR
SIXTRACKL_BUILD_EXAMPLES OR SIXTRACKL_BUILD_TOOLS )
add_subdirectory( tests )
endif()
# ------------------------------------------------------------------------------
#
# end: sixtracklib/CMakeLists.txt
#