-
Notifications
You must be signed in to change notification settings - Fork 125
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
base: master
Are you sure you want to change the base?
Conversation
This PR aims to allow dependent projects to build their models via CMake rather than a combination of shell scripts and Makefiles. In the long term, this may help facilitate building natively on Windows. To try: ``` git clone -b imported-main https://github.com/BlueBrain/neurodamus-models.git cd neurodamus-models ``` Create a `CMakeLists.txt` with contents like: ```cmake cmake_minimum_required(VERSION 3.28) project(newrodamus) find_package(neuron REQUIRED) create_libnrnmech(MOD_FILES neocortex/mod/v6/CaDynamics_DC0.mod neocortex/mod/v6/Ca_HVA2.mod neocortex/mod/v6/Ca_LVAst.mod neocortex/mod/v6/DetAMPANMDA.mod neocortex/mod/v6/DetGABAAB.mod neocortex/mod/v6/GluSynapse.mod neocortex/mod/v6/Ih.mod neocortex/mod/v6/K_Pst.mod neocortex/mod/v6/K_Tst.mod neocortex/mod/v6/KdShu2007.mod neocortex/mod/v6/NaTg.mod neocortex/mod/v6/Nap_Et2.mod neocortex/mod/v6/ProbAMPANMDA_EMS.mod neocortex/mod/v6/ProbGABAAB_EMS.mod neocortex/mod/v6/SK_E2.mod neocortex/mod/v6/SKv3_1.mod neocortex/mod/v6/StochKv3.mod neocortex/mod/v6/TTXDynamicsSwitch.mod neocortex/mod/v6/VecStim.mod neocortex/mod/v6/gap.mod neocortex/mod/v6/netstim_inhpoisson.mod ) ``` Then build and install: ``` cmake -B build -S . -GNinja -DCMAKE_INSTALL_PREFIX=x86_64 cmake --build build cmake --install build ``` To be continued‥
Always use resolved absolute paths in CMake since nocmodl has some trouble with symlinks.
* add docs and various args
Also finally add (hacky) test
✔️ 535bb1c -> artifacts URL |
✔️ 535bb1c -> Azure artifacts URL |
✔️ 3a7bb98 -> Azure artifacts URL |
✔️ 3a7bb98 -> artifacts URL |
✔️ 908dc4e -> artifacts URL |
✔️ 908dc4e -> Azure artifacts URL |
✔️ 1462039 -> artifacts URL |
✔️ 1462039 -> Azure artifacts URL |
✔️ 446fb48 -> Azure artifacts URL |
# - create a `special-core` executable in the `CMAKE_HOST_SYSTEM_PROCESSOR` subdirectory from the `coreneuron.cpp` file | ||
# - link the above executable to the `corenrnmech` library | ||
# Note that any other files created are basically noise. | ||
# create_nrnmech( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below for the full API of create_nrnmech
.
✔️ ebbe6f5 -> artifacts URL |
✔️ ebbe6f5 -> Azure artifacts URL |
|
✔️ 81c1d1f -> Azure artifacts URL |
launch-nvhpc-ci |
✔️ 81c1d1f -> artifacts URL |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3468 +/- ##
==========================================
+ Coverage 68.40% 68.42% +0.02%
==========================================
Files 682 682
Lines 116565 116565
==========================================
+ Hits 79731 79760 +29
+ Misses 36834 36805 -29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
NVHPC CI failed for commit 81c1d1f, see logs at https://gist.github.com/JCGoran/45276e21690eda095f22ed47ca02b052 |
Split off from #2746 since that PR was getting a bit too large.
Context
Currently we build mechanisms (mod files) using a hand-written Makefile. As a result, we need to ship a bunch of Make-specific tools with NEURON. This also does not work (or at least, not without a lot of workarounds) in a cross-platform manner.
This PR allows one to build NEURON mechanisms with CMake, using any generator we want. The way it achieves this is by exposing the
create_nrnmech
CMake function, which works as follows:Note that the
NEURON
,CORENEURON
, andSPECIAL
toggle whether one buildslibnrnmech
,libcorenrnmech
, and thespecial
executable (enablingCORENEURON
andSPECIAL
together enables thespecial-core
executable as well).One can then build the targets via:
which can then be loaded into NEURON as usual:
Additional notes
CMAKE_PREFIX_PATH
, and thenmodl
executable must be inPATH
. Additionally, until NOCMODL fails to run from build directory without settingMODLUNIT
#3470 is resolved,MODLUNIT
must also be setnrnivmodl
touches a lot of the internal code as well, so the changeset would be much larger)CMAKE_PREFIX_PATH
should include{NEURON_INSTALL_DIR}/.data/lib/cmake
, though I am not sure how to obtain it without running any external utilitiescmake
andninja
, but since this feature is a bit experimental, I'm not sure how useful it is