Skip to content

Commit

Permalink
Refactor NMODL integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Oct 30, 2024
1 parent cd7ac7d commit 30605e2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
46 changes: 45 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,49 @@ endif()
# initialize CLI11 submodule
cpp_cc_git_submodule(CLI11 BUILD PACKAGE CLI11 REQUIRED)

# =============================================================================
# Enable NMODL code-generator support
# =============================================================================
if(NRN_ENABLE_CORENEURON)

# =============================================================================
# NMODL specific options
# =============================================================================
find_package(nmodl)
if(NOT "${CORENRN_NMODL_DIR}" STREQUAL "" AND NOT nmodl_FOUND)
message(FATAL_ERROR "Cannot find NMODL in ${CORENRN_NMODL_DIR}")
endif()
if(nmodl_FOUND)
set(CORENRN_NMODL_BINARY ${nmodl_BINARY})
else()
set(NMODL_ENABLE_PYTHON_BINDINGS
OFF
CACHE BOOL "Enable NMODL python bindings")
nrn_add_external_project(nmodl DISABLE_ADD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/nmodl ${CMAKE_BINARY_DIR}/external/nmodl)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
set(NMODL_TARGET_TO_DEPEND nmodl)
set(NMODL_PROJECT_BINARY_DIR ${CMAKE_BINARY_DIR}/external/nmodl)
# install nrnunits.lib and libpywrapper.so from external/nmodl
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/lib/libpywrapper${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION lib
COMPONENT pywrapper
OPTIONAL)
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/share/nmodl/nrnunits.lib
DESTINATION share/nmodl
COMPONENT nrnunits)
endif()
set_property(GLOBAL PROPERTY CORENRN_NMODL_BINARY "${CORENRN_NMODL_BINARY}")

# set correct arguments for nmodl for cpu/gpu target
set(CORENRN_NMODL_FLAGS
""
CACHE STRING "Extra NMODL options such as passes")

endif()

# =============================================================================
# Enable CoreNEURON support
# =============================================================================
Expand Down Expand Up @@ -536,7 +579,8 @@ if(NRN_ENABLE_CORENEURON)
get_property(CORENRN_LIB_LINK_FLAGS GLOBAL PROPERTY CORENRN_LIB_LINK_FLAGS)
get_property(CORENRN_NEURON_LINK_FLAGS GLOBAL PROPERTY CORENRN_NEURON_LINK_FLAGS)
get_property(CORENRN_ENABLE_SHARED GLOBAL PROPERTY CORENRN_ENABLE_SHARED)
get_property(CORENRN_NMODL_BINARY GLOBAL PROPERTY CORENRN_NMODL_BINARY)
# get_property(CORENRN_NMODL_BINARY GLOBAL PROPERTY CORENRN_NMODL_BINARY)

# NEURON tests that link against CoreNEURON need to depend on it.
set(CORENEURON_TARGET_TO_DEPEND coreneuron-for-tests)

Expand Down
36 changes: 0 additions & 36 deletions src/coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,42 +241,6 @@ if(MINGW)
list(APPEND CORENRN_COMPILE_DEFS MINGW)
endif()

# =============================================================================
# NMODL specific options
# =============================================================================
find_package(nmodl)
if(NOT "${CORENRN_NMODL_DIR}" STREQUAL "" AND NOT nmodl_FOUND)
message(FATAL_ERROR "Cannot find NMODL in ${CORENRN_NMODL_DIR}")
endif()
if(nmodl_FOUND)
set(CORENRN_NMODL_BINARY ${nmodl_BINARY})
else()
set(NMODL_ENABLE_PYTHON_BINDINGS
OFF
CACHE BOOL "Enable NMODL python bindings")
nrn_add_external_project(nmodl DISABLE_ADD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/nmodl ${CMAKE_BINARY_DIR}/external/nmodl)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
set(NMODL_TARGET_TO_DEPEND nmodl)
set(NMODL_PROJECT_BINARY_DIR ${CMAKE_BINARY_DIR}/external/nmodl)
# install nrnunits.lib and libpywrapper.so from external/nmodl
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/lib/libpywrapper${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION lib
COMPONENT pywrapper
OPTIONAL)
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/share/nmodl/nrnunits.lib
DESTINATION share/nmodl
COMPONENT nrnunits)
endif()
set_property(GLOBAL PROPERTY CORENRN_NMODL_BINARY "${CORENRN_NMODL_BINARY}")

# set correct arguments for nmodl for cpu/gpu target
set(CORENRN_NMODL_FLAGS
""
CACHE STRING "Extra NMODL options such as passes")

# =============================================================================
# Profiler/Instrumentation Options
# =============================================================================
Expand Down

0 comments on commit 30605e2

Please sign in to comment.