|
1 | | -# ============================================================================= |
2 | | -# Sundials |
3 | | -# ============================================================================= |
| 1 | +# cmake/modules/FindSUNDIALS.cmake |
4 | 2 |
|
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") |
7 | 17 | set(SUNDIALS_INCLUDE_DIR "${SUNDIALS_PREFIX}/include") |
8 | 18 | set(SUNDIALS_LIB_DIR "${SUNDIALS_PREFIX}/lib") |
9 | | -make_directory(${SUNDIALS_INCLUDE_DIR}) |
10 | 19 |
|
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") |
15 | 20 | include(ExternalProject) |
16 | 21 | ExternalProject_Add( |
17 | | - sundials-external |
| 22 | + sundials |
| 23 | + SOURCE_DIR "${SUNDIALS_SOURCE_DIR}" |
18 | 24 | 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 "" |
32 | 25 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> |
33 | 26 | -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} |
34 | 27 | -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} |
35 | | - -DCMAKE_C_FLAGS=${SUNDIALS_C_FLAGS} |
36 | | - -DCMAKE_CXX_FLAGS=${SUNDIALS_CXX_FLAGS} |
37 | 28 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} |
| 29 | + -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 30 | + -DBUILD_SHARED_LIBS=OFF |
| 31 | + -DEXAMPLES_ENABLE_C=OFF |
38 | 32 | -DEXAMPLES_INSTALL=OFF |
39 | 33 | -DBUILD_ARKODE=OFF |
40 | 34 | -DBUILD_CVODES=OFF |
41 | 35 | -DBUILD_IDAS=OFF |
42 | 36 | -DBUILD_KINSOL=OFF |
43 | | - -DEXAMPLES_ENABLE_C=OFF |
44 | 37 | -DMPI_ENABLE=OFF |
45 | 38 | -DPTHREAD_ENABLE=ON |
46 | 39 | -DSUNDIALS_PRECISION=double |
47 | 40 | -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} |
52 | 41 | 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 |
54 | 43 | <INSTALL_DIR>/lib/libsundials_nvecserial.a <INSTALL_DIR>/lib/libsundials_nvecpthreads.a |
55 | | - <INSTALL_DIR>/lib/libsundials_nvecparallel.a) |
| 44 | + INSTALL_DIR "${SUNDIALS_PREFIX}") |
56 | 45 |
|
57 | 46 | 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) |
0 commit comments