Skip to content

cmake: export targets, allow building mechanisms via CMake, part 1 #3468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
744864a
cmake: export targets, allow to build models via CMake
matz-e Feb 17, 2024
2df2103
Bump stuff.
matz-e Aug 15, 2024
87cc65b
Fix formatting
github-actions[bot] Aug 15, 2024
fd75527
Merge branch 'master' into export-cmake
JCGoran Jan 16, 2025
489c390
Add fmt to linked libs for testing
JCGoran Jan 16, 2025
65fc1ee
Also link fmt in Python build
JCGoran Jan 16, 2025
047732d
Put back the original `hh.mod`
JCGoran Jan 16, 2025
86895cb
Fix issue with corenrn target
JCGoran Jan 20, 2025
5947fa8
Merge branch 'master' into export-cmake
JCGoran Apr 15, 2025
6a8c83b
Fix issues with paths
JCGoran Apr 17, 2025
3b8d0fb
Merge branch 'master' into jelic/cmake_mechanisms
JCGoran Jun 3, 2025
58a380f
Update create_nrnmech
JCGoran Jun 3, 2025
f0eaccc
Remove comments
JCGoran Jun 3, 2025
c0f168a
Add tentative test
JCGoran Jun 4, 2025
758142c
Neuron config
JCGoran Jun 4, 2025
32c2cc1
Fix include paths
JCGoran Jun 4, 2025
6a8ed75
Add NEURON and special
JCGoran Jun 4, 2025
6988505
Formatting
JCGoran Jun 4, 2025
b00f3dc
Better config
JCGoran Jun 4, 2025
2caa145
Merge branch 'master' into jelic/cmake_mechanisms
JCGoran Jun 4, 2025
535bb1c
Formatting
JCGoran Jun 4, 2025
3a7bb98
Appease MODLUNIT
JCGoran Jun 4, 2025
908dc4e
Workaround for NOCMODL
JCGoran Jun 4, 2025
a121ef7
Merge branch 'master' into jelic/cmake_mechanisms
JCGoran Jun 5, 2025
1462039
Use same compiler as used by system
JCGoran Jun 5, 2025
446fb48
Disable CMake mechanism test if using sanitizers
JCGoran Jun 5, 2025
ebbe6f5
Use `-nopython` when launching `special`
JCGoran Jun 5, 2025
81c1d1f
Disable test on coverage as well
JCGoran Jun 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ endif()
# initialize CLI11 submodule
cpp_cc_git_submodule(CLI11 BUILD PACKAGE CLI11 REQUIRED)

# coreneuron targets will get propagated down from the subdirectory
set(NRN_INSTALL_TARGETS nrniv_lib nocmodl)

# =============================================================================
# Enable NMODL code-generator support
# =============================================================================
Expand Down Expand Up @@ -1104,6 +1107,37 @@ if(NRN_MACOS_BUILD AND NOT SKBUILD)
nrn_macos_after_install()
endif()

# =============================================================================
# Install CMake glue
# =============================================================================
configure_file(cmake/neuronMechMaker.cmake
"${PROJECT_BINARY_DIR}/lib/cmake/neuron/neuronMechMaker.cmake" COPYONLY)
configure_file(cmake/mod_reg_nrn.cpp.in "${PROJECT_BINARY_DIR}/share/nrn/mod_reg_nrn.cpp.in"
COPYONLY)
configure_file(cmake/mod_reg_corenrn.cpp.in
"${PROJECT_BINARY_DIR}/share/nrn/mod_reg_corenrn.cpp.in" COPYONLY)
install(TARGETS ${NRN_INSTALL_TARGETS} ${CORENRN_INSTALL_TARGETS} EXPORT NeuronTargets)
export(
EXPORT NeuronTargets
FILE ${PROJECT_BINARY_DIR}/lib/cmake/neuron/neuronTargets.cmake
NAMESPACE neuron::)

install(
EXPORT NeuronTargets
FILE neuronTargets.cmake
NAMESPACE neuron::
DESTINATION lib/cmake/neuron)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/neuronConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/neuron/neuronConfig.cmake @ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/neuron/neuronConfig.cmake
DESTINATION lib/cmake/neuron)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/neuronMechMaker.cmake DESTINATION lib/cmake/neuron)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod_reg_nrn.cpp.in
${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod_reg_corenrn.cpp.in DESTINATION share/nrn)

# =============================================================================
# Copy bash executable for windows
# =============================================================================
Expand Down
16 changes: 16 additions & 0 deletions cmake/mod_reg_corenrn.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cstdio>
namespace coreneuron {
extern int nrnmpi_myid;
extern int nrn_nobanner_;

@MECH_DECLARE@

void modl_reg() {
if (!nrn_nobanner_) if (nrnmpi_myid < 1) {
fprintf(stderr, " Additional mechanisms from files\n");
@MECH_PRINT@
fprintf(stderr, "\n\n");
}
@MECH_REGISTRE@
}
} //namespace coreneuron
16 changes: 16 additions & 0 deletions cmake/mod_reg_nrn.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include "hocdec.h"
extern int nrnmpi_myid;
extern int nrn_nobanner_;

@MECH_DECLARE@

extern "C" void modl_reg() {
if (!nrn_nobanner_) if (nrnmpi_myid < 1) {
fprintf(stderr, "Additional mechanisms from files\n");
@MECH_PRINT@
fprintf(stderr, "\n");
}
@MECH_REGISTRE@
}

25 changes: 25 additions & 0 deletions cmake/neuronConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include(CMakeFindDependencyMacro)

find_dependency(Threads)

include("${CMAKE_CURRENT_LIST_DIR}/neuronTargets.cmake")

get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)

set(NRN_ENABLE_CORENEURON @NRN_ENABLE_CORENEURON@)

set(_NEURON_MAIN "${_prefix}/share/nrn/nrnmain.cpp")
set(_NEURON_MAIN_INCLUDE_DIR "${_prefix}/include/nrncvode" "${_prefix}/include")
set(_NEURON_MECH_REG "${_prefix}/share/nrn/mod_reg_nrn.cpp.in")

set(_CORENEURON_BASE_MOD "${_prefix}/share/modfile")
set(_CORENEURON_MAIN "${_prefix}/share/coreneuron/coreneuron.cpp")
set(_CORENEURON_MECH_REG "${_prefix}/share/nrn/mod_reg_corenrn.cpp.in")
set(_CORENEURON_MECH_ENG "${_prefix}/share/coreneuron/enginemech.cpp")
set(_CORENEURON_RANDOM_INCLUDE "${_prefix}/include/coreneuron/utils/randoms" "${_prefix}/include")
set(_CORENEURON_FLAGS @CORENRN_CXX_FLAGS@)

find_program(NMODL nmodl REQUIRED)

include(${CMAKE_CURRENT_LIST_DIR}/neuronMechMaker.cmake)
Loading
Loading