Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit ca4345d

Browse files
author
Nicolas Cornu
authored
Add mod2c as subdirectory instead of external project (#409)
* Add mod2c as add_subdirectory instead of external project * unset PMI_RANK inside nrnivmodl-core * Fix nrnunits.lib path for install * Update mod2c to latest master
1 parent 0fe2465 commit ca4345d

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

CMake/AddMod2cSubmodule.cmake

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# See top-level LICENSE file for details.
55
# =============================================================================
66

7-
include(ExternalProject)
87
find_package(FindPkgConfig QUIET)
98

109
find_path(
@@ -29,14 +28,4 @@ else()
2928
message(STATUS "Using mod2c submodule from ${MOD2C_PROJ}")
3029
endif()
3130

32-
set(ExternalProjectCMakeArgs
33-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
34-
-DCMAKE_C_COMPILER=${CORENRN_FRONTEND_C_COMPILER}
35-
-DCMAKE_CXX_COMPILER=${CORENRN_FRONTEND_CXX_COMPILER})
36-
37-
ExternalProject_Add(
38-
mod2c
39-
BUILD_ALWAYS 1
40-
SOURCE_DIR ${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c
41-
GIT_SUBMODULES
42-
CMAKE_ARGS ${ExternalProjectCMakeArgs})
31+
add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/mod2c)

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ if(CORENRN_ENABLE_NMODL)
275275
separate_arguments(NMODL_EXTRA_FLAGS_LIST UNIX_COMMAND "${CORENRN_NMODL_FLAGS}")
276276
else()
277277
include(AddMod2cSubmodule)
278-
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/mod2c_core${CMAKE_EXECUTABLE_SUFFIX})
278+
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/external/mod2c/src/mod2c_core/mod2c_core${CMAKE_EXECUTABLE_SUFFIX})
279279
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
280280
endif()
281281

coreneuron/CMakeLists.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ set(MODFUNC_PERL_SCRIPT "mechanism/mech/mod_func.c.pl")
5050
set(KINDERIV_PYTHON_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/kinderiv.py")
5151
set(KINDERIV_HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/_kinderiv.h")
5252

53-
set(NMODL_UNITS_FILE "${CMAKE_BINARY_DIR}/share/nrnunits.lib")
53+
set(NMODL_UNITS_FILE "${CMAKE_BINARY_DIR}/share/mod2c/nrnunits.lib")
5454

5555
# copy inbuilt mod files to share
5656
file(COPY ${CORENEURON_PROJECT_SOURCE_DIR}/coreneuron/mechanism/mech/modfile
@@ -153,6 +153,7 @@ set_target_properties(
153153
add_custom_target(
154154
nrniv-core ALL
155155
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -b STATIC
156+
-m ${CORENRN_NMODL_BINARY}
156157
${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod
157158
WORKING_DIRECTORY
158159
${CMAKE_BINARY_DIR}/bin
@@ -198,17 +199,6 @@ endforeach()
198199
configure_file("utils/profile/profiler_interface.h"
199200
${CMAKE_BINARY_DIR}/include/coreneuron/nrniv/profiler_interface.h COPYONLY)
200201

201-
if(NOT CORENRN_ENABLE_NMODL)
202-
# ~~~
203-
# MOD2C puts UNITS_FILE in share, but we need to see it in share/mod2c We create
204-
# a link since we know neither the source location nor when its copied
205-
# ~~~
206-
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/share/mod2c/")
207-
add_custom_target(link_units ALL COMMAND ${CMAKE_COMMAND} -E create_symlink "${NMODL_UNITS_FILE}"
208-
"${CMAKE_BINARY_DIR}/share/mod2c/nrnunits.lib")
209-
add_dependencies(nrniv-core link_units)
210-
endif()
211-
212202
# main program required for building special-core
213203
file(COPY apps/coreneuron.cpp DESTINATION ${CMAKE_BINARY_DIR}/share/coreneuron)
214204

external/mod2c

extra/nrnivmodl-core.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
set -e
99

10+
# TODO : mod2c_core can be linked with (HPE-)MPI library
11+
# and running that under slurm allocation result into
12+
# runtime error. For now, unset PMI_RANK variable
13+
# which is sufficint to avoid issue with HPE-MPI+SLURM.
14+
unset PMI_RANK
15+
1016
# name of the script
1117
APP_NAME=$(basename $0)
1218

0 commit comments

Comments
 (0)