-macro(lyx_merge_files _filename _list)
- message("----- Generating merged file ${_filename}\n")
- set(_tmp)
- set(_content)
- foreach(_current ${${_list}})
- file(READ ${_current} _tmp)
- set(_content ${_content} "\n\n\n\n//----------------------------------------\n/*\n file: ${_current} \n*/\n\n")
- set(_content ${_content} ${_tmp})
- endforeach(_current)
- file(WRITE ${_filename} "${_content}")
-endmacro(lyx_merge_files _list _filename)
+# 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})
+ get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
+ # don't include any generated files in the final-file
+ # because then cmake will not know the dependencies
+ get_source_file_property(_isGenerated ${_abs_FILE} GENERATED)
+ if (_isGenerated)
+ list(APPEND ${_filesExcludedFromFinalFile} ${_abs_FILE})
+ else (_isGenerated)
+ # don't include c-files in the final-file, because they usually come
+ # from a 3rd party and as such are not intended to be compiled all-in-one
+ string(REGEX MATCH ".+\\.c$" _isCFile ${_abs_FILE})
+ if (_isCFile)
+ list(APPEND ${_filesExcludedFromFinalFile} ${_abs_FILE})
+ else (_isCFile)
+ file(APPEND ${_filenameCPP} "#include \"${_abs_FILE}\"\n")
+ endif (_isCFile)
+ endif (_isGenerated)
+ endforeach (_current_FILE)
+
+endmacro (KDE4_CREATE_FINAL_FILES)