Author: sir_richard
Date: Wed Aug 4 06:41:07 2010
New Revision: 48447
URL:
http://svn.reactos.org/svn/reactos?rev=48447&view=rev
Log:
[CMAKE]: Add support for precompiled headers (this was not fun).
[CMAKE]: Use them in RTL and CRT. Someone needs to add them to the other makefiles.
Added:
branches/cmake-bringup/CMakeMacros.cmake
Modified:
branches/cmake-bringup/CMakeLists.txt
branches/cmake-bringup/lib/rtl/CMakeLists.txt
branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt
Modified: branches/cmake-bringup/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/CMakeLists.txt?re…
==============================================================================
--- branches/cmake-bringup/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/CMakeLists.txt [iso-8859-1] Wed Aug 4 06:41:07 2010
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(REACTOS)
+
+include(CMakeMacros.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
@@ -46,7 +48,7 @@
add_definitions(-D_USE_32BIT_TIME_T)
# Compiler Core
-add_definitions(-pipe -fms-extensions -fno-set-stack-executable)
+add_definitions(-pipe -fms-extensions)
# Debugging (Note: DWARF-4 on 4.5.1 when we ship)
add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none
-feliminate-unused-debug-types)
@@ -55,23 +57,23 @@
add_definitions(-march=pentium -mtune=i686)
# Warnings
-add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar
-Wno-error=uninitialized -Wno-unused-value)
+add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar
-Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
# Optimizations
add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer
-mpreferred-stack-boundary=2 -fno-optimize-sibling-calls)
-include_directories(./include)
-include_directories(./include/psdk)
-include_directories(./include/dxsdk)
+include_directories(include)
+include_directories(include/psdk)
+include_directories(include/dxsdk)
include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
include_directories(${REACTOS_BINARY_DIR}/include/psdk)
include_directories(${REACTOS_BINARY_DIR}/include/reactos)
-include_directories(./include/crt)
-include_directories(./include/crt/mingw32)
-include_directories(./include/ddk)
-include_directories(./include/ndk)
-include_directories(./include/reactos)
-include_directories(./include/reactos/libs)
+include_directories(include/crt)
+include_directories(include/crt/mingw32)
+include_directories(include/ddk)
+include_directories(include/ndk)
+include_directories(include/reactos)
+include_directories(include/reactos/libs)
add_subdirectory(include/psdk)
add_subdirectory(include/dxsdk)
Added: branches/cmake-bringup/CMakeMacros.cmake
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/CMakeMacros.cmake…
==============================================================================
--- branches/cmake-bringup/CMakeMacros.cmake (added)
+++ branches/cmake-bringup/CMakeMacros.cmake [iso-8859-1] Wed Aug 4 06:41:07 2010
@@ -1,0 +1,40 @@
+MACRO(_PCH_GET_COMPILE_FLAGS _target_name _out_compile_flags _header_filename)
+
+ # Add the precompiled header to the build
+ SET(_gch_filename "${_header_filename}.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(item)
+
+ # This is a particular bit of undocumented/hacky magic I'm quite proud of
+ GET_DIRECTORY_PROPERTY(_compiler_flags DEFINITIONS)
+ STRING(REPLACE "\ " "\t" _compiler_flags ${_compiler_flags})
+ 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(item)
+ ENDIF()
+
+ENDMACRO(_PCH_GET_COMPILE_FLAGS)
+
+MACRO(add_pch _target_name _header_filename _src_list)
+
+ SET(_gch_filename "${_header_filename}.gch")
+
+ LIST(APPEND ${_src_list} ${_gch_filename})
+
+ _PCH_GET_COMPILE_FLAGS(${_target_name} _args ${_header_filename})
+
+ add_custom_command(OUTPUT ${_gch_filename}
+ COMMAND rm -f ${_gch_filename}
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} ${_args}
+ DEPENDS ${_header_filename})
+ENDMACRO(add_pch _target_name _header_filename _src_list)
Modified: branches/cmake-bringup/lib/rtl/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/rtl/CMakeList…
==============================================================================
--- branches/cmake-bringup/lib/rtl/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/lib/rtl/CMakeLists.txt [iso-8859-1] Wed Aug 4 06:41:07 2010
@@ -11,6 +11,7 @@
${CMAKE_CURRENT_SOURCE_DIR}/mem.c
${CMAKE_CURRENT_SOURCE_DIR}/memgen.c)
-add_library(rtl ${ARCH_SOURCE} ${SOURCE})
+add_library(rtl ${ARCH_SOURCE} ${SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/rtl.h.gch)
+add_pch(rtl ${CMAKE_CURRENT_SOURCE_DIR}/rtl.h ${SOURCE})
add_dependencies(rtl psdk)
Modified: branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/CMake…
==============================================================================
--- branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt [iso-8859-1] (original)
+++ branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt [iso-8859-1] Wed Aug 4 06:41:07
2010
@@ -1,4 +1,3 @@
-
include_directories(./include)
add_definitions(-D_CRTBLD)
@@ -7,8 +6,11 @@
LIST(REMOVE_ITEM CRT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/stdio/findgen.c)
LIST(REMOVE_ITEM CRT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/string/strtold.c)
-add_library(crt ${CRT_SOURCE})
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/precomp.h.gch PROPERTIES
GENERATED ON)
+
+add_library(crt ${CRT_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/precomp.h.gch)
set_property(TARGET crt PROPERTY COMPILE_DEFINITIONS __MINGW_IMPORT=extern
USE_MSVCRT_PREFIX _MSVCRT_LIB_ _MSVCRT_ _MT)
+add_pch(crt ${CMAKE_CURRENT_SOURCE_DIR}/precomp.h ${CRT_SOURCE})
add_dependencies(crt psdk)
if(ARCH MATCHES i386)