1
1
cmake_minimum_required (VERSION 3.3.0 FATAL_ERROR )
2
- project (nrn C CXX )
2
+ project (NEURON C CXX )
3
3
4
4
# =============================================================================
5
5
# CMake common project settings
6
6
# =============================================================================
7
7
set (PROJECT_VERSION_MAJOR 7 )
8
8
set (PROJECT_VERSION_MINOR 7 )
9
- set (CMAKE_BUILD_TYPE Debug )
10
9
set (CMAKE_CXX_STANDARD 98 )
11
10
set (CMAKE_CXX_STANDARD_REQUIRED ON )
12
11
set (CMAKE_CXX_EXTENSIONS OFF )
12
+ set (CMAKE_BUILD_TYPE RelWithDebInfo )
13
13
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /bin )
14
+ set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR} .${PROJECT_VERSION_MINOR} )
14
15
15
- # needed in several subdirectoy configurations
16
- set (prefix ${CMAKE_INSTALL_PREFIX} )
17
- set (host_cpu ${CMAKE_SYSTEM_PROCESSOR} )
18
- set (exec_prefix ${prefix} )
19
- set (bindir \${exec_prefix} /bin )
20
- set (libdir \${exec_prefix} /lib )
21
- set (PACKAGE "\" nrn\" " )
22
-
23
- option (NRN_BUILD_SHARED "Build libraries shared or static" ON )
24
- option (ENABLE_INTERVIEWS "Link with INTERVIEWS GUI library" ON )
25
- option (ENABLE_LegacyFR "Original faraday, R, etc. instead of 2017 nist constants in share/lib/nrnunits.lib" ON )
26
- option (ENABLE_NRNMECH_DLL_STYLE "Dynamically load nrnmech shared library" ON )
27
- option (ENABLE_DISCRETE_EVENT_OBSERVER "Set to OFF if do not want Observer to be a subclass of DiscreteEvent" ON )
28
- option (ENABLE_PYTHON "Python interpreter available -- python3 fallback to python" ON )
29
- option (ENABLE_THREADS "Allow use of pthreads" ON )
30
- option (ENABLE_MPI "Allow use of MPI" ON )
31
- option (ENABLE_MEMACS "Allow use of memacs" ON )
32
- option (ENABLE_RX3D "Allow use of rx3d" OFF )
33
-
34
- set (INSTALL_NEURON_MODULE "YES" CACHE STRING "\" NO\" , means do not \
35
- install the neuron module. \" Yes\" , means to install with --home in \
36
- CMAKE_INSTALL_PREFIX. For installation using other modes or locations \
37
- use an appropriate string that goes after python setup.py install" )
38
-
39
- set (NRNPYTHON_DYNAMIC "NO" CACHE STRING "\" NO\" , means the nrnpython
40
- interface is linked into libnrniv.so. \" YES\" means the nrnpython
41
- interface consistent with default python3 (falling back to python) is
42
- built and loaded dynamically at run time (nrniv still works in the
43
- absence of any Python at all). A ';' separated list of executable
44
- pythons are used to create a separate interface for each. When one of
45
- those versions of Python is lauched,
46
- import neuron
47
- will automatically load the appropriate module interface along with the
48
- rest of neuron. (And
49
- nrniv -pyexe <python>
50
- will work with any <python> in the list of python executables." )
16
+ # =============================================================================
17
+ # Build options (boolean)
18
+ # =============================================================================
19
+ option (NRN_BUILD_SHARED "Build shared libraries (otherwise static library)" ON )
20
+ option (NRN_ENABLE_INTERVIEWS "Enable GUI with INTERVIEWS" ON )
21
+ option (NRN_ENABLE_LEGACY_FR "Use original faraday, R, etc. instead of 2017 nist constants" ON )
22
+ option (NRN_ENABLE_MECH_DLL_STYLE "Dynamically load nrnmech shared library" ON )
23
+ option (NRN_ENABLE_DISCRETE_EVENT_OBSERVER "Enable Observer to be a subclass of DiscreteEvent" ON )
24
+ option (NRN_ENABLE_PYTHON "Enable Python interpreter support (default python3 fallback to python)" ON )
25
+ option (NRN_ENABLE_THREADS "Allow use of Pthreads" ON )
26
+ option (NRN_ENABLE_MPI "Enable MPI support" ON )
27
+ option (NRN_ENABLE_MEMACS "Enable use of memacs" ON )
28
+ option (NRN_ENABLE_RX3D "Enable rx3d support" OFF )
51
29
52
- set (NRNMPI_DYNAMIC "NO" CACHE STRING "\" No\" , means the nrnmpi
53
- is linked into libnrniv.so. \" YES\" , means the nrnmpi interface
54
- consistent with default mpi is built and loaded dynamically at run
55
- time (nrniv still works in the absence of any mpi at all). A ';'
56
- separated list of paths to mpi package bin directories is used to
57
- create a separate libnrnmpi_xxx.so interface for each. When nrniv
58
- is launched with the -mpi argument, the first mpi found will determine
59
- which interface is dynamically loaded." )
30
+ # =============================================================================
31
+ # Build options (string)
32
+ # =============================================================================
60
33
61
- set (USING_CMAKE_FALSE "#" )
62
- set (USING_CMAKE_TRUE "" )
34
+ # NEURON module installation:
35
+ # - NO : do not install
36
+ # - YES : install with --home in ${CMAKE_INSTALL_PREFIX}
37
+ # - <string> : install using other modes or locations using an appropriate
38
+ # string that goes after python setup.py install
39
+ # Dynamic Python version support:
40
+ # - NO : nrnpython interface is linked into libnrniv.so
41
+ # - YES : nrnpython interface consistent with default python3 (falling back to python)
42
+ # is built and loaded dynamically at run time (nrniv still works in the absence
43
+ # of any Python at all).
44
+ # - <string> : semicolon (;) separated list of python executable used to create a separate
45
+ # interface for each. When one of those versions of Python is lauched,
46
+ # "import neuron" will automatically load the appropriate module interface along
47
+ # with the rest of neuron. Alsom nrniv -pyexe <python> will work with any <python>
48
+ # in the list of python executables.
49
+ # Dynamic MPI support:
50
+ # - NO : nrnmpi is linked into libnrniv.so
51
+ # - YES : nrnmpi interface is consistent with default mpi is built and loaded dynamically
52
+ # at run time (nrniv still works in the absence of any mpi at all).
53
+ # - <string> : semicolon (;) separated list of MPI's bin directories to create a separate
54
+ # libnrnmpi_xxx.so interface for each. When nrniv is launched with the -mpi argument,
55
+ # the first mpi found will determine which interface is dynamically loaded."
56
+ set (NRN_ENABLE_MODULE_INSTALL YES CACHE STRING "Enable NEURON module installation (with setup.py)" )
57
+ set (NRN_ENABLE_PYTHON_DYNAMIC "NO" CACHE STRING "Enable dynamic Python version support" )
58
+ set (NRN_ENABLE_MPI_DYNAMIC "NO" CACHE STRING "Enable dynamic MPI library support" )
63
59
64
60
# =============================================================================
65
- # Compile static libraries with hidden visibility
61
+ # Include cmake modules
66
62
# =============================================================================
67
- #set(CMAKE_CXX_VISIBILITY_PRESET hidden)
63
+ list (APPEND CMAKE_MODULE_PATH
64
+ ${PROJECT_SOURCE_DIR} /cmake
65
+ ${PROJECT_SOURCE_DIR} /cmake/modules )
66
+ include (CompilerHelper )
67
+ include (MacroHelper )
68
+ include (RpathHelper )
69
+ include (PlatformHelper )
68
70
69
71
# =============================================================================
70
72
# Find required packages
71
73
# =============================================================================
72
- message (STATUS "CHECKING FOR X11" )
73
74
find_package (BISON )
74
75
find_package (FLEX )
76
+ find_package (Threads )
77
+ find_package (readline )
75
78
76
- if (ENABLE_MPI )
79
+ # =============================================================================
80
+ # Enable MPI/Python/IV/Pthead if found
81
+ # =============================================================================
82
+ # enable mpi if found
83
+ if (NRN_ENABLE_MPI )
77
84
find_package (MPI REQUIRED )
78
- # TODO : include this for only selective target
79
85
include_directories (${MPI_INCLUDE_PATH} )
80
86
set (NRNMPI 1 )
81
87
set (PARANEURON 1 )
@@ -84,36 +90,35 @@ else()
84
90
set (PARANEURON 0 )
85
91
endif ()
86
92
87
- if (ENABLE_INTERVIEWS )
93
+ # enable interviews if found
94
+ if (NRN_ENABLE_INTERVIEWS )
88
95
find_package (X11 )
89
96
if (NOT ${X11_FOUND} )
90
97
if (APPLE )
91
98
message (FATAL_ERROR "You must install XQuartz from https://www.xquartz.org/ to build iv" )
92
99
else ()
93
- find_package ( X11 REQUIRED )
100
+ message ( FATAL_ERROR "You must install X11 to build iv e.g. 'apt install libx11-dev libxcomposite-dev' on Ubuntu" )
94
101
endif ()
95
102
endif ()
96
- include_directories (${X11_INCLUDE_DIR} )
97
103
find_package (iv REQUIRED )
104
+ get_target_property (IV_INCLUDE_DIR iv_interviews INTERFACE_INCLUDE_DIRECTORIES )
105
+ include_directories (${X11_INCLUDE_DIR} )
98
106
set (HAVE_IV 1 )
99
107
else ()
100
- set (HAVE_IV 0 )
108
+ set (HAVE_IV 0 )
101
109
endif ()
102
110
103
- # python or python3 is also needed to make hocusr.h from neuron.h
104
- set (Python_ADDITIONAL_VERSIONS 3.6 ) # 3.x priority, then 2.x
105
- find_package (PythonInterp REQUIRED ) #currently active
106
- message (NOTICE "ENABLE_PYTHON ${ENABLE_PYTHON} " )
107
- if (ENABLE_PYTHON )
108
- message (NOTICE " inside ENABLE_PYTHON" )
109
- find_package (PythonLibs REQUIRED ) # consistent with above
111
+ # enable python support (interpreter needed to make hocusr.h from neuron.h, prefer Python 3)
112
+ find_package (PythonInterp REQUIRED )
113
+ if (NRN_ENABLE_PYTHON )
114
+ find_package (PythonLibsNew ${PYTHON_VERSION_MAJOR} REQUIRED )
110
115
set (USE_PYTHON 1 )
111
- message (NOTICE "USE_PYTHON ${USE_PYTHON} " )
112
116
else ()
113
117
set (USE_PYTHON 0 )
114
118
endif ()
115
119
116
- if (ENABLE_THREADS )
120
+ # enable threads if found
121
+ if (NRN_ENABLE_THREADS )
117
122
set (THREADS_PREFER_PTHREAD_FLAG ON )
118
123
find_package (Threads REQUIRED )
119
124
set (USE_PTHREAD 1 )
@@ -122,70 +127,93 @@ else()
122
127
endif ()
123
128
124
129
# =============================================================================
125
- # Include cmake modules
130
+ # Add CMake modules AFTER setting options
126
131
# =============================================================================
127
- list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake )
128
- include (RpathHelper )
129
- include (ConfigACFile )
130
- include (NrnPyDynamic )
131
- include (NrnMPIDynamic )
132
+ include (ConfigFileSetting )
133
+ include (NeuronFileLists )
134
+ include (PythonDynamicHelper )
135
+ include (MPIDynamicHelper )
132
136
133
137
# =============================================================================
134
138
# Project version from git and project directories
135
139
# =============================================================================
136
- set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR} .${PROJECT_VERSION_MINOR} )
137
-
138
- add_definitions (-DHAVE_CONFIG_H )
139
-
140
- if (${CMAKE_SYSTEM_NAME} MATCHES "CYGWIN" )
141
- set (CYGWIN 1 )
140
+ add_subdirectory (cmake_config )
141
+ add_subdirectory (src/nrniv )
142
+ add_subdirectory (bin )
143
+ if (NRN_ENABLE_PYTHON )
144
+ add_subdirectory (src/nrnpython )
145
+ endif ()
146
+ if (NRN_MACOS_BUILD OR NOT ${READLINE_FOUND} )
147
+ add_subdirectory (src/readline )
148
+ set (INTERNAL_READLINE readline )
149
+ unset (Readline_LIBRARY CACHE )
142
150
endif ()
143
151
144
- add_subdirectory (cmkconfig )
152
+ # =============================================================================
153
+ # Install targets
154
+ # =============================================================================
155
+ # find headers to install
156
+ nrn_find_project_files (NRN_HEADERS_PATHS ${HEADER_FILES_TO_INSTALL} )
145
157
146
- install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /share/lib
147
- DESTINATION share/nrn )
148
- install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /share/demo
149
- DESTINATION share/nrn )
150
- install (FILES ${PROJECT_BINARY_DIR} /share/lib/nrnunits.lib
158
+ install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /share/lib DESTINATION share/nrn )
159
+ install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /share/demo DESTINATION share/nrn )
160
+ install (FILES
161
+ ${PROJECT_BINARY_DIR} /share/lib/nrnunits.lib
151
162
${PROJECT_BINARY_DIR} /share/lib/nrn.defaults
152
163
DESTINATION ${CMAKE_INSTALL_PREFIX} /share/nrn/lib
153
164
)
154
- install (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR} /share/lib/cleanup
165
+ install (PROGRAMS
166
+ ${CMAKE_CURRENT_SOURCE_DIR} /share/lib/cleanup
155
167
DESTINATION ${CMAKE_INSTALL_PREFIX} /share/nrn/lib
156
168
)
157
-
158
- # paths to *.h files for installing into <prefix>/include
159
- my_find_files (inst_inc
160
- cabvars.h hoc_membf.h neuron.h nrnjava.h options .h
161
- cspmatrix.h hocparse.h nmodlmutex.h nrnoc_ml.h scoplib_ansi.h
162
- cspredef.h md1redef.h nrn_ansi.h scoplib.h
163
- hocassrt.h md2redef.h nrnapi.h nrnran123.h section.h
164
- hocdec.h membdef.h nrnassrt.h nrnredef.h spconfig.h
165
- hocgetsym.h membfunc.h nrncvode.h oc_ansi.h spmatrix.h
166
- hoc.h multicore.h nrnisaac.h ocfunc.h
167
- hoclist.h multisplit.h nrniv_mf.h ocmisc.h
168
- )
169
- install (FILES ${inst_inc} ${PROJECT_BINARY_DIR} /src/oc/nrnpthread.h
169
+ install (FILES
170
+ ${NRN_HEADERS_PATHS} ${PROJECT_BINARY_DIR} /src/oc/nrnpthread.h
170
171
DESTINATION ${CMAKE_INSTALL_PREFIX} /include
171
172
)
172
173
173
- find_package (readline )
174
-
175
- # if readline not found or if we are on OSX, use internal readline
176
- # also clear library variable
177
- if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR NOT ${READLINE_FOUND} )
178
- add_subdirectory (src/readline )
179
- set (INTERNAL_READLINE readline )
180
- unset (Readline_LIBRARY CACHE )
181
- endif ()
182
-
183
- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
184
- set (CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup" )
185
- endif ()
186
-
187
- add_subdirectory (src/nrniv )
188
- add_subdirectory (bin )
189
- if (ENABLE_PYTHON )
190
- add_subdirectory (src/nrnpython )
174
+ # =============================================================================
175
+ # Print build status
176
+ # =============================================================================
177
+ message (STATUS "" )
178
+ message (STATUS "Configured NEURON ${PROJECT_VERSION} " )
179
+ message (STATUS "" )
180
+ string (TOLOWER "${CMAKE_GENERATOR} " cmake_generator_tolower )
181
+ if (cmake_generator_tolower MATCHES "makefile" )
182
+ message (STATUS "Some things you can do now:" )
183
+ message (STATUS "--------------+--------------------------------------------------------------" )
184
+ message (STATUS "Command | Description" )
185
+ message (STATUS "--------------+--------------------------------------------------------------" )
186
+ message (STATUS "make install | Will install NEURON to: ${CMAKE_INSTALL_PREFIX} " )
187
+ message (STATUS " | Change the install location of NEURON using:" )
188
+ message (STATUS " | cmake <src_path> -DCMAKE_INSTALL_PREFIX=<install_path>" )
189
+ message (STATUS "make doc | Build the API documentation, requires Sphinx" )
190
+ message (STATUS "make uninstall| Removes files installed by make install" )
191
+ message (STATUS "--------------+--------------------------------------------------------------" )
192
+ message (STATUS " Build option | Status" )
193
+ message (STATUS "--------------+--------------------------------------------------------------" )
194
+ message (STATUS "Interviews | ${HAVE_IV} " )
195
+ if (${HAVE_IV} )
196
+ message (STATUS " PATH | ${iv_DIR} " )
197
+ endif ()
198
+ message (STATUS "MPI | ${NRNMPI} " )
199
+ if (NRN_ENABLE_MPI )
200
+ message (STATUS " INC | ${MPI_INCLUDE_PATH} " )
201
+ message (STATUS " LIB | ${MPI_LIBRARY} " )
202
+ endif ()
203
+ message (STATUS "Python | ${USE_PYTHON} " )
204
+ if (NRN_ENABLE_PYTHON )
205
+ message (STATUS " EXE | ${PYTHON_EXECUTABLE} " )
206
+ message (STATUS " INC | ${PYTHON_INCLUDE_DIRS} " )
207
+ message (STATUS " LIB | ${PYTHON_LIBRARIES} " )
208
+ if (NOT NRN_ENABLE_PYTHON_DYNAMIC MATCHES "NO" )
209
+ message (STATUS " INC(2) | ${NRNPYTHON_INCLUDE2} " )
210
+ message (STATUS " INC(3) | ${NRNPYTHON_INCLUDE3} " )
211
+ endif ()
212
+ endif ()
213
+ message (STATUS "RXD | ${NRN_ENABLE_RX3D} " )
214
+ message (STATUS "Shared | ${NRN_BUILD_SHARED} " )
215
+ message (STATUS "--------------+--------------------------------------------------------------" )
216
+ message (STATUS " See documentation : https://www.neuron.yale.edu/neuron/" )
217
+ message (STATUS "--------------+--------------------------------------------------------------" )
191
218
endif ()
219
+ message (STATUS "" )
0 commit comments