Basic precompiled header support for Linux/OS X. Shaves 20-30% off full rebuild time on my system.

This commit is contained in:
comex 2013-10-17 00:06:34 -04:00
parent cffe6ba3fd
commit de1773affb
11 changed files with 112 additions and 15 deletions

View File

@ -11,6 +11,7 @@ option(USE_GLES "Enables GLES2 And EGL, disables OGL" OFF)
option(USE_GLES3 "Enables GLES3 and EGL" OFF)
option(USE_UPNP "Enables UPnP port mapping support" ON)
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
option(ENABLE_PCH "Use PCH to speed up compilation" OFF)
option(FASTLOG "Enable all logs" OFF)
option(OPROFILING "Enable profiling" OFF)
@ -817,3 +818,4 @@ list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}")
# CPack must be included after the CPACK_* variables are set in order for those
# variables to take effect.
Include(CPack)

View File

@ -1,3 +1,47 @@
set(CMAKE_FAKELANG_CREATE_STATIC_LIBRARY "touch <TARGET>")
if(ENABLE_PCH)
# This is actually a .h file, but trick cmake into compiling it as a source file
set(pch_out_filename "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/pch.dir/pch.h")
set(pch_lib_filename "${CMAKE_CURRENT_BINARY_DIR}/libpch.a")
set(pch_src_filename "${CMAKE_CURRENT_SOURCE_DIR}/pch.h")
if(APPLE)
set(type objective-c++-header)
else()
set(type c++-header)
endif()
set_source_files_properties(
pch.h PROPERTIES
COMPILE_FLAGS "-x ${type}"
HEADER_FILE_ONLY 0
LANGUAGE CXX)
add_library(pch STATIC pch.h)
add_custom_command(
TARGET pch
PRE_LINK
COMMAND ln -fs "${pch_out_filename}.o" "${pch_out_filename}.gch"
COMMAND ln -fs "${pch_out_filename}.o" "${pch_out_filename}.pch"
COMMAND cp "${pch_src_filename}" "${pch_out_filename}")
set_target_properties(
pch PROPERTIES
LINKER_LANGUAGE FAKELANG)
endif(ENABLE_PCH)
macro(add_dolphin_library lib srcs libs)
add_library(${lib} STATIC ${srcs})
target_link_libraries(${lib} ${libs})
if(ENABLE_PCH)
add_dependencies(${lib} pch)
set_source_files_properties(
${srcs} PROPERTIES
COMPILE_FLAGS "-include ${pch_out_filename}"
OBJECT_DEPENDS "${pch_lib_filename}")
endif(ENABLE_PCH)
endmacro(add_dolphin_library)
add_subdirectory(Core)
if (DSPTOOL)
@ -8,4 +52,7 @@ if (UNITTESTS)
add_subdirectory(UnitTests)
endif()
# TODO: Add DSPSpy and TestSuite. Preferrably make them option()s and cpack components

View File

@ -40,5 +40,4 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SRCS ${SRCS} Src/CoreAudioSoundStream.cpp)
endif()
add_library(audiocommon STATIC ${SRCS})
target_link_libraries(audiocommon ${LIBS})
add_dolphin_library(audiocommon "${SRCS}" "${LIBS}")

View File

@ -51,5 +51,4 @@ endif(WIN32)
enable_precompiled_headers(Src/stdafx.h Src/stdafx.cpp SRCS)
add_library(common STATIC ${SRCS})
target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT})
add_dolphin_library(common "${SRCS}" "${CMAKE_THREAD_LIBS_INIT}")

View File

@ -269,5 +269,4 @@ if(GDBSTUB)
set(SRCS ${SRCS} Src/PowerPC/GDBStub.cpp)
endif(GDBSTUB)
add_library(core STATIC ${SRCS})
target_link_libraries(core ${LIBS})
add_dolphin_library(core "${SRCS}" "${LIBS}")

View File

@ -21,5 +21,4 @@ set(SRCS Src/BannerLoader.cpp
Src/VolumeWiiCrypted.cpp
Src/WiiWad.cpp)
add_library(discio STATIC ${SRCS})
target_link_libraries(discio common)
add_dolphin_library(discio "${SRCS}" "")

View File

@ -32,4 +32,4 @@ elseif(ANDROID)
Src/ControllerInterface/Android/Android.cpp)
endif()
add_library(inputcommon ${SRCS})
add_dolphin_library(inputcommon "${SRCS}" "")

View File

@ -45,5 +45,4 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
set(LIBS ${LIBS} usbhid)
endif()
add_library(videoogl STATIC ${SRCS})
target_link_libraries(videoogl ${LIBS})
add_dolphin_library(videoogl "${SRCS}" "${LIBS}")

View File

@ -49,5 +49,4 @@ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
set(LIBS ${LIBS} clrun)
endif()
add_library(videosoftware STATIC ${SRCS})
target_link_libraries(videosoftware ${LIBS})
add_dolphin_library(videosoftware "${SRCS}" "${LIBS}")

View File

@ -61,8 +61,7 @@ if(LIBAV_FOUND OR WIN32)
set(SRCS ${SRCS} Src/AVIDump.cpp)
endif()
add_library(videocommon STATIC ${SRCS})
target_link_libraries(videocommon ${LIBS})
add_dolphin_library(videocommon "${SRCS}" "${LIBS}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(LIBAV_FOUND)

55
Source/pch.h Normal file
View File

@ -0,0 +1,55 @@
#include "Common.h"
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <deque>
#include <errno.h>
#include <execinfo.h>
#include <fcntl.h>
#include <float.h>
#include <fstream>
#include <functional>
#include <getopt.h>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <limits>
#include <list>
#include <locale.h>
#include <map>
#include <math.h>
#include <memory.h>
#include <memory>
#include <mutex>
#include <numeric>
#include <pthread.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <thread>
#include <time.h>
#include <type_traits>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>