Init
This commit is contained in:
85
CMakeLists.txt
Normal file
85
CMakeLists.txt
Normal file
@@ -0,0 +1,85 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
project("spacegame"
|
||||
VERSION 0.2.2
|
||||
DESCRIPTION "Blocky spacegame by crydsch@lph.zone"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O0 -ggdb")
|
||||
|
||||
# Enable compiler warnings
|
||||
set(SPACEGAME_COMPILER_WARNINGS
|
||||
-Wall -Wextra -pedantic
|
||||
-Wcast-align -Wcast-qual -Wformat=2 -Winit-self -Wmissing-declarations
|
||||
-Wmissing-include-dirs -Wredundant-decls -Wswitch-default
|
||||
-Wundef -Wctor-dtor-privacy
|
||||
)
|
||||
|
||||
# Enable compile_commands.json generation for other tools
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
|
||||
if(NOT EXISTS /spacegame_deps)
|
||||
message(FATAL_ERROR "'/spacegame_deps' not found!\nYou need to build the required dependecies first.\nSee 'scripts/build_deps.sh'")
|
||||
else()
|
||||
# Search for our pre-built dependencies first
|
||||
set(CMAKE_PREFIX_PATH /spacegame_deps)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Note: shaderc must be run on the host system
|
||||
option(SPACEGAME_BUILD_SHADERS "Use shaderc to build spirv shaders" OFF)
|
||||
|
||||
|
||||
################ dependencies ################
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(glfw3 REQUIRED)
|
||||
|
||||
# This finds import libraries: bgfx::bgfx, bgfx::bx and bgfx::bimg
|
||||
# Linking with these will bring: include dirs, compiler options, compiler defs, link libraries
|
||||
find_package(bgfx REQUIRED)
|
||||
# bgfx::bgfx wrongly links with: OpenGL,GLX and others
|
||||
# So we link to libbgfx.a only
|
||||
find_library(BGFX NAMES libbgfx.a REQUIRED)
|
||||
|
||||
if(SPACEGAME_BUILD_SHADERS)
|
||||
find_program(SHADERC shaderc REQUIRED)
|
||||
endif()
|
||||
|
||||
################## sources ###################
|
||||
|
||||
if(SPACEGAME_BUILD_SHADERS)
|
||||
add_subdirectory(shaders)
|
||||
endif()
|
||||
|
||||
# Game executable is here:
|
||||
add_subdirectory(src)
|
||||
|
||||
################# debugging ##################
|
||||
|
||||
# A useful trick is to append "-LAH" to the cmake command
|
||||
# of libraries to see their available options.
|
||||
#
|
||||
# Uncomment this section to have cmake print all variables.
|
||||
# This is useful to find the actual variable names of the libraries in use.
|
||||
# Such as, is it ${SMTH_INCLUDE_DIR} or ${SMTH_INCLUDE_DIRS}?
|
||||
# get_cmake_property(_variableNames VARIABLES)
|
||||
# list (SORT _variableNames)
|
||||
# foreach (_variableName ${_variableNames})
|
||||
# message(STATUS "${_variableName}=${${_variableName}}")
|
||||
# endforeach()
|
||||
#
|
||||
# List imported targets from 'find_package(..)'
|
||||
# get_property(importTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
|
||||
# message("Import Targets: ${importTargets}")
|
||||
#
|
||||
# Build this target to test generator expressions
|
||||
# add_custom_target(debug_gen_expr COMMAND ${CMAKE_COMMAND} -E echo "$<IF:$<BOOL:${SPACEGAME_BUILD_SHADERS}>,true_string,false_string>")
|
||||
Reference in New Issue
Block a user