Add PCH support using cotire CMake module

master
ANAND 2019-10-28 18:46:36 +05:30
parent 3ed7570894
commit a0ead8b467
No known key found for this signature in database
GPG Key ID: 3AD8A3C4A51AAB97
5 changed files with 56 additions and 6 deletions

5
.gitignore vendored
View File

@ -10,6 +10,7 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
*.cmake*
# Output files
bin/
# Application executable
bin/Magnetar

View File

@ -2,11 +2,16 @@ cmake_minimum_required(VERSION 2.8)
project(Magnetar)
set(CMAKE_CXX_STANDARD 11)
# GLFW build flags
# Directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
include(cotire)
# GLFW
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(libs/glfw-3.3)
find_package(OpenGL REQUIRED)
@ -42,3 +47,7 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME} ${OPENGL_gl_LIBRARY} glfw)
# PCH
set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/magnetar_pch.h")
cotire(${PROJECT_NAME})

View File

@ -164,3 +164,28 @@ 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.
7. cotire (CMake/cotire.cmake)
Copyright (c) 2012-2018 Sascha Kratky
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.

View File

@ -1,7 +1,6 @@
// Master include file, to include all Magnetar files
// Master include file, to be used by clients
#include "magnetar/application.h"
#include "magnetar/entry_point.h"
// Miscellaneous headers
#include "magnetar/log.h"

16
src/magnetar_pch.h Normal file
View File

@ -0,0 +1,16 @@
// Single pre-compiled header for use by Magnetar
#include <iostream>
#include <fstream>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <unordered_set>