Author: akhaldi
Date: Mon Jul 25 19:05:00 2011
New Revision: 52865

URL: http://svn.reactos.org/svn/reactos?rev=52865&view=rev
Log:
[CMAKE]
* Introduce a temporary cmake variable (PCH) to enable/disable cmake pch 
support as this requires our patched binary.
* Wrap pch macros around this variable.
* Implement the pch marco accordingly. By Jerome.

Modified:
    trunk/reactos/cmake/gcc.cmake

Modified: trunk/reactos/cmake/gcc.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/gcc.cmake?rev=52865&r1=52864&r2=52865&view=diff
==============================================================================
--- trunk/reactos/cmake/gcc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/gcc.cmake [iso-8859-1] Mon Jul 25 19:05:00 2011
@@ -285,44 +285,69 @@
 set(PSEH_LIB "pseh")
 
 # Macros
-macro(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
-    # Add the precompiled header to the build
-    get_filename_component(_FILE ${_header_filename} NAME)
-    set(_gch_filename "${_FILE}.gch")
-    list(APPEND ${_out_compile_flags} -c ${_header_filename} -o 
${_gch_filename})
-
-    # This gets us our includes
-    get_directory_property(DIRINC INCLUDE_DIRECTORIES)
-    foreach(item ${DIRINC})
-        list(APPEND ${_out_compile_flags} -I${item})
-    endforeach()
-
-    # This our definitions
-    get_directory_property(_compiler_flags DEFINITIONS)
-    list(APPEND ${_out_compile_flags} ${_compiler_flags})
-
-    # This gets any specific definitions that were added with 
set-target-property
-    get_target_property(_target_defs ${_target_name} COMPILE_DEFINITIONS)
-    if (_target_defs)
-        foreach(item ${_target_defs})
-            list(APPEND ${_out_compile_flags} -D${item})
+if(PCH)
+    macro(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags 
_header_filename)
+        # Add the precompiled header to the build
+        get_filename_component(_FILE ${_header_filename} NAME)
+        set(_gch_filename "${_FILE}.gch")
+        list(APPEND ${_out_compile_flags} -c ${_header_filename} -o 
${_gch_filename})
+
+        # This gets us our includes
+        get_directory_property(DIRINC INCLUDE_DIRECTORIES)
+        foreach(item ${DIRINC})
+            list(APPEND ${_out_compile_flags} -I${item})
         endforeach()
-    endif()
-
-       separate_arguments(${_out_compile_flags})
-endmacro()
-
-macro(add_pch _target_name _FILE)
-       #set(_header_filename ${CMAKE_CURRENT_SOURCE_DIR}/${_FILE})
-       #get_filename_component(_basename ${_FILE} NAME)
-    #set(_gch_filename ${_basename}.gch)
-    #_PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
-
-    #add_custom_command(OUTPUT ${_gch_filename} COMMAND ${CMAKE_C_COMPILER} 
${CMAKE_C_COMPILER_ARG1} ${_args} DEPENDS ${_header_filename})
-       #get_target_property(_src_files ${_target_name} SOURCES)
-       #set_source_files_properties(${_src_files} PROPERTIES COMPILE_FLAGS 
"-Winvalid-pch -fpch-preprocess" #OBJECT_DEPENDS 
${CMAKE_CURRENT_BINARY_DIR}/${_gch_filename})
-       #add_linkerflag(${_target_name} "${_gch_filename}")
-endmacro()
+
+        # This our definitions
+        get_directory_property(_compiler_flags DEFINITIONS)
+        list(APPEND ${_out_compile_flags} ${_compiler_flags})
+
+        # This gets any specific definitions that were added with 
set-target-property
+        get_target_property(_target_defs ${_target_name} COMPILE_DEFINITIONS)
+        if (_target_defs)
+            foreach(item ${_target_defs})
+                list(APPEND ${_out_compile_flags} -D${item})
+            endforeach()
+        endif()
+
+        if(IS_CPP)
+            list(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
+        else()
+            list(APPEND ${_out_compile_flags} ${CMAKE_C_FLAGS})
+        endif()
+
+        separate_arguments(${_out_compile_flags})
+    endmacro()
+
+    macro(add_pch _target_name _FILE)
+        set(_header_filename ${CMAKE_CURRENT_SOURCE_DIR}/${_FILE})
+        get_filename_component(_basename ${_FILE} NAME)
+        set(_gch_filename ${_basename}.gch)
+        _PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
+
+        if(IS_CPP)
+            set(__lang CXX)
+            set(__compiler ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1})
+        else()
+            set(__lang C)
+            set(__compiler ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
+        endif()
+
+        add_custom_command(OUTPUT ${_gch_filename} COMMAND ${__compiler} 
${_args} IMPLICIT_DEPENDS ${__lang} ${_header_filename})
+        get_target_property(_src_files ${_target_name} SOURCES)
+        foreach(_item in ${_src_files})
+            get_source_file_property(__src_lang ${_item} LANGUAGE)
+            if(__src_lang STREQUAL __lang)
+                set_source_files_properties(${_item} PROPERTIES COMPILE_FLAGS 
"-fpch-preprocess" OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_gch_filename})
+            endif()
+        endforeach()
+        #set dependency checking : depends on precompiled header only whixh 
already depends on deeper header
+        set_target_properties(${_target_name} PROPERTIES 
IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "\"${_basename}\"=;<${_basename}>=")
+    endmacro()
+else()
+    macro(add_pch _target_name _FILE)
+    endmacro()
+endif()
 
 macro(CreateBootSectorTarget _target_name _asm_file _object_file _base_address)
     get_filename_component(OBJECT_PATH ${_object_file} PATH)


Reply via email to