-# For all C++ sources a big source file which includes all the files
-# is created.
-# This is not done for the C sources, they are just gathered in a separate list
-# because they are usually not written by KDE and as such not intended to be
-# compiled all-in-one.
-macro (KDE4_CREATE_FINAL_FILES _filenameCPP _filesExcludedFromFinalFile )
- set(${_filesExcludedFromFinalFile})
- file(WRITE ${_filenameCPP} "//autogenerated file\n")
- foreach (_current_FILE ${ARGN})
+macro(lyx_const_touched_files _allinone_name _list)
+ set(_file_list ${_allinone_name}_files)
+ set(_file_const ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_const.C)
+ set(_file_touched ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_touched.C)
+
+
+ # don't touch exisiting or non-empty file,
+ # so a cmake re-run doesn't touch all created files
+ set(_rebuild_file_const 0)
+ if (NOT EXISTS ${_file_const})
+ set(_rebuild_file_const 1)
+ else()
+ FILE(READ ${_file_const} _file_content)
+ if (NOT _file_content)
+ set(_rebuild_file_const 1)
+ endif()
+ endif()
+
+ set(_rebuild_file_touched 0)
+ if (NOT EXISTS ${_file_touched})
+ set(_rebuild_file_touched 1)
+ else()
+ FILE(READ ${_file_touched} _file_content)
+ if (NOT _file_content)
+ set(_rebuild_file_touched 1)
+ endif()
+ endif()
+
+ if (merge_rebuild)
+ set(_rebuild_file_const 1)
+ set(_rebuild_file_touched 1)
+ endif()
+
+ if (_rebuild_file_const)
+ file(WRITE ${_file_const} "// autogenerated file \n//\n")
+ file(APPEND ${_file_const} "// * clear or delete this file to build it again by cmake \n//\n\n")
+ endif()
+
+ if (_rebuild_file_touched)
+ file(WRITE ${_file_touched} "// autogenerated file \n//\n")
+ file(APPEND ${_file_touched} "// * clear or delete this file to build it again by cmake \n//\n")
+ file(APPEND ${_file_touched} "// * don't touch this file \n//\n\n")
+ file(APPEND ${_file_touched} "#define DONT_INCLUDE_CONST_FILES\n")
+ file(APPEND ${_file_touched} "#include \"${_file_const}\"\n\n\n")
+ endif()
+
+ set(${_file_list} ${_file_const} ${_file_touched})
+
+ foreach (_current_FILE ${${_list}})