Skip to content

Commit

Permalink
Add precompiled header support
Browse files Browse the repository at this point in the history
  • Loading branch information
Desour committed Mar 25, 2023
1 parent 15ed7b8 commit 8812b79
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ For Fedora users:
sudo dnf install git

For Arch users:

sudo pacman -S git

For Alpine users:
Expand Down Expand Up @@ -253,6 +253,8 @@ General options and their default values:
SemiDebug - Partially optimized debug build
RelWithDebInfo - Release build with debug information
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
PRECOMPILE_HEADERS=FALSE - Precompile some headers (experimental)
PRECOMPILED_HEADERS_PATH= - Path to a file listing all headers to precompile (default points to src/precompiled_headers.txt)
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
Expand Down
24 changes: 24 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ if(NOT (BUILD_CLIENT OR BUILD_SERVER))
endif()


option(PRECOMPILE_HEADERS "Precompile some headers (experimental)" FALSE)
set(PRECOMPILED_HEADERS_PATH "" CACHE FILEPATH "Path to a file listing all headers to precompile")

if(PRECOMPILE_HEADERS)
if(PRECOMPILED_HEADERS_PATH)
set(PRECOMPILED_HEADERS ${PRECOMPILED_HEADERS_PATH})
else()
set(PRECOMPILED_HEADERS "${CMAKE_SOURCE_DIR}/src/precompiled_headers.txt")
endif()
message(STATUS "Reading headers to precompile from: ${PRECOMPILED_HEADERS}")
# ignore lines that begin with # and empty lines
file(STRINGS ${PRECOMPILED_HEADERS} PRECOMPILED_HEADERS_LIST REGEX "^[^#].*$")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PRECOMPILED_HEADERS})
endif()


option(ENABLE_CURL "Enable cURL support for fetching media" TRUE)
set(USE_CURL FALSE)

Expand Down Expand Up @@ -594,6 +610,10 @@ if(BUILD_CLIENT)
if(BUILD_BENCHMARKS)
target_link_libraries(${PROJECT_NAME} catch2)
endif()

if(PRECOMPILE_HEADERS)
target_precompile_headers(${PROJECT_NAME} PRIVATE ${PRECOMPILED_HEADERS_LIST})
endif()
endif(BUILD_CLIENT)


Expand Down Expand Up @@ -657,6 +677,10 @@ if(BUILD_SERVER)
if(BUILD_BENCHMARKS)
target_link_libraries(${PROJECT_NAME}server catch2)
endif()

if(PRECOMPILE_HEADERS)
target_precompile_headers(${PROJECT_NAME}server PRIVATE ${PRECOMPILED_HEADERS_LIST})
endif()
endif(BUILD_SERVER)

# Blacklisted locales that don't work.
Expand Down
95 changes: 95 additions & 0 deletions src/precompiled_headers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

# stdlib
# ------

# C stuff:
<cassert>
<cctype>
<cerrno>
<cfenv>
<cfloat>
<cinttypes>
<ciso646>
<climits>
<clocale>
<cmath>
<csetjmp>
<csignal>
<cstdarg>
<cstdbool>
<cstddef>
<cstdint>
<cstdio>
<cstdlib>
<cstring>
<ctgmath>
<ctime>
<cuchar>
<cwchar>
<cwctype>

# Containers:
<array>
<deque>
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
<unordered_map>
<unordered_set>
<vector>

# Input/Output:
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>

# Multi-threading:
<atomic>
<condition_variable>
<future>
<mutex>
<thread>

# Other:
<algorithm>
<bitset>
<chrono>
<codecvt>
<complex>
<exception>
<functional>
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<new>
<numeric>
<random>
<ratio>
<regex>
<stdexcept>
<string>
<system_error>
<tuple>
<typeindex>
<typeinfo>
<type_traits>
<utility>
<valarray>


# libs
# ----

# jsoncpp
<json/json.h>

0 comments on commit 8812b79

Please sign in to comment.