Inferno Game Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.3 KiB

5 years ago
# User config between these lines
# ------------------------------------------
# Set engine name
set(ENGINE "inferno")
5 years ago
# Set project name
set(GAME "game")
# Set debugging, ON/OFF
set(DEBUG "ON")
# ------------------------------------------
# Add 'make run' target
add_custom_target(run
COMMAND ${GAME}
)
5 years ago
# ------------------------------------------
cmake_minimum_required(VERSION 3.16)
5 years ago
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5 years ago
# Check if the build should include debugging symbols
option(DEBUG "" ${DEBUG})
5 years ago
if(DEBUG)
# cmake -DDEBUG=on .. && make
message("--- Debug ---")
set(CMAKE_BUILD_TYPE "Debug")
# -Og = Optimizations that do not interfere with debugging
# -Wall = All warnings about contructions that are easily avoidable
# -Wextra = Extra warning flags not covered by -Wall
5 years ago
# -g = Produce debugging information in OS's native format
5 years ago
# -pg = Generate profile information for analysis with gprof
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -Wall -Wextra -g -pg")
5 years ago
# gprof <GAME> gmon.out > profile-data.txt
else()
# cmake -DDEBUG=off .. && make
message("--- Release ---")
set(CMAKE_BUILD_TYPE "Release")
# -O3 = Optimizations that increases compilation time and performance
5 years ago
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
endif()
# Include all headers
include_directories(
"${ENGINE}/vendor/freetype/include"
5 years ago
"${ENGINE}/vendor/glad/include"
"${ENGINE}/vendor/glfw/include"
"${ENGINE}/vendor/glm"
"${ENGINE}/vendor/json/include"
"${ENGINE}/vendor/stb"
"${ENGINE}/src"
5 years ago
)
# Define engine source files
5 years ago
file(GLOB_RECURSE GLAD "${ENGINE}/vendor/glad/*.c")
file(GLOB_RECURSE ENGINE_SOURCES "${ENGINE}/src/${ENGINE}/*.cpp")
set(ENGINE_SOURCES ${GLAD} ${ENGINE_SOURCES})
# Define game source files
5 years ago
file(GLOB_RECURSE GAME_SOURCES "${GAME}/src/*.cpp")
set(GAME_SOURCES ${GAME_SOURCES})
5 years ago
# ------------------------------------------
project(${ENGINE})
set(CMAKE_CXX_STANDARD 17)
5 years ago
# 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 GLFW target to project
add_subdirectory(${ENGINE}/vendor/glfw)
5 years ago
# Add FreeType2 target to project
add_subdirectory(${ENGINE}/vendor/freetype)
add_library(${ENGINE} STATIC ${ENGINE_SOURCES})
target_link_libraries(${ENGINE} glfw freetype)
5 years ago
# ------------------------------------------
project(${GAME})
set(CMAKE_CXX_STANDARD 17)
5 years ago
add_executable(${GAME} ${GAME_SOURCES})
5 years ago
target_link_libraries(${GAME} ${ENGINE})
# ------------------------------------------
target_precompile_headers(${ENGINE} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:<algorithm$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<array$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<csignal$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<cstddef$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<cstdint$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<functional$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<iostream$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<memory$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<ostream$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<sstream$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<string$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<string_view$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<unordered_map$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<utility$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<vector$<ANGLE-R>>"
)
target_precompile_headers(${GAME} REUSE_FROM ${ENGINE})