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

Commit 22e6e40

Browse files
authored
Default/Minimal coreneuron should be always available in NEURON (cpu) (#789)
* Before this PR, user always had to do `nrnivmodl -coreneuron .`` to have coreneuron with default mechanisms. * This was because we were not installing default mechanism library libcorenrnmech.so into install dir. Note that this was done in order to force user to re-build optimised library from vendor compiler like Intel. * But, for basic demonstration and testing, I think it's always helpful to ship default mechanism library as a fallback. The library <arch>/libcorenrnmech.so built by user will be preferred anyway. * Update nmodl to latest master
1 parent f72026d commit 22e6e40

File tree

8 files changed

+29
-14
lines changed

8 files changed

+29
-14
lines changed

coreneuron/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,25 @@ set_target_properties(
326326
# =============================================================================
327327
set(modfile_directory "${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod")
328328
file(GLOB modfiles "${modfile_directory}/*.mod")
329+
330+
if(CORENRN_ENABLE_SHARED)
331+
set(corenrn_mech_library
332+
"${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/libcorenrnmech${CMAKE_SHARED_LIBRARY_SUFFIX}"
333+
CACHE INTERNAL "coreneuron mechanism library")
334+
else()
335+
set(corenrn_mech_library
336+
"${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/libcorenrnmech${CMAKE_STATIC_LIBRARY_SUFFIX}"
337+
CACHE INTERNAL "coreneuron mechanism library")
338+
endif()
339+
329340
set(output_binaries "${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/special-core"
330-
"${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/libcorenrnmech.a")
341+
"${corenrn_mech_library}")
342+
331343
add_custom_command(
332344
OUTPUT ${output_binaries}
333345
DEPENDS scopmath coreneuron ${NMODL_TARGET_TO_DEPEND} ${modfiles} ${CORENEURON_BUILTIN_MODFILES}
334-
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -b STATIC -m ${CORENRN_MOD2CPP_BINARY} -p 1
335-
"${modfile_directory}"
346+
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -b ${COMPILE_LIBRARY_TYPE} -m
347+
${CORENRN_MOD2CPP_BINARY} -p 1 "${modfile_directory}"
336348
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
337349
COMMENT "Running nrnivmodl-core with halfgap.mod")
338350
add_custom_target(nrniv-core ALL DEPENDS ${output_binaries})
@@ -416,6 +428,9 @@ install(
416428
RENAME nrniv-core)
417429
install(FILES apps/coreneuron.cpp DESTINATION share/coreneuron)
418430

431+
# install mechanism library
432+
install(FILES ${corenrn_mech_library} DESTINATION lib)
433+
419434
# install random123 and nmodl headers
420435
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ DESTINATION include)
421436

extra/nrnivmodl_core_makefile.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ ORIGIN_RPATH := $(if $(filter Darwin,$(OS_NAME)),@loader_path,$$ORIGIN)
182182
SONAME_OPTION := -Wl,$(if $(filter Darwin,$(OS_NAME)),-install_name${COMMA_OP}@rpath/,-soname${COMMA_OP})$(notdir ${COREMECH_LIB_PATH})
183183
LIB_RPATH = $(if $(DESTDIR),$(DESTDIR)/lib,$(ORIGIN_RPATH))
184184

185+
# When special-core is installed, it needs to find library in the
186+
# lib folder of install prefix. We use relative path in order it
187+
# to be portable when files are moved (e.g. python wheel)
188+
INSTALL_LIB_RPATH = $(ORIGIN_RPATH)/../lib
189+
185190
# All objects used during build
186191
ALL_OBJS = $(MOD_FUNC_OBJ) $(DIMPLIC_OBJ) $(mod_cpp_objs) $(mod_ispc_objs)
187192

@@ -214,7 +219,7 @@ $(SPECIAL_EXE): coremech_lib_target
214219
$(CXX_LINK_EXE_CMD) -o $(SPECIAL_EXE) $(CORENRN_SHARE_CORENRN_DIR)/coreneuron.cpp \
215220
-I$(CORENRN_INC_DIR) $(INCFLAGS) \
216221
-L$(OUTPUT_DIR) -l$(COREMECH_LIB_NAME) $(CORENRNLIB_FLAGS) $(LDFLAGS) \
217-
-Wl,-rpath,'$(LIB_RPATH)' -Wl,-rpath,$(CORENRN_LIB_DIR)
222+
-Wl,-rpath,'$(LIB_RPATH)' -Wl,-rpath,$(CORENRN_LIB_DIR) -Wl,-rpath,'$(INSTALL_LIB_RPATH)'
218223

219224
coremech_lib_target: $(corenrnmech_lib_target)
220225
rm -rf $(OUTPUT_DIR)/.libs/lib$(COREMECH_LIB_NAME)$(LIB_SUFFIX); \

tests/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ endif()
1414

1515
set(CMAKE_BUILD_RPATH ${CMAKE_BINARY_DIR}/bin/${CMAKE_HOST_SYSTEM_PROCESSOR})
1616

17-
# mechanism library path
18-
set(corenrn_mech_lib
19-
"${CMAKE_BINARY_DIR}/bin/${CMAKE_HOST_SYSTEM_PROCESSOR}/libcorenrnmech${CMAKE_STATIC_LIBRARY_SUFFIX}"
20-
)
21-
2217
set(Boost_NO_BOOST_CMAKE TRUE)
2318
find_package(Boost 1.41.0 QUIET COMPONENTS filesystem system atomic unit_test_framework)
2419

tests/unit/cmdline_interface/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target_link_libraries(
99
${MPI_CXX_LIBRARIES}
1010
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
1111
coreneuron
12-
${corenrn_mech_lib}
12+
${corenrn_mech_library}
1313
${reportinglib_LIBRARY}
1414
${sonatareport_LIBRARY})
1515
target_include_directories(cmd_interface_test_bin SYSTEM

tests/unit/interleave_info/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target_link_libraries(
99
${MPI_CXX_LIBRARIES}
1010
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
1111
coreneuron
12-
${corenrn_mech_lib}
12+
${corenrn_mech_library}
1313
${reportinglib_LIBRARY}
1414
${sonatareport_LIBRARY})
1515
add_dependencies(interleave_info_bin nrniv-core)

tests/unit/lfp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ target_link_libraries(
1313
${MPI_CXX_LIBRARIES}
1414
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
1515
coreneuron
16-
${corenrn_mech_lib}
16+
${corenrn_mech_library}
1717
${reportinglib_LIBRARY}
1818
${sonatareport_LIBRARY})
1919
# Tell CMake *not* to run an explicit device code linker step (which will produce errors); let the

tests/unit/queueing/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target_link_libraries(
99
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
1010
${Boost_SYSTEM_LIBRARY}
1111
coreneuron
12-
${corenrn_mech_lib}
12+
${corenrn_mech_library}
1313
${reportinglib_LIBRARY}
1414
${sonatareport_LIBRARY})
1515
add_dependencies(queuing_test_bin nrniv-core)

0 commit comments

Comments
 (0)