@@ -53,28 +53,51 @@ set(KINDERIV_HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/_kinderiv.h")
5353
5454set (NMODL_UNITS_FILE "${CMAKE_BINARY_DIR} /share/mod2c/nrnunits.lib" )
5555
56- # copy inbuilt mod files {source}/coreneuron/mechanism/mech/modfile/*.mod to
57- # {build_dir}/share/modfile/
56+ # =============================================================================
57+ # Copy files that are required by nrnivmodl-core to the build tree at build time.
58+ # =============================================================================
59+ cpp_cc_build_time_copy(
60+ INPUT "${CMAKE_CURRENT_SOURCE_DIR} /${MODFUNC_PERL_SCRIPT} "
61+ OUTPUT "${CMAKE_BINARY_DIR} /share/coreneuron/mod_func.c.pl"
62+ NO_TARGET)
63+ cpp_cc_build_time_copy(
64+ INPUT "${KINDERIV_PYTHON_SCRIPT} "
65+ OUTPUT "${CMAKE_BINARY_DIR} /share/coreneuron/kinderiv.py"
66+ NO_TARGET)
67+ cpp_cc_build_time_copy(
68+ INPUT "${CMAKE_CURRENT_SOURCE_DIR} /${DIMPLIC_CODE_FILE} "
69+ OUTPUT "${CMAKE_BINARY_DIR} /share/coreneuron/dimplic.cpp"
70+ NO_TARGET)
71+ cpp_cc_build_time_copy(
72+ INPUT "${CMAKE_CURRENT_SOURCE_DIR} /${ENGINEMECH_CODE_FILE} "
73+ OUTPUT "${CMAKE_BINARY_DIR} /share/coreneuron/enginemech.cpp"
74+ NO_TARGET)
75+ set (nrnivmodl_core_dependencies
76+ "${CMAKE_BINARY_DIR} /share/coreneuron/mod_func.c.pl"
77+ "${CMAKE_BINARY_DIR} /share/coreneuron/kinderiv.py"
78+ "${CMAKE_BINARY_DIR} /share/coreneuron/dimplic.cpp"
79+ "${CMAKE_BINARY_DIR} /share/coreneuron/enginemech.cpp" )
80+ # Set up build rules that copy builtin mod files from
81+ # {source}/coreneuron/mechanism/mech/modfile/*.mod to {build_dir}/share/modfile/
5882file (GLOB builtin_modfiles
5983 "${CORENEURON_PROJECT_SOURCE_DIR} /coreneuron/mechanism/mech/modfile/*.mod" )
60- # get the corresponding list of paths to the modfiles in the build directory
61- set (builtin_modfiles_in_build_dir)
6284foreach (builtin_modfile ${builtin_modfiles} )
85+ # Construct the path in the build directory.
6386 get_filename_component (builtin_modfile_name "${builtin_modfile} " NAME )
64- list (APPEND builtin_modfiles_in_build_dir
65- "${CMAKE_BINARY_DIR} /share/modfile/${builtin_modfile_name} " )
87+ set (modfile_build_path "${CMAKE_BINARY_DIR} /share/modfile/${builtin_modfile_name} " )
88+ # Create a build rule to copy the modfile there.
89+ cpp_cc_build_time_copy(
90+ INPUT "${builtin_modfile} "
91+ OUTPUT "${modfile_build_path} "
92+ NO_TARGET)
93+ list (APPEND nrnivmodl_core_dependencies "${modfile_build_path} " )
6694endforeach ()
67- file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR} /share/modfile" )
68- # set up a build rule that ensures the modfiles in the build directory are updated if their
69- # counterparts in the source directory are touched
70- add_custom_command (
71- OUTPUT ${builtin_modfiles_in_build_dir}
72- DEPENDS ${builtin_modfiles}
73- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${builtin_modfiles}
74- "${CMAKE_BINARY_DIR} /share/modfile" )
75- add_custom_target (copy-builtin-modfiles ALL DEPENDS ${builtin_modfiles_in_build_dir} )
95+ add_custom_target (coreneuron-copy-nrnivmodl-core-dependencies ALL
96+ DEPENDS ${nrnivmodl_core_dependencies} )
97+ # Store the build-tree modfile paths in a cache variable; these are an implicit dependency of
98+ # nrnivmodl-core.
7699set (CORENEURON_BUILTIN_MODFILES
77- "${builtin_modfiles_in_build_dir } "
100+ "${nrnivmodl_core_dependencies } "
78101 CACHE STRING "List of builtin modfiles that nrnivmodl-core implicitly depends on" FORCE)
79102
80103# =============================================================================
@@ -201,15 +224,6 @@ set(CORENRN_LINK_LIBS
201224 "${CORENRN_LINK_LIBS} "
202225 PARENT_SCOPE)
203226
204- # =============================================================================
205- # Copy files for nrnivmodl-core workflow during build time
206- # =============================================================================
207-
208- configure_file (${MODFUNC_PERL_SCRIPT} ${CMAKE_BINARY_DIR} /share/coreneuron/mod_func.c.pl COPYONLY )
209- configure_file (${KINDERIV_PYTHON_SCRIPT} ${CMAKE_BINARY_DIR} /share/coreneuron/kinderiv.py COPYONLY )
210- configure_file (${DIMPLIC_CODE_FILE} ${CMAKE_BINARY_DIR} /share/coreneuron/dimplic.cpp COPYONLY )
211- configure_file (${ENGINEMECH_CODE_FILE} ${CMAKE_BINARY_DIR} /share/coreneuron/enginemech.cpp COPYONLY )
212-
213227# Make headers avail to build tree
214228configure_file (engine.h.in ${CMAKE_BINARY_DIR} /include /coreneuron/engine.h @ONLY)
215229
0 commit comments