]> git.lyx.org Git - lyx.git/blobdiff - development/cmake/modules/LyXMacros.cmake
also improve build times when working on some files
[lyx.git] / development / cmake / modules / LyXMacros.cmake
index 3b157a322bff90423217c8b3a044f496e49df7f4..c0bef8b25e7fa9861a82f42553c2157d2b5e1232 100644 (file)
@@ -131,9 +131,18 @@ endmacro (LYX_AUTOMOC)
 # 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 )
+macro (LYX_CREATE_FINAL_FILES _filenameCPP _filesExcludedFromFinalFile )
    set(${_filesExcludedFromFinalFile})
    file(WRITE ${_filenameCPP} "//autogenerated file\n")
+
+   set(_file_macros ${CMAKE_CURRENT_BINARY_DIR}/${_filenameCPP}.h)
+   set(_file_const ${CMAKE_CURRENT_BINARY_DIR}/${_filenameCPP}_const.C)
+   set(_file_touched ${CMAKE_CURRENT_BINARY_DIR}/${_filenameCPP}_touched.C)
+      
+   file(WRITE ${_file_macros} "// undef the macro when working on this file \n\n\n")
+   file(WRITE ${_file_const} "// const files\n#include \"${_file_macros}\" \n\n\n")
+   file(WRITE ${_file_touched} "// touched files\n#include \"${_file_macros}\"\n\n\n")
+   
    foreach (_current_FILE ${ARGN})
       get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
       # don't include any generated files in the final-file
@@ -149,13 +158,28 @@ macro (KDE4_CREATE_FINAL_FILES _filenameCPP _filesExcludedFromFinalFile )
             list(APPEND ${_filesExcludedFromFinalFile} ${_abs_FILE})
          else (_isCFile)
             file(APPEND ${_filenameCPP} "#include \"${_abs_FILE}\"\n")
+            
+            GET_FILENAME_COMPONENT(_file_name ${_abs_FILE} NAME_WE)
+            STRING(REGEX REPLACE "-" "_" _file_name "${_file_name}" )
+            set(__macro_name ASSUME_CONST_____${_file_name})
+            file(APPEND ${_file_macros} "#define ${__macro_name}\n")
+            
+            file(APPEND ${_file_const}  "#ifdef ${__macro_name}\n")
+            file(APPEND ${_file_const}  "#include \"${_abs_FILE}\"\n")
+            file(APPEND ${_file_const}  "#endif\n\n")
+            
+            file(APPEND ${_file_touched}  "#ifndef ${__macro_name}\n")
+            file(APPEND ${_file_touched}  "#include \"${_abs_FILE}\"\n")
+            file(APPEND ${_file_touched}  "#endif\n\n")
+            
          endif (_isCFile)
       endif (_isGenerated)
    endforeach (_current_FILE)
 
-endmacro (KDE4_CREATE_FINAL_FILES)
+endmacro (LYX_CREATE_FINAL_FILES)
 
 
 macro(lyx_merge_files _filename _list)
-       KDE4_CREATE_FINAL_FILES(${_filename} _nix_nothing ${${_list}})
-endmacro(lyx_merge_files _list _filename)
\ No newline at end of file
+       LYX_CREATE_FINAL_FILES(${_filename} _nix_nothing ${${_list}})
+endmacro(lyx_merge_files _list _filename)
+