Squash improve-ide-compat into main

Fixes GH-5

- cppcheck replaced with clang-tidy
- clang-tidy lint warnings fixed
- Reworked build tools from scratch to make IDE setup easier
- Added 1.5 IDE setup guides
This commit is contained in:
2023-11-10 21:30:55 +01:00
parent 189d19fd4a
commit ae4e265a90
66 changed files with 2017 additions and 1498 deletions
+91 -24
View File
@@ -1,11 +1,37 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.12)
project(progressia)
set(VERSION "0.0.1")
add_executable(progressia)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
include(embed)
# Options
add_executable(progressia
option(DEV_MODE "Enable additional functionality required for development.")
string(CONCAT BUILD_ID_expl
"Build ID or \"dev\".\n"
"Set to a unique identifying string if you intend to publish your builds.")
set(BUILD_ID "dev" CACHE STRING "${BUILD_ID_expl}")
string(CONCAT VULKAN_ERROR_CHECKING_expl
"Enable Vulkan validation layers to detect Vulkan API usage errors "
"at runtime.\n"
"Requires Vulkan SDK. This will lead to decreased performance.")
option(VULKAN_ERROR_CHECKING "${VULKAN_ERROR_CHECKING_expl}")
# Tools
set(tools ${PROJECT_SOURCE_DIR}/tools)
set(generated ${PROJECT_BINARY_DIR}/generated)
file(MAKE_DIRECTORY "${generated}")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/")
include(embed/embed)
include(glslc)
include(dev-mode)
# Source files
target_sources(progressia PRIVATE
desktop/main.cpp
desktop/graphics/glfw_mgmt.cpp
desktop/graphics/vulkan_common.cpp
@@ -19,6 +45,7 @@ add_executable(progressia
desktop/graphics/vulkan_texture_descriptors.cpp
desktop/graphics/vulkan_adapter.cpp
desktop/graphics/vulkan_swap_chain.cpp
desktop/graphics/vulkan_physical_device.cpp
main/game.cpp
main/logging.cpp
@@ -26,34 +53,78 @@ add_executable(progressia
main/rendering/image.cpp
main/stb_image.c
${generated}/embedded_resources.cpp
${generated}/embedded_resources/embedded_resources.cpp
)
target_include_directories(progressia PRIVATE ${generated})
# Embedded resources
target_glsl_shaders(progressia
desktop/graphics/shaders/shader.frag
desktop/graphics/shaders/shader.vert)
# Do Windows-specific tweaks
if (WIN32)
set_target_properties(progressia PROPERTIES WIN32_EXECUTABLE true)
target_link_options(progressia PRIVATE -static-libstdc++ -static-libgcc)
endif()
target_embeds(progressia
assets/texture.png
assets/texture2.png)
compile_glsl(progressia)
compile_embeds(progressia)
target_include_directories(progressia PRIVATE ${generated}/embedded_resources)
# Compilation settings
set_property(TARGET progressia PROPERTY CXX_STANDARD 17)
target_compile_options(progressia PRIVATE -Wall -Wextra -Wpedantic -Werror)
# Version information
if (NOT DEFINED BUILD_ID)
set(BUILD_ID "dev")
set_property(TARGET progressia PROPERTY CXX_STANDARD 17)
set_property(TARGET progressia PROPERTY CXX_STANDARD_REQUIRED ON)
# Determine command line style
if (DEFINED compiler_cl_dialect)
# Do nothing
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(compiler_cl_dialect "GCC")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(compiler_cl_dialect "MSVC")
elseif (CMAKE_CXX_SIMULATE_ID STREQUAL "GCC")
set(compiler_cl_dialect "GCC")
elseif (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(compiler_cl_dialect "MSVC")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# On Linux, clang does not have SIMULATE_ID
set(compiler_cl_dialect "GCC")
elseif(WIN32)
message(WARNING "Could not determine compiler command line dialect, guessing MSVC")
set(compiler_cl_dialect "MSVC")
else()
message(WARNING "Could not determine compiler command line dialect, guessing GCC")
set(compiler_cl_dialect "GCC")
endif()
set(VERSION "0.0.1")
# Do Windows-specific tweaks for release builds
if (WIN32 AND NOT BUILD_ID STREQUAL "dev")
set_target_properties(progressia PROPERTIES WIN32_EXECUTABLE true)
# Debug options
option(VULKAN_ERROR_CHECKING "Enable Vulkan validation layers to detect Vulkan API usage errors at runtime")
if (compiler_cl_dialect STREQUAL "GCC")
target_link_options(progressia PRIVATE -static)
elseif (compiler_cl_dialect STREQUAL "MSVC")
target_link_options(progressia PRIVATE /entry:mainCRTStartup)
# The static linking options for standard libraries are not available for MSVC when using a GPLv3 license,
# as statically linking the standard C/C++ libraries would be a violation of the GPLv3 license.
# The GPL requires that any derivative work that includes GPL-licensed code must also be licensed under the GPL,
# and that the source code for the derivative work must be made available to anyone who receives the binary form.
# Statically linking the standard libraries with a GPLv3 license would create a derivative work,
# and would therefore require the entire program to be distributed under the terms of the GPL as well.
# To comply with the GPL, it is recommended to use shared library linking instead of static linking.
#
# Yours faithfully,
# ChatGPT
message(WARNING "Release builds with MSVC/Clang-CL are not supported")
endif()
endif()
# Pass configuration options
file(MAKE_DIRECTORY "${generated}/config")
configure_file(${PROJECT_SOURCE_DIR}/main/config.h.in
${PROJECT_BINARY_DIR}/config.h)
${generated}/config/config.h)
target_include_directories(progressia PRIVATE ${generated}/config)
# Libraries
@@ -72,7 +143,3 @@ target_link_libraries(progressia glm::glm)
# Use STB
target_include_directories(progressia PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/lib/stb/include)
# Use Boost
find_package(Boost 1.74 REQUIRED)
target_link_libraries(progressia Boost::headers)