浏览代码

Add new build option to support non-PCH build.
In order to achieve this, the Precompiled.h is now included back in all the Urho3D implementation source file. So, when the Precompiled.h is not being force-included in the PCH build, then the compiler is still able to find all the required symbol declarations. By doing so, it should also fix the indexer in some IDEs to index all the Urho3D declared symbols correctly whether it is a PCH build or not.

Yao Wei Tjong 姚伟忠 10 年之前
父节点
当前提交
f0d107d3db
共有 4 个文件被更改,包括 13 次插入6 次删除
  1. 7 3
      CMake/Modules/Urho3D-CMake-common.cmake
  2. 1 0
      Docs/GettingStarted.dox
  3. 1 1
      Docs/Reference.dox
  4. 4 2
      Source/ThirdParty/Assimp/CMakeLists.txt

+ 7 - 3
CMake/Modules/Urho3D-CMake-common.cmake

@@ -106,6 +106,7 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
     cmake_dependent_option (URHO3D_EXTRAS "Build extras (native and RPI only)" FALSE "NOT IOS AND NOT ANDROID AND NOT EMSCRIPTEN" FALSE)
     option (URHO3D_DOCS "Generate documentation as part of normal build")
     option (URHO3D_DOCS_QUIET "Generate documentation as part of normal build, suppress generation process from sending anything to stdout")
+    option (URHO3D_PCH "Enable PCH support" TRUE)
     cmake_dependent_option (URHO3D_MINIDUMPS "Enable minidumps on crash (VS only)" TRUE "MSVC" FALSE)
     option (URHO3D_FILEWATCHER "Enable filewatcher support" TRUE)
     if (CPACK_SYSTEM_NAME STREQUAL Linux)
@@ -665,9 +666,12 @@ macro (enable_pch HEADER_PATHNAME)
                 # Determine the dependency list
                 execute_process (COMMAND ${CMAKE_CXX_COMPILER} @${CMAKE_CURRENT_BINARY_DIR}/${HEADER_FILENAME}.${CONFIG}.pch.rsp -MTdeps -MM -o ${CMAKE_CURRENT_BINARY_DIR}/${HEADER_FILENAME}.${CONFIG}.pch.deps ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER_PATHNAME} RESULT_VARIABLE CXX_COMPILER_EXIT_CODE)
                 if (NOT CXX_COMPILER_EXIT_CODE EQUAL 0)
-                    message (FATAL_ERROR "The configured compiler toolchain in the build tree is not able to handle all the compiler flags required to build the project. "
-                        "Please kindly update your compiler toolchain to its latest version. If you are using MinGW then make sure it is MinGW-W64 instead of MinGW-W32 or TDM-GCC (Code::Blocks default). "
-                        "However, if you think there is something wrong with the compiler flags being used then please file a bug report to the project devs.")
+                    message (FATAL_ERROR
+                        "The configured compiler toolchain in the build tree is not able to handle all the compiler flags required to build the project with PCH enabled. "
+                        "Please kindly update your compiler toolchain to its latest version. "
+                        "If you are using MinGW then make sure it is MinGW-W64 instead of MinGW-W32 or TDM-GCC (Code::Blocks default). "
+                        "Or disable the PCH build support by passing the '-DURHO3D_PCH=0' when retrying to configure/generate the build tree. "
+                        "However, if you think there is something wrong with our build system then kindly file a bug report to the project devs.")
                 endif ()
                 file (STRINGS ${CMAKE_CURRENT_BINARY_DIR}/${HEADER_FILENAME}.${CONFIG}.pch.deps DEPS)
                 string (REGEX REPLACE "^deps: *| *\\; +" ";" DEPS ${DEPS})

+ 1 - 0
Docs/GettingStarted.dox

@@ -87,6 +87,7 @@ A number of build options can be defined when invoking the build scripts or when
 |URHO3D_EXTRAS        |0|Build extras (native and RPI only)|
 |URHO3D_DOCS          |0|Generate documentation as part of normal build (the 'doc' builtin target can be used to generate documentation regardless of this option's value)|
 |URHO3D_DOCS_QUIET    |0|Generate documentation as part of normal build, suppress generation process from sending anything to stdout|
+|URHO3D_PCH           |1|Enable PCH support|
 |URHO3D_SSE           |1|Enable SSE instruction set|
 |URHO3D_MINIDUMPS     |1|Enable minidumps on crash (VS only)|
 |URHO3D_FILEWATCHER   |1|Enable filewatcher support|

+ 1 - 1
Docs/Reference.dox

@@ -2862,7 +2862,7 @@ byte[]     Bytecode, produced by AngelScript serializer
 
 - Indent style is Allman (BSD) -like, ie. brace on the next line from a control statement, indented on the same level. In switch-case statements the cases are on the same indent level as the switch statement.
 
-- Indents use 4 spaces instead of tabs.
+- Indents use 4 spaces instead of tabs. Indents on empty lines should not be kept.
 
 - Class and struct names are in camelcase beginning with an uppercase letter. They should be nouns. For example DebugRenderer, FreeTypeLibrary, Graphics.
 

+ 4 - 2
Source/ThirdParty/Assimp/CMakeLists.txt

@@ -719,7 +719,9 @@ SET( CONTRIB_FILES
 set (TARGET_NAME Assimp)
 list (APPEND SOURCE_FILES ${CONTRIB_FILES} ${PUBLIC_HEADERS} ${COMPILER_HEADERS})
 
-set_source_files_properties (contrib/clipper/clipper.cpp contrib/irrXML/irrXML.cpp PROPERTIES NO_PCH TRUE)
-enable_pch (code/AssimpPCH.h)
+if (URHO3D_PCH)
+    set_source_files_properties (contrib/clipper/clipper.cpp contrib/irrXML/irrXML.cpp PROPERTIES NO_PCH TRUE)
+    enable_pch (code/AssimpPCH.h)
+endif ()
 
 setup_library ()