)
endif()
+# The mkoptions.py script only updates its output files if their content would
+# actually change. This mechanism makes sure that running the script does not
+# automatically trigger a full rebuild, but only a rebuild of those parts that
+# include files that did actually change.
+# This approach also means that the output files (which gen-options used to
+# depend on) may not actually be updated and thus cmake would keep re-running
+# mkoptions.py over and over again.
+# We thus have an artificial options.stamp file that mkoptions.py always writes
+# to, and can thus be used to communicate that all options files have been
+# properly updated.
add_custom_command(
- OUTPUT
- ${options_gen_cpp_files} ${options_gen_h_files}
- ${options_gen_doc_files}
- COMMAND
- ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/options
- COMMAND
- ${PYTHON_EXECUTABLE}
- ${CMAKE_CURRENT_LIST_DIR}/options/mkoptions.py
- ${CMAKE_CURRENT_LIST_DIR}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${abs_toml_files}
- DEPENDS
- options/mkoptions.py
- ${options_toml_files}
- main/options_template.cpp
- options/module_template.h
- options/module_template.cpp
- options/options_public_template.cpp
- options/options_template.h
- options/options_template.cpp
-)
-
-add_custom_target(gen-options
+ OUTPUT
+ options/options.stamp
+ COMMAND
+ ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/options
+ COMMAND
+ ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_LIST_DIR}/options/mkoptions.py
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${abs_toml_files}
+ BYPRODUCTS
+ ${options_gen_cpp_files} ${options_gen_h_files} ${options_gen_doc_files}
DEPENDS
- ${options_gen_cpp_files}
- ${options_gen_h_files}
+ options/mkoptions.py
+ ${options_toml_files}
+ main/options_template.cpp
+ options/module_template.h
+ options/module_template.cpp
+ options/options_public_template.cpp
+ options/options_template.h
+ options/options_template.cpp
)
+add_custom_target(gen-options DEPENDS options/options.stamp)
+
#-----------------------------------------------------------------------------#
codegen_module(module, dst_dir, module_tpls)
codegen_all_modules(modules, build_dir, dst_dir, global_tpls)
+ # Generate output file to signal cmake when this script was run last
+ open(os.path.join(dst_dir, 'options/options.stamp'), 'w').write('')
+
if __name__ == "__main__":
mkoptions_main()