-
Notifications
You must be signed in to change notification settings - Fork 148
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
Merged
Merged
Changes from 85 commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
744864a
cmake: export targets, allow to build models via CMake
matz-e 2df2103
Bump stuff.
matz-e 87cc65b
Fix formatting
github-actions[bot] fd75527
Merge branch 'master' into export-cmake
489c390
Add fmt to linked libs for testing
65fc1ee
Also link fmt in Python build
047732d
Put back the original `hh.mod`
86895cb
Fix issue with corenrn target
5947fa8
Merge branch 'master' into export-cmake
6a8c83b
Fix issues with paths
0466496
Fix NMODL line numbers in parser
b833b1d
Add newer version of Bison to Docker image
bce4aec
Fix additional NMODL paths
398fd44
Merge branch 'master' into jelic/alternative_nmodl_fix
JCGoran cbef7ce
Update to lcov 2
8bbfdcd
Merge branch 'jelic/alternative_nmodl_fix' into jelic/parallel_lcov
7a74a13
Merge branch 'master' into jelic/alternative_nmodl_fix
2e2d1de
Alternative fix with flexible bison
236c51a
Merge remote-tracking branch 'origin/jelic/alternative_nmodl_fix' int…
94c568d
Extract version of lcov
be489a0
Set launcher command based on lcov version
e728fe7
Merge branch 'jelic/alternative_nmodl_fix' into jelic/parallel_lcov
d683140
Set lcov launcher flags based on version
5e38569
Revert to ubuntu 22.04 to see if it works
19ac8aa
Merge branch 'master' into jelic/parallel_lcov
3b8d0fb
Merge branch 'master' into jelic/cmake_mechanisms
58a380f
Update create_nrnmech
f0eaccc
Remove comments
c0f168a
Add tentative test
758142c
Neuron config
32c2cc1
Fix include paths
6a8ed75
Add NEURON and special
6988505
Formatting
b00f3dc
Better config
2caa145
Merge branch 'master' into jelic/cmake_mechanisms
535bb1c
Formatting
3a7bb98
Appease MODLUNIT
908dc4e
Workaround for NOCMODL
a121ef7
Merge branch 'master' into jelic/cmake_mechanisms
1462039
Use same compiler as used by system
446fb48
Disable CMake mechanism test if using sanitizers
ebbe6f5
Use `-nopython` when launching `special`
81c1d1f
Disable test on coverage as well
5b087b7
Merge branch 'master' into jelic/cmake_mechanisms
b08e772
Small changes
210f2c3
Merge branch 'master' into jelic/cmake_mechanisms
af6aa53
Fix for building special-core on NVHPC
6194db8
Fix formatting
6a5591d
Merge branch 'master' into jelic/cmake_mechanisms
0c8c917
Merge branch 'master' into jelic/cmake_mechanisms
5497de0
More flexibility for CUDA detection
2e7b44f
Use dynamic min CUDA toolkit version
b87f6c4
More debugging in `create_nrnmech`
64963f9
Actually update docs to use CMake
73f346c
Forgot to add it to reqs
6b3983f
Put docs back next to implementation
5f5f413
Add example to create_nrnmech
9a09835
Fix issue with wheels containing wrong paths
66ba781
Fix slashes in installer
e086ace
Add workaround for running special under wheels
a40003f
Update docs for CMake API
67c2759
Fix install dir on Windows
36887b0
Merge branch 'master' into jelic/cmake_mechanisms
8611ccc
Merge branch 'master' into jelic/parallel_lcov
697e1d2
Merge branch 'master' into jelic/cmake_mechanisms
JCGoran e4ce946
Merge branch 'master' into jelic/cmake_mechanisms
f68627e
Merge branch 'master' into jelic/cmake_mechanisms
009cc34
Merge branch 'jelic/parallel_lcov'
7e83672
Merge branch 'master' into jelic/cmake_mechanisms
4e0d8cb
Refactor test
539f509
Revert "Merge branch 'jelic/parallel_lcov'"
e492583
Make min version match one of NEURON
aabe405
Fix issue with embedded nrnunits.lib
1e189fc
Privately link to readline
9d76338
Embed nrnunits in NMODL
3efeb70
Revert "Fix issue with embedded nrnunits.lib"
f7e96e4
Merge branch 'jelic/embed_nrnunits_nmodl' into jelic/cmake_mechanisms
6ee81f7
Remove error message
dabcf6f
Merge branch 'jelic/embed_nrnunits_nmodl' into jelic/cmake_mechanisms
d0f8f46
Merge branch 'master' into jelic/cmake_mechanisms
6baa54f
Merge branch 'master' into jelic/cmake_mechanisms
305fb2d
Add `nrnivmodl.cmake`
7fcc855
Fix issue when using wheels
973a294
Merge branch 'master' into jelic/cmake_mechanisms
922bcf0
Update CI
4040182
Fix Azure CI
50ca338
Make SonarThing happy
5d59350
Put this back
52728a8
Merge branch 'master' into jelic/cmake_mechanisms
nrnhines 99e8d67
CodeCoverage ci error: keyword signature for target_link_libraries.
nrnhines 94081a3
Previous commit did not have PRIVATE as second arg
nrnhines 504d229
Merge branch 'master' into jelic/cmake_mechanisms
nrnhines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # ============================================================================= | ||
| # Simple wrapper for CMake that builds mechanisms from mod files | ||
| # ============================================================================= | ||
|
|
||
| set -eu | ||
|
|
||
| # Where the output files will be placed | ||
| bindir="$(uname -m)" | ||
|
|
||
| # The name of the current program | ||
| program_name="$(basename "${0}")" | ||
|
|
||
| # Where the `*.cmake` files are located | ||
| NRN_CMAKE_PREFIX_PATH_DEFAULT="$(readlink -f "$(dirname "${0}")/../lib/cmake/")" | ||
| if [ -n "${CMAKE_PREFIX_PATH:-}" ]; then | ||
| CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${NRN_CMAKE_PREFIX_PATH_DEFAULT}" | ||
| else | ||
| CMAKE_PREFIX_PATH="${NRN_CMAKE_PREFIX_PATH_DEFAULT}" | ||
| fi | ||
| export CMAKE_PREFIX_PATH | ||
|
|
||
| # On MacOS we need to set the deployment target to be equal to the one of NEURON | ||
| if command -v xcrun >& /dev/null; then | ||
| @NRN_OSX_BUILD_TRUE@export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)" | ||
| @NRN_OSX_BUILD_TRUE@export MACOSX_DEPLOYMENT_TARGET="@CMAKE_OSX_DEPLOYMENT_TARGET@" | ||
| if [ -z "${MACOSX_DEPLOYMENT_TARGET}" ]; then | ||
| unset MACOSX_DEPLOYMENT_TARGET | ||
| fi | ||
| fi | ||
|
|
||
| # We use the CMakeLists.txt from the NEURON installation directory to not have | ||
| # to deal with any pre-existing CMakeLists.txt in the current directory | ||
| srcdir="${NRN_CMAKE_PREFIX_PATH_DEFAULT}/neuron/nrnivmodl/" | ||
|
|
||
| # In case of no files, default to using the files in the current dir | ||
| if [ $# -lt 1 ]; then | ||
| set -- ./*.mod | ||
| # In case of a single input, check if it's a directory; if it is, collect all mod files in it | ||
| elif [ $# -eq 1 ] && [ -d "${1}" ]; then | ||
| printf "[%s] Collecting mod files under %s\n" "${program_name}" "$(readlink -f "${1}")" | ||
| set -- "${1}"/*.mod | ||
| fi | ||
|
|
||
| # After collecting the mod files, check each mod file actually exists | ||
| for mod_file in "$@"; do | ||
| if [ ! -e "${mod_file}" ]; then | ||
| printf "[%s] ERROR: Mod file %s does not exist!\n" "${program_name}" "${mod_file}" >&2 | ||
| exit 4 | ||
| fi | ||
| done | ||
|
|
||
| # Convert all mod file paths to absolute paths because the source dir is in the NEURON install | ||
| args=() | ||
| for f in "$@"; do | ||
| resolved=$(readlink -f "$f") || exit 1 | ||
| args+=("$resolved") | ||
| done | ||
| set -- "${args[@]}" | ||
|
|
||
| # TODO what if the mod filenames contain semicolons? | ||
| modfiles=$(IFS=";"; echo "$*") | ||
|
|
||
| # Configure the mod files | ||
| cmake \ | ||
| -S "${srcdir}" \ | ||
| -B "${bindir}" \ | ||
| -DNRNIVMODL_MOD_FILES="${modfiles}" \ | ||
| -DNRNIVMODL_NEURON=@NRNIVMODL_NEURON@ \ | ||
| -DNRNIVMODL_CORENEURON=@NRNIVMODL_CORENEURON@ | ||
|
|
||
| # Actually build them | ||
| cmake --build "${bindir}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@ | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@) | ||
|
|
||
| set(_CORENEURON_MIN_CUDA_TOOLKIT_VERSION @CORENRN_CUDA_VERSION_SHORT@) | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/neuronMechMaker.cmake") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.