diff --git a/CMakeLists.txt b/CMakeLists.txt index 57bd4530363..79f2ec92ac9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 # ============================================================================= @@ -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) diff --git a/src/coreneuron/CMakeLists.txt b/src/coreneuron/CMakeLists.txt index 1cf452d23c5..59e78ae735f 100644 --- a/src/coreneuron/CMakeLists.txt +++ b/src/coreneuron/CMakeLists.txt @@ -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 # =============================================================================