forked from nest/nest-simulator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
293 lines (247 loc) · 12.1 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# CMakeLists.txt
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>
cmake_minimum_required( VERSION 2.8.12 )
# juqueen 2.8.12.2
# add cmake modules: for all `include(...)` first look here
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
project( nest CXX C )
set( NEST_USER_EMAIL "[email protected]" )
# VERSION exported to libnestutil/config.h, extras/create_release.sh
set( NEST_VERSION_MAJOR 2 )
set( NEST_VERSION_MINOR 10 )
set( NEST_VERSION_PATCHLEVEL 0 )
set( NEST_VERSION_VERSION "${NEST_VERSION_MAJOR}.${NEST_VERSION_MINOR}.${NEST_VERSION_PATCHLEVEL}" )
set( NEST_VERSION_PRGNAME "${PROJECT_NAME}-${NEST_VERSION_VERSION}" )
################################################################################
################## All User Defined options ##################
################################################################################
# set NEST defaults
set( tics_per_ms "1000.0" CACHE STRING "Specify elementary unit of time. [default 1000.0]" )
set( tics_per_step "100" CACHE STRING "Specify resolution. [default 100]" )
option( with-ps-arrays "Use PS array construction semantics. [default=ON]" ON )
# add user modules
set( external-modules OFF CACHE STRING "External NEST modules to be linked in, separated by ';'. [default=OFF]" )
# connect NEST with external projects
set( with-libneurosim OFF CACHE STRING "Request the use of libneurosim. Optionally give the directory, where libneurosim is installed. [default=OFF]" )
set( with-music OFF CACHE STRING "Request the use of MUSIC. Optionally give the directory, where MUSIC is installed. [default=OFF]" )
# set parallelization scheme
set( with-mpi OFF CACHE STRING "Request compilation with MPI. Optionally give directory with MPI installation. [default=OFF]" )
set( with-openmp ON CACHE STRING "Enable OpenMP multithreading. Optional: set OMP flag. [default=ON]" )
# define default libraries
set( with-gsl ON CACHE STRING "Find a gsl library. To set a specific gsl installation, set install path. [default=ON]" )
set( with-readline ON CACHE STRING "Find a readline library. To set a specific readline, set install path. [default=ON]" )
set( with-ltdl ON CACHE STRING "Find a ltdl library. To set a specific ltdl, set install path. [default=ON]" )
set( with-python ON CACHE STRING "Build PyNEST. To set a specific Python, set install path. [default=ON]" )
option( cythonize-pynest "Use Cython to cythonize pynestkernel.pyx. If OFF, PyNEST has to be build from a pre-cythonized pynestkernel.pyx. [default=ON]" ON )
# Whether to build a 'mostly' static executable and static libraries.
option( static-libraries "Build static executable and libraries. [default=OFF]" OFF )
# additional compile flags
set( with-optimize ON CACHE STRING "Enable user defined optimizations. [default ON, when ON, defaults to '-O2']" )
set( with-warning ON CACHE STRING "Enable user defined warnings. [default ON, when ON, defaults to '-Wall']" )
set( with-debug OFF CACHE STRING "Enable user defined debug flags. [default OFF, when ON, defaults to '-g']" )
set( with-libraries OFF CACHE STRING "Link additional libraries. Give full path. Separate multiple libraries by ';'. [default OFF]" )
set( with-includes OFF CACHE STRING "Add additional include paths. Give full path without '-I'. Separate multiple include paths by ';'. [default OFF]" )
set( with-defines OFF CACHE STRING "Additional defines, e.g. '-DXYZ=1'. Separate multiple defines by ';'. [default OFF]" )
# cross-compiling
# should be set via toolchain files
set( enable-bluegene OFF CACHE STRING "Configure for BlueGene." )
option( k-computer "Enable K computer." OFF )
################################################################################
################## Project Directory variables ##################
################################################################################
# install prefix is set with -DCMAKE_INSTALL_PREFIX:PATH=...
set( INSTALL_BIN_DIR bin )
set( INSTALL_LIB_DIR lib )
set( INSTALL_INC_DIR include )
set( INSTALL_DATA_DIR share/nest )
set( INSTALL_DOC_DIR share/doc/nest )
set( PKGSRCDIR ${PROJECT_SOURCE_DIR} )
set( PKGBUILDDIR ${PROJECT_BINARY_DIR} )
set( PKGDATADIR ${CMAKE_INSTALL_PREFIX}/${INSTALL_DATA_DIR} )
set( PKGDOCDIR ${CMAKE_INSTALL_PREFIX}/${INSTALL_DOC_DIR} )
set( TESTSUITE_BASEDIR ${PKGDOCDIR} )
################################################################################
################# Do not install into /usr/local #################
################################################################################
if ( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local" )
# no prefix given?
message( FATAL_ERROR "Do not install into '${CMAKE_INSTALL_PREFIX}'? "
"Please set -DCMAKE_INSTALL_PREFIX:PATH=<install prefix>." )
endif ()
################################################################################
################## Find utility programs ##################
################################################################################
# needed for target doc and fulldoc
find_package( Doxygen )
find_program( SED NAMES sed gsed )
################################################################################
################## CPack, checks, ... in external modules ##################
################################################################################
include( CPackVariables )
include( CheckIncludesSymbols )
include( ProcessOptions )
include( WriteStaticModules_h )
include( DetermineLibraries )
include( CheckExtraCompilerFeatures )
################################################################################
################## Enable Testing Targets ##################
################################################################################
enable_testing()
set( TEST_LOGFILE ${PROJECT_BINARY_DIR}/reports/installcheck.log )
file( MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/reports/ )
if ( HAVE_PYTHON )
add_custom_target( installcheck
#COMMAND ${CMAKE_MAKE_PROGRAM} install
COMMAND export PATH="${CMAKE_INSTALL_PREFIX}/${INSTALL_BIN_DIR}:$ENV{PATH}" &&
export PYTHON="${PYTHON}" &&
export PYTHONPATH="${PYEXECDIR}:$ENV{PYTHONPATH}" &&
export exec_prefix="${CMAKE_INSTALL_PREFIX}" &&
${PKGDATADIR}/extras/do_tests.sh --test-pynest --source-dir="${PROJECT_SOURCE_DIR}"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Execute NEST's testsuite...."
)
else ()
add_custom_target( installcheck
#COMMAND ${CMAKE_MAKE_PROGRAM} install
COMMAND export PATH="${CMAKE_INSTALL_PREFIX}/${INSTALL_BIN_DIR}:$ENV{PATH}" &&
${PKGDATADIR}/extras/do_tests.sh --source-dir="${PROJECT_SOURCE_DIR}"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Execute NEST's testsuite...."
)
endif ()
add_custom_target( check
COMMAND export CTEST_OUTPUT_ON_FAILURE=1 &&
${CMAKE_CTEST_COMMAND} -C ${CMAKE_BUILD_TYPE}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
################################################################################
################## Define Subdirectories here ##################
################################################################################
if ( HAVE_LIBNEUROSIM )
add_subdirectory( conngen )
endif ()
add_subdirectory( doc )
add_subdirectory( examples )
add_subdirectory( extras )
add_subdirectory( lib )
add_subdirectory( libnestutil )
add_subdirectory( librandom )
add_subdirectory( models )
add_subdirectory( sli )
add_subdirectory( nest )
add_subdirectory( nestkernel )
add_subdirectory( precise )
add_subdirectory( testsuite )
add_subdirectory( topology )
if ( HAVE_PYTHON )
add_subdirectory( pynest )
endif ()
################################################################################
################## Summary of flags ##################
################################################################################
# used in nest-config
# all compiler flags
if ( NOT CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "None" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS}" )
set( ALL_CXXFLAGS "${CMAKE_CXX_FLAGS}" )
elseif ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}" )
set( ALL_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}" )
elseif ( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}" )
set( ALL_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}" )
elseif ( ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}" )
set( ALL_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
elseif ( ${CMAKE_BUILD_TYPE} STREQUAL "MinSizeRel" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_MINSIZEREL}" )
set( ALL_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" )
else ()
message( FATAL_ERROR "Unknown build type: '${CMAKE_BUILD_TYPE}'" )
endif ()
if ( with-defines )
foreach ( def ${with-defines} )
set( ALL_CFLAGS "${def} ${ALL_CFLAGS}" )
set( ALL_CXXFLAGS "${def} ${ALL_CXXFLAGS}" )
endforeach ()
endif ()
# all libraries
set( ALL_LIBS "${OpenMP_CXX_FLAGS};${LTDL_LIBRARIES};${READLINE_LIBRARIES};${GSL_LIBRARIES};${LIBNEUROSIM_LIBRARIES};${MUSIC_LIBRARIES};${MPI_CXX_LIBRARIES}" )
if ( with-libraries )
set( ALL_LIBS "${ALL_LIBS};${with-libraries}" )
endif ()
string( REPLACE ";" " " ALL_LIBS "${ALL_LIBS}" )
# all includes
set( ALL_INCLUDES_tmp "${LTDL_INCLUDE_DIRS};${READLINE_INCLUDE_DIRS};${GSL_INCLUDE_DIRS};${LIBNEUROSIM_INCLUDE_DIRS};${MUSIC_INCLUDE_DIRS};${MPI_CXX_INCLUDE_PATH}" )
set( ALL_INCLUDES "" )
foreach ( INC ${ALL_INCLUDES_tmp} ${with-includes} )
if ( INC AND NOT INC STREQUAL "" )
set( ALL_INCLUDES "${ALL_INCLUDES} -I${INC}" )
endif ()
endforeach ()
if ( HAVE_LIBNEUROSIM )
set( ALL_LIBS "-lconngen ${ALL_LIBS}" )
set( ALL_INCLUDES "-I${PROJECT_SOURCE_DIR}/conngen ${ALL_INCLUDES}" )
endif ()
################################################################################
################## File generation here ##################
################################################################################
configure_file(
"${PROJECT_SOURCE_DIR}/libnestutil/config.h.in"
"${PROJECT_BINARY_DIR}/libnestutil/config.h" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/pynest/setup.py.in"
"${PROJECT_BINARY_DIR}/pynest/setup.py" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/pynest/do_tests.py.in"
"${PROJECT_BINARY_DIR}/pynest/do_tests.py" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/topology/setup.py.in"
"${PROJECT_BINARY_DIR}/topology/setup.py" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/testsuite/do_tests.sh.in"
"${PROJECT_BINARY_DIR}/testsuite/do_tests.sh" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/extras/emacs/sli.el.in"
"${PROJECT_BINARY_DIR}/extras/emacs/sli.el" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/extras/nest-config.in"
"${PROJECT_BINARY_DIR}/extras/nest-config" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/extras/create_release.sh.in"
"${PROJECT_BINARY_DIR}/extras/create_release.sh" @ONLY
)
configure_file(
"${PROJECT_SOURCE_DIR}/extras/nest_vars.sh.in"
"${PROJECT_BINARY_DIR}/extras/nest_vars.sh" @ONLY
)
################################################################################
################## Install Extra Files ##################
################################################################################
install( FILES LICENSE README.md NEWS
DESTINATION ${INSTALL_DOC_DIR}
)
include( ConfigureSummary )