diff --git a/CMakeLists.txt b/CMakeLists.txt index 57bd453036..160cbf2317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ option(NRN_ENABLE_THREADS "Allow use of multithreading" ${NRN_ENABLE_THREADS_DEF option(NRN_ENABLE_MPI "Enable MPI support" ${NRN_ENABLE_MPI_DEFAULT}) option(NRN_ENABLE_MUSIC "Enable MUSIC support" ${NRN_ENABLE_MUSIC_DEFAULT}) option(NRN_ENABLE_RX3D "Enable rx3d support" ${NRN_ENABLE_RX3D_DEFAULT}) +option(NRN_ENABLE_NMODL "Enable NMODL code-generator support" ${NRN_ENABLE_NMODL_DEFAULT}) option(NRN_ENABLE_CORENEURON "Enable CoreNEURON support" ${NRN_ENABLE_CORENEURON_DEFAULT}) option(NRN_ENABLE_BACKTRACE "Enable pretty-printed backtraces" ${NRN_ENABLE_BACKTRACE_DEFAULT}) option(NRN_ENABLE_TESTS "Enable unit tests" ${NRN_ENABLE_TESTS_DEFAULT}) @@ -502,6 +503,36 @@ endif() # initialize CLI11 submodule cpp_cc_git_submodule(CLI11 BUILD PACKAGE CLI11 REQUIRED) +# ============================================================================= +# Enable NMODL code-generator support +# ============================================================================= +if(NRN_ENABLE_NMODL OR NRN_ENABLE_CORENEURON) + + set(NMODL_ENABLE_PYTHON_BINDINGS + OFF + CACHE BOOL "Enable NMODL python bindings") + nrn_add_external_project(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) + + # 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 +567,7 @@ 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) + # NEURON tests that link against CoreNEURON need to depend on it. set(CORENEURON_TARGET_TO_DEPEND coreneuron-for-tests) diff --git a/cmake/BuildOptionDefaults.cmake b/cmake/BuildOptionDefaults.cmake index b43338e5ac..c4cc16b5a6 100644 --- a/cmake/BuildOptionDefaults.cmake +++ b/cmake/BuildOptionDefaults.cmake @@ -14,6 +14,7 @@ set(NRN_ENABLE_THREADS_DEFAULT ON) set(NRN_ENABLE_MPI_DEFAULT ON) set(NRN_ENABLE_MUSIC_DEFAULT OFF) set(NRN_ENABLE_RX3D_DEFAULT ON) +set(NRN_ENABLE_NMODL_DEFAULT OFF) set(NRN_ENABLE_CORENEURON_DEFAULT OFF) set(NRN_ENABLE_BACKTRACE_DEFAULT OFF) set(NRN_ENABLE_TESTS_DEFAULT OFF) diff --git a/cmake/coreneuron/packages/Findnmodl.cmake b/cmake/coreneuron/packages/Findnmodl.cmake deleted file mode 100644 index aa483c889e..0000000000 --- a/cmake/coreneuron/packages/Findnmodl.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# ============================================================================= -# Copyright (C) 2016-2021 Blue Brain Project -# -# See top-level LICENSE file for details. -# ============================================================================= - -# ~~~ -# Findnmodl -# ------------- -# -# Find nmodl -# -# Find the nmodl Blue Brain HPC utils library -# -# Using nmodl: -# -# :: -# set(CORENRN_NMODL_DIR "" CACHE PATH "Path to nmodl source-to-source compiler installation") -# find_package(nmodl REQUIRED) -# target_link_libraries(foo ${nmodl_LIBRARIES}) -# -# This module sets the following variables: -# -# :: -# -# nmodl_FOUND - set to true if the library is found -# nmodl_BINARY - the nmodl binary -# ~~~ - -# UNIX paths are standard, no need to write. -find_program( - nmodl_BINARY - NAMES nmodl${CMAKE_EXECUTABLE_SUFFIX} - HINTS "${CORENRN_NMODL_DIR}/bin" QUIET) - -# Checks 'REQUIRED', 'QUIET' and versions. -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - nmodl - FOUND_VAR nmodl_FOUND - REQUIRED_VARS nmodl_BINARY) diff --git a/src/coreneuron/CMakeLists.txt b/src/coreneuron/CMakeLists.txt index 1cf452d23c..59e78ae735 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 # =============================================================================