-
Notifications
You must be signed in to change notification settings - Fork 127
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 |
✔️ 73f346c -> artifacts URL |
✔️ 64963f9 -> artifacts URL |
✔️ 73f346c -> Azure artifacts URL |
✔️ 5f5f413 -> artifacts URL |
✔️ 5f5f413 -> Azure artifacts URL |
✔️ 66ba781 -> artifacts URL |
✔️ 66ba781 -> Azure artifacts URL |
✔️ 67c2759 -> artifacts URL |
✔️ 67c2759 -> Azure artifacts URL |
|
✔️ 36887b0 -> Azure artifacts URL |
✔️ 36887b0 -> artifacts URL |
|
✔️ 697e1d2 -> artifacts URL |
✔️ 697e1d2 -> Azure artifacts URL |
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
nmodl
is now installed as a NEURON target so we only needCMAKE_PREFIX_PATH
.Additionally, until NOCMODL fails to run from build directory without settingissue fixed!MODLUNIT
#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_WHEEL_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 iswe are hardcoding some of the CLI options for now, which means that one should build NEURON from source, and then use the same installation for building mechanisms (otherwise I cannot guarantee that the mechanism-building will work)looks like it works without too much hardcodingrunningadded the same workaround as we use for wheels so now it worksspecial
when building from a wheel currently does not work OOTB because of the fact that NEURON hardcodes the path tonrnpyenv.sh
. The workaround is to addNEURONHOME=${NEURON_WHEEL_DIR}/.data/share/nrn"
to the envspecial-core
with NVHPC 25.3 and it works without issues. I did not want to add too many new tests since that will be tested anyway once the CMake build itself starts usingcreate_nrnmech
instead of callingnrnivmodl
(that's planned for part 2)