Commits

Michaël Broutin  committed 78c1e1a

Added precompiled headers for Visual Studio (only for Ogitor project, at the moment)

  • Participants
  • Parent commits 2ccd92c

Comments (0)

Files changed (11)

File CMakeModules/PrecompiledHeader.cmake

+#-------------------------------------------------------------------
+# This file is part of the CMake build system for OGRE
+#     (Object-oriented Graphics Rendering Engine)
+# For the latest info, see http://www.ogre3d.org/
+#
+# The contents of this file are placed in the public domain. Feel
+# free to make use of it in any way you like.
+#-------------------------------------------------------------------
+
+##################################################################
+# Support macro to use a precompiled header
+# Usage:
+#   use_precompiled_header(TARGET HEADER_FILE SRC_FILE)
+##################################################################
+
+macro(use_precompiled_header TARGET HEADER_FILE SRC_FILE)
+  get_filename_component(HEADER ${HEADER_FILE} NAME)
+
+  # Use MSVC_IDE to exclude NMake from using PCHs
+  if (MSVC AND NOT NMAKE AND NOT OGRE_UNITY_BUILD)
+	add_definitions(/Yu"${HEADER}")
+    set_source_files_properties(${SRC_FILE}
+      PPROPERTIES COMPILE_FLAGS /Yc"${HEADER}"
+	)
+    
+  elseif (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+    # disabled because it seems to increase compile time
+    ## this is some serious hack... we definitely need native 
+    ## support in CMake for this!
+    ## we will generate the precompiled header via a workaround
+    ## first give the header a new name with the proper extension
+    #set(PRECOMP_HEADER ${CMAKE_CURRENT_BINARY_DIR}/hacked/${HEADER}.gch)
+    #configure_file(${HEADER_FILE} ${PRECOMP_HEADER} COPYONLY)
+    ## retrieve some info about the target's build settings
+    #get_target_property(${TARGET} PRECOMP_TYPE TYPE)
+    #if (PRECOMP_TYPE STREQUAL "SHARED_LIBRARY")
+    #  set(PRECOMP_LIBTYPE "SHARED")
+    #else ()
+    #  set(PRECOMP_LIBTYPE "STATIC")
+    #endif ()
+    #get_target_property(${TARGET} PRECOMP_DEFINITIONS COMPILE_DEFINITIONS)
+    #get_target_property(${TARGET} PRECOMP_FLAGS COMPILE_FLAGS)
+    #
+    ## add a new target which compiles the header
+    #add_library(__precomp_header ${PRECOMP_LIBTYPE} ${PRECOMP_HEADER})
+    #add_dependencies(${TARGET} __precomp_header)
+    #set_target_properties(__precomp_header PROPERTIES
+    #  COMPILE_DEFINITIONS ${PRECOMP_DEFINITIONS}
+    #  COMPILE_FLAGS ${PRECOMP_FLAGS}
+    #  HAS_CXX TRUE
+    #)
+    #set_source_files_properties(${PRECOMP_HEADER} PROPERTIES
+    #  HEADER_FILE_ONLY FALSE
+    #  KEEP_EXTENSION TRUE
+    #  COMPILE_FLAGS "-x c++-header"
+    #  LANGUAGE CXX
+    #)
+    #
+    ## finally, we need to ensure that gcc can find the precompiled header
+    ## this is another dirty hack
+    #include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/__precomp_header.dir/hacked")
+
+  endif ()
+endmacro(use_precompiled_header)

File CMakeModules/Templates/OgitorsGlobals.cpp.in

+#include "OgitorsPrerequisites.h"
 #include "OgitorsGlobals.h"
 
 // THIS FILE IS GENERATED BY CMAKE - DO NOT CHANGE IT - CHANGE THE MAIN CMAKE SCRIPT INSTEAD :)

File Ogitor/CMakeLists.txt

 include_directories(${DEPENDENCIES_INCLUDES})
 include_directories(include)
 
+include(PrecompiledHeader)
+
 set(Ogitor_hdrs
 	./include/AxisGizmo.h
 	./include/BaseEditor.h
 	./src/OgitorsUtils.cpp
 	./src/OgitorsPaging.cpp
 	./src/OgitorsPagedWorldSection.cpp
+	./src/PrecompiledHeaders.cpp
 	./src/TerrainGroupEditor.cpp
 	./src/TerrainGroupEditorEditing.cpp
 	./src/TerrainGroupEditorUpdate.cpp
 	./src/tinyxml.cpp
 	./src/tinyxmlerror.cpp
 	./src/tinyxmlparser.cpp
-	${OGITOR_WORK_DIR}/Ogitor/src/OgitorsGlobals.cpp
+	${OGITOR_WORK_DIR}/Ogitor/src/OgitorsGlobals.cpp	
 )
 
 add_library(Ogitor SHARED ${Ogitor_hdrs} ${Ogitor_srcs})
 message(STATUS ${OGRE_LIBRARY})
 target_link_libraries(Ogitor ${OGRE_LIBRARY} ${OGRE_Terrain_LIBRARY} ${OGRE_Paging_LIBRARY} PagedGeometry OFS ${Boost_LIBRARIES})
 
+# specify a precompiled header to use
+#use_precompiled_header(Ogitor 
+#  "${CMAKE_CURRENT_SOURCE_DIR}/include/OgitorsPrerequisites.h"
+#  "${CMAKE_CURRENT_SOURCE_DIR}/src/PrecompiledHeaders.cpp"
+#)
+
 if(APPLE)
         find_package(Cocoa REQUIRED)
 	message(STATUS ${Cocoa_LIBRARIES})

File Ogitor/src/OBBoxRenderable.cpp

 // This Class is taken from OGRE Wiki
-
+#include "OgitorsPrerequisites.h"
 #include "Ogre.h"
 #include "OBBoxRenderable.h"
 

File Ogitor/src/OgitorsClipboardManager.cpp

 /// THE SOFTWARE.
 ////////////////////////////////////////////////////////////////////////////////*/
 
+#include "OgitorsPrerequisites.h"
 #include "tinyxml.h"
-#include "OgitorsPrerequisites.h"
 #include "OgitorsClipboardManager.h"
 #include "OgitorsRoot.h"
 #include "OgitorsSystem.h"

File Ogitor/src/PrecompiledHeaders.cpp

+/*/////////////////////////////////////////////////////////////////////////////////
+/// An
+///    ___   ____ ___ _____ ___  ____
+///   / _ \ / ___|_ _|_   _/ _ \|  _ \
+///  | | | | |  _ | |  | || | | | |_) |
+///  | |_| | |_| || |  | || |_| |  _ <
+///   \___/ \____|___| |_| \___/|_| \_\
+///                              File
+///
+/// Copyright (c) 2008-2012 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
+//
+/// The MIT License
+///
+/// Permission is hereby granted, free of charge, to any person obtaining a copy
+/// of this software and associated documentation files (the "Software"), to deal
+/// in the Software without restriction, including without limitation the rights
+/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+/// copies of the Software, and to permit persons to whom the Software is
+/// furnished to do so, subject to the following conditions:
+///
+/// The above copyright notice and this permission notice shall be included in
+/// all copies or substantial portions of the Software.
+///
+/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+/// THE SOFTWARE.
+////////////////////////////////////////////////////////////////////////////////*/
+
+#include "OgitorsPrerequisites.h"

File Ogitor/src/Selection2D.cpp

 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 /// THE SOFTWARE.
 ////////////////////////////////////////////////////////////////////////////////*/
-
+#include "OgitorsPrerequisites.h"
 #include "OgreStableHeaders.h"
 #include "Selection2D.h"
 

File Ogitor/src/tinystr.cpp

 /*
  * THIS FILE WAS ALTERED BY Tyge L�vset, 7. April 2005.
  */
-
+#include "OgitorsPrerequisites.h"
 
 #ifndef TIXML_USE_STL
 

File Ogitor/src/tinyxml.cpp

 3. This notice may not be removed or altered from any source
 distribution.
 */
+#include "OgitorsPrerequisites.h"
 
 #include <ctype.h>
 

File Ogitor/src/tinyxmlerror.cpp

 3. This notice may not be removed or altered from any source
 distribution.
 */
+#include "OgitorsPrerequisites.h"
 
 #include "tinyxml.h"
 

File Ogitor/src/tinyxmlparser.cpp

 3. This notice may not be removed or altered from any source 
 distribution.
 */
+#include "OgitorsPrerequisites.h"
 
 #include <ctype.h>
 #include <stddef.h>