瀏覽代碼

- added PCH compilation for CMake using cotire module (PCH is OFF per default, can be enabled with ENABLE_PCH=ON)

beegee1 11 年之前
父節點
當前提交
df0a28d9cb

+ 4 - 0
AI/BattleAI/CMakeLists.txt

@@ -11,6 +11,10 @@ set(battleAI_SRCS
 add_library(BattleAI SHARED ${battleAI_SRCS})
 target_link_libraries(BattleAI vcmi)
 
+if(COMMAND cotire)
+	cotire(BattleAI)
+endif()
+
 if (NOT APPLE) # Already inside vcmiclient bundle
     install(TARGETS BattleAI DESTINATION ${AI_LIB_DIR})
 endif()

+ 4 - 0
AI/StupidAI/CMakeLists.txt

@@ -11,6 +11,10 @@ set(stupidAI_SRCS
 add_library(StupidAI SHARED ${stupidAI_SRCS})
 target_link_libraries(StupidAI vcmi)
 
+if(COMMAND cotire)
+	cotire(StupidAI)
+endif()
+
 if (NOT APPLE) # Already inside vcmiclient bundle
     install(TARGETS StupidAI DESTINATION ${AI_LIB_DIR})
 endif()

+ 4 - 0
AI/VCAI/CMakeLists.txt

@@ -18,6 +18,10 @@ set(VCAI_HEADERS
 add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS})
 target_link_libraries(VCAI FuzzyLite_lib vcmi)
 
+if(COMMAND cotire)
+	cotire(VCAI)
+endif()
+
 if (NOT APPLE) # Already inside vcmiclient bundle
     install(TARGETS VCAI DESTINATION ${AI_LIB_DIR})
 endif()

+ 5 - 0
CMakeLists.txt

@@ -21,6 +21,7 @@ option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_EDITOR "Enable compilation of map editor" OFF)
 option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
 option(ENABLE_TEST "Enable compilation of unit tests" OFF)
+option(ENABLE_PCH "Enable precompiled headers" OFF)
 
 ############################################
 #        Building section                  #
@@ -59,6 +60,10 @@ find_package(SDL_mixer REQUIRED)
 find_package(SDL_ttf REQUIRED)
 find_package(ZLIB REQUIRED)
 
+if(ENABLE_PCH)
+	include(cotire)
+endif()
+
 if (ENABLE_EDITOR OR ENABLE_LAUNCHER)
 	# Widgets finds its own dependencies (QtGui and QtCore).
 	find_package(Qt5Widgets REQUIRED)

+ 1 - 1
Global.h

@@ -90,7 +90,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <boost/version.hpp>
 
 #define BOOST_FILESYSTEM_VERSION 3
-#if ( BOOST_VERSION>105000 )
+#if ( BOOST_VERSION>105000 && !defined(BOOST_THREAD_VERSION))
 #define BOOST_THREAD_VERSION 3
 #endif
 #define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1

+ 6 - 0
client/CMakeLists.txt

@@ -108,5 +108,11 @@ endif()
 
 target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${RT_LIB} ${DL_LIB})
 
+set_property(DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${FFMPEG_INCLUDE_DIRS}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
+
+if(COMMAND cotire)
+	cotire(vcmiclient)
+endif()
+
 install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
 

+ 1 - 0
editor/CMakeLists.txt

@@ -38,6 +38,7 @@ add_executable(vcmieditor ${maped_SRCS} ${maped_FORMS_OUT})
 
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
 target_link_libraries(vcmieditor vcmi ${Qt5Widgets_LIBRARIES})
+cotire(vcmieditor)
 
 if (NOT APPLE) # Already inside bundle
     install(TARGETS vcmieditor DESTINATION ${BIN_DIR})

+ 4 - 0
launcher/CMakeLists.txt

@@ -53,6 +53,10 @@ add_executable(vcmilauncher ${launcher_SRCS} ${launcher_UI_HEADERS})
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
 target_link_libraries(vcmilauncher vcmi ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES})
 
+if(COMMAND cotire)
+	cotire(vcmilauncher)
+endif()
+
 if (NOT APPLE) # Already inside bundle
     install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
 	# copy whole directory but .svn control files

+ 4 - 0
lib/CMakeLists.txt

@@ -106,6 +106,10 @@ add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
 set_target_properties(vcmi PROPERTIES XCODE_ATTRIBUTE_LD_DYLIB_INSTALL_NAME "@executable_path/libvcmi.dylib")
 target_link_libraries(vcmi minizip ${Boost_LIBRARIES} ${SDL_LIBRARY} ${ZLIB_LIBRARIES} ${RT_LIB} ${DL_LIB})
 
+if(COMMAND cotire)
+	cotire(vcmi)
+endif()
+
 if (NOT APPLE) # Already inside vcmiclient bundle
     install(TARGETS vcmi DESTINATION ${LIB_DIR})
 endif()

+ 1 - 0
scripting/erm/CMakeLists.txt

@@ -11,5 +11,6 @@ set(lib_SRCS
 
 add_library(vcmiERM SHARED ${lib_SRCS})
 target_link_libraries(vcmiERM ${Boost_LIBRARIES})
+cotire(vcmiERM)
 
 install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR})

+ 4 - 0
server/CMakeLists.txt

@@ -19,6 +19,10 @@ endif()
 
 target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB})
 
+if(COMMAND cotire)
+	cotire(vcmiserver)
+endif()
+
 if (NOT APPLE) # Already inside vcmiclient bundle
     install(TARGETS vcmiserver DESTINATION ${BIN_DIR})
 endif()

+ 6 - 0
test/CMakeLists.txt

@@ -14,6 +14,12 @@ add_executable(vcmitest ${test_SRCS})
 target_link_libraries(vcmitest vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB})
 add_test(vcmitest vcmitest)
 
+set_property(DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${Boost_INCLUDE_DIRS}/boost/test" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
+
+if(COMMAND cotire)
+	cotire(vcmitest)
+endif()
+
 # Files to copy to the build directory
 add_custom_target(vcmitestFiles ALL)
 set(vcmitest_FILES