Skip to content

Commit 164ace7

Browse files
committed
build: add SUNDIALS as git submodule (neuronsimulator fork)
- Add external/sundials submodule pointing to neuronsimulator/sundials (hines/hoc_pow) - Update FindSUNDIALS.cmake to use the standard submodule approach. - Build SUNDIALS inside the main build directory. - Initialization consistent with other submodules (InterViews, etc.)
1 parent 64bdb8b commit 164ace7

3 files changed

Lines changed: 35 additions & 34 deletions

File tree

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@
3737
[submodule "external/spdlog"]
3838
path = external/spdlog
3939
url = https://github.com/gabime/spdlog.git
40+
[submodule "external/sundials"]
41+
path = external/sundials
42+
url = https://github.com/neuronsimulator/sundials.git
43+
branch = hines/hoc_pow

cmake/modules/FindSUNDIALS.cmake

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,54 @@
1-
# =============================================================================
2-
# Sundials
3-
# =============================================================================
1+
# cmake/modules/FindSUNDIALS.cmake
42

5-
include(ExternalProject)
6-
set(SUNDIALS_PREFIX "${THIRD_PARTY_DIRECTORY}/sundials")
3+
set(SUNDIALS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/sundials")
4+
5+
# Use the same pattern as other submodules in NEURON
6+
if(NOT EXISTS "${SUNDIALS_SOURCE_DIR}/CMakeLists.txt")
7+
message(STATUS "SUNDIALS submodule not found.")
8+
include(${PROJECT_SOURCE_DIR}/cmake/ExternalProjectHelper.cmake)
9+
nrn_initialize_submodule(external/sundials)
10+
endif()
11+
12+
if(NOT EXISTS "${SUNDIALS_SOURCE_DIR}/CMakeLists.txt")
13+
message(FATAL_ERROR "Failed to initialize SUNDIALS submodule")
14+
endif()
15+
16+
set(SUNDIALS_PREFIX "${CMAKE_BINARY_DIR}/external/sundials")
717
set(SUNDIALS_INCLUDE_DIR "${SUNDIALS_PREFIX}/include")
818
set(SUNDIALS_LIB_DIR "${SUNDIALS_PREFIX}/lib")
9-
make_directory(${SUNDIALS_INCLUDE_DIR})
1019

11-
set(SUNDIALS_C_FLAGS ${CMAKE_C_FLAGS})
12-
list(REMOVE_ITEM SUNDIALS_C_FLAGS "-tp=haswell")
13-
set(SUNDIALS_CXX_FLAGS ${CMAKE_CXX_FLAGS})
14-
list(REMOVE_ITEM SUNDIALS_CXX_FLAGS "-tp=haswell")
1520
include(ExternalProject)
1621
ExternalProject_Add(
17-
sundials-external
22+
sundials
23+
SOURCE_DIR "${SUNDIALS_SOURCE_DIR}"
1824
PREFIX "${SUNDIALS_PREFIX}"
19-
# cmake-format: off
20-
# GIT_REPOSITORY https://github.com/LLNL/sundials.git
21-
# Forked to following, to allow RPowerR to use hoc_pow
22-
GIT_REPOSITORY https://github.com/neuronsimulator/sundials.git
23-
# GIT_TAG e2f29c34f324829302037a1492db480be8828084 6.2.0 -> CVodeMem no longer "visible" GIT_TAG
24-
# c09e732080a214694b209032ec627c93fed45340 4
25-
#GIT_TAG 811234254d37652954daff0ccdb7af9813736846 # 3.2.1
26-
GIT_TAG 71b3daec18ce66a7c011be9501a31567aa5c09b6 # 3.2.1 hines/hoc_pow
27-
# GIT_TAG 7ed895fd102226dbc52225e6b2c6e26ef1cafa0e #2.7.0
28-
# cmake-format: on
29-
GIT_SHALLOW ON
30-
GIT_PROGRESS ON
31-
# UPDATE_COMMAND ""
3225
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
3326
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
3427
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
35-
-DCMAKE_C_FLAGS=${SUNDIALS_C_FLAGS}
36-
-DCMAKE_CXX_FLAGS=${SUNDIALS_CXX_FLAGS}
3728
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
29+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
30+
-DBUILD_SHARED_LIBS=OFF
31+
-DEXAMPLES_ENABLE_C=OFF
3832
-DEXAMPLES_INSTALL=OFF
3933
-DBUILD_ARKODE=OFF
4034
-DBUILD_CVODES=OFF
4135
-DBUILD_IDAS=OFF
4236
-DBUILD_KINSOL=OFF
43-
-DEXAMPLES_ENABLE_C=OFF
4437
-DMPI_ENABLE=OFF
4538
-DPTHREAD_ENABLE=ON
4639
-DSUNDIALS_PRECISION=double
4740
-DUSE_GENERIC_MATH=ON
48-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
49-
-DBUILD_SHARED_LIBS=OFF
50-
-DMPI_C_COMPILER=${MPI_C_COMPILER}
51-
-DCMAKE_INSTALL_LIBDIR=${SUNDIALS_LIB_DIR}
5241
BUILD_BYPRODUCTS
53-
<INSTALL_DIR>/lib/libsundials_ida.a <INSTALL_DIR>/lib/libsundials_cvode.a
42+
<INSTALL_DIR>/lib/libsundials_cvode.a <INSTALL_DIR>/lib/libsundials_ida.a
5443
<INSTALL_DIR>/lib/libsundials_nvecserial.a <INSTALL_DIR>/lib/libsundials_nvecpthreads.a
55-
<INSTALL_DIR>/lib/libsundials_nvecparallel.a)
44+
INSTALL_DIR "${SUNDIALS_PREFIX}")
5645

5746
add_library(SUNDIALS INTERFACE IMPORTED)
58-
add_dependencies(SUNDIALS sundials-external)
47+
add_dependencies(SUNDIALS sundials)
48+
49+
set(SUNDIALS_INCLUDE_DIR
50+
"${SUNDIALS_INCLUDE_DIR}"
51+
PARENT_SCOPE)
52+
set(SUNDIALS_LIB_DIR
53+
"${SUNDIALS_LIB_DIR}"
54+
PARENT_SCOPE)

external/sundials

Submodule sundials added at 71b3dae

0 commit comments

Comments
 (0)