Skip to content

Commit

Permalink
- CMAKE cleanup
Browse files Browse the repository at this point in the history
- Add support to turn off renderer using RAWRBOX_BUILD_RAWRBOX_RENDER
- Jolt improvements
- Fixed missing RAWRBOX_TRACE_EXCEPTIONS checks
  • Loading branch information
edunad committed Aug 15, 2024
1 parent d6c360a commit f6e8909
Show file tree
Hide file tree
Showing 33 changed files with 179 additions and 114 deletions.
53 changes: 37 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ option(RAWRBOX_USE_WAYLAND "Use Wayland for linux" OFF)
option(RAWRBOX_BUILD_TESTING "Build tests" OFF)
option(RAWRBOX_BUILD_SAMPLES "Build samples" OFF)

option(RAWRBOX_BUILD_RAWRBOX_RENDER "Build rawrbox renderer, disable for renderless programs" ON)
option(RAWRBOX_BUILD_RAWRBOX_UI "Build rawrbox UI" OFF)
option(RAWRBOX_BUILD_RAWRBOX_RESOURCES "Build rawrbox resources utils" OFF)
option(RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS "Build 3D physics support" OFF)
Expand Down Expand Up @@ -63,26 +64,27 @@ option(RAWRBOX_INTERPROCEDURAL_OPTIMIZATION "Enables IPO" ON)
# ---------------
# -----

if(RAWRBOX_INTERPROCEDURAL_OPTIMIZATION)
message(WARNING "Enabled INTERPROCEDURAL_OPTIMIZATION")
if(RAWRBOX_INTERPROCEDURAL_OPTIMIZATION AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM64") AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM"))
message(STATUS "Enabled INTERPROCEDURAL_OPTIMIZATION for release and distribution")

include(CheckIPOSupported)
check_ipo_supported(RESULT ipoSupported OUTPUT error)

if(ipoSupported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION TRUE)
else()
message(FATAL_ERROR "IPO / LTO is not supported, please disable RAWRBOX_INTERPROCEDURAL_OPTIMIZATION")
endif()
endif()

# Uncomment for package.lock generation
if(RAWRBOX_DEV_MODE)
message(WARNING "RAWRBOX Dev mode enabled!")

set(RAWRBOX_BUILD_TESTING ON)
set(RAWRBOX_BUILD_SAMPLES ON)

set(RAWRBOX_BUILD_RAWRBOX_RENDER ON)
set(RAWRBOX_BUILD_RAWRBOX_UI ON)
set(RAWRBOX_BUILD_RAWRBOX_RESOURCES ON)
set(RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS ON)
Expand Down Expand Up @@ -135,14 +137,16 @@ if(NOT WIN32)
list(APPEND RAWRBOX_EXTRA_LIBS wayland-egl)
set(GLFW_BUILD_WAYLAND ON CACHE INTERNAL "")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions") # Enable exceptions and RTTI
else()
# Ignore warnings about missing pdb
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ignore:4099")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4099")

add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /EHsc /GR") # Enable strict mode, exceptions and RTTI
endif()

set(CMAKE_SKIP_RPATH TRUE)
Expand All @@ -162,14 +166,26 @@ endif()
# ---------------------

## CHECKS ---
if(RAWRBOX_BUILD_SAMPLES AND NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
message(WARNING "Samples require RAWRBOX.RESOURCES to be enabled, enabling...")
set(RAWRBOX_BUILD_RAWRBOX_RESOURCES ON)
endif()
if(NOT RAWRBOX_BUILD_RAWRBOX_RENDER)
message(WARNING "----------------------------------------\nRAWRBOX_BUILD_RAWRBOX_RENDER is disabled!\nDisabling UI / ASSIMP / IMGUI / WEBM and samples..\n----------------------------------------")
set(RAWRBOX_BUILD_RAWRBOX_UI OFF)
set(RAWRBOX_BUILD_RAWRBOX_ASSIMP OFF)
set(RAWRBOX_BUILD_RAWRBOX_IMGUI OFF)
set(RAWRBOX_BUILD_RAWRBOX_WEBM OFF)

set(RAWRBOX_BUILD_SAMPLES OFF)
else()
# Samples & UI ---
if(RAWRBOX_BUILD_SAMPLES AND NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
message(WARNING "Samples require RAWRBOX.RESOURCES to be enabled, enabling...")
set(RAWRBOX_BUILD_RAWRBOX_RESOURCES ON)
endif()

if(RAWRBOX_BUILD_RAWRBOX_UI AND NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
message(WARNING "RAWRBOX.UI requires RAWRBOX.RESOURCES to be enabled, enabling...")
set(RAWRBOX_BUILD_RAWRBOX_RESOURCES ON)
if(RAWRBOX_BUILD_RAWRBOX_UI AND NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
message(WARNING "RAWRBOX.UI requires RAWRBOX.RESOURCES to be enabled, enabling...")
set(RAWRBOX_BUILD_RAWRBOX_RESOURCES ON)
endif()
# -----------
endif()

if(NOT RAWRBOX_BUILD_MSVC_MULTITHREADED_RUNTIME AND RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS)
Expand All @@ -189,8 +205,10 @@ if(magic_enum_ADDED)
set_lib_runtime_mt(magic_enum)
endif()

if(NOT WIN32 AND RAWRBOX_USE_WAYLAND)
CPMAddPackage("https://gitlab.freedesktop.org/wayland/[email protected]")
if(RAWRBOX_BUILD_RAWRBOX_RENDER)
if(NOT WIN32 AND RAWRBOX_USE_WAYLAND)
CPMAddPackage("https://gitlab.freedesktop.org/wayland/[email protected]")
endif()
endif()

CPMAddPackage("gh:stephenberry/[email protected]")
Expand Down Expand Up @@ -231,6 +249,11 @@ add_subdirectory("rawrbox.math")
add_subdirectory("rawrbox.utils")
add_subdirectory("rawrbox.engine")

if(RAWRBOX_BUILD_RAWRBOX_RENDER)
message(STATUS "Enabled RAWRBOX.RENDER support")
add_subdirectory("rawrbox.render")
endif()

if(RAWRBOX_BUILD_RAWRBOX_SCRIPTING)
message(STATUS "Enabled RAWRBOX.SCRIPTING support")
add_subdirectory("rawrbox.scripting")
Expand All @@ -246,8 +269,6 @@ if(RAWRBOX_BUILD_RAWRBOX_NETWORK)
add_subdirectory("rawrbox.network")
endif()

add_subdirectory("rawrbox.render")

if(RAWRBOX_BUILD_RAWRBOX_WEBM)
message(STATUS "Enabled RAWRBOX.WEBM support")
add_subdirectory("rawrbox.webm")
Expand Down
78 changes: 40 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ This engine started as a C++ training project, with hopes of being applied in my
### REQUIRED SOFTWARE

- [Microsoft Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe) 2015 - 2022 version
- [Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows) (ensure the enviroment paths are correct)
- [GIT](https://git-scm.com/) or something similar to GIT
- [CMAKE](https://cmake.org/download/) at least > 3.16.3
- Download and install **C++ Build Tools** (2022 is recommended)<br/>
Expand Down Expand Up @@ -113,44 +114,45 @@ This engine started as a C++ training project, with hopes of being applied in my

# CMAKE OPTIONS

| OPTION NAME | NOTE |
| :----------------------------------------- | :------------------------------------------------------------------------------------------------- |
| `RAWRBOX_BUILD_TESTING` | Builds & enables project tests |
| `RAWRBOX_BUILD_SAMPLES` | Builds the project sample |
| -- | -- |
| `RAWRBOX_CONTENT_FOLDER` | The content folder to output assets. Default is `assets` |
| -- | -- |
| `RAWRBOX_USE_WAYLAND` | Enables WAYLAND compiling on LINUX |
| -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_UI` | Builds and includes ui |
| `RAWRBOX_BUILD_RAWRBOX_RESOURCES` | Builds and resouces manager (aka handling and storing loaded resources) |
| `RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS` | Builds the 3D physics engine |
| `RAWRBOX_BUILD_RAWRBOX_2D_PHYSICS` | Builds the 2D physics engine |
| `RAWRBOX_BUILD_RAWRBOX_BASS` | Enables BASS support. ⚠️ [BASS IS ONLY FREE FOR OPEN SOURCE PROJECTS](https://www.un4seen.com/) ⚠️ |
| `RAWRBOX_BUILD_RAWRBOX_ASSIMP` | Enables assimp model loading |
| `RAWRBOX_BUILD_RAWRBOX_WEBM` | Enables WEBM loading |
| `RAWRBOX_BUILD_RAWRBOX_NETWORK` | Builds network support |
| `RAWRBOX_BUILD_RAWRBOX_IMGUI` | Builds imgui support |
| -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_SCRIPTING` | Enables lua & modding support |
| `RAWRBOX_SCRIPTING_UNSAFE` | Enables io support on lua (loading and saving files on the data folder) |
| `RAWRBOX_SCRIPTING_EXCEPTION` | Enables scripting throwing exceptions instead of catching them |
| `RAWRBOX_SCRIPTING_WORKSHOP_MODDING` | Enables workshop utilities (useful for steam workshop / mod.io) |
| -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_STEAMWORKS` | Enables steamworks support |
| `STEAMWORKS_APPID` | Sets the steamworks appid |
| -- | -- |
| `RAWRBOX_BUILD_QHULL` | Builds QHull util |
| -- | -- |
| `RAWRBOX_BUILD_MSVC_MULTITHREADED_RUNTIME` | Builds libraries with MSVC Multithreaded runtime (Auto-enabled if jolt is used) |
| -- | -- |
| `RAWRBOX_DISABLE_SUPPORT_DX12` | Disable dx12 support |
| `RAWRBOX_DISABLE_SUPPORT_VULKAN` | Disable vulkan support |
| -- | -- |
| `RAWRBOX_DEV_MODE` | Enables all the modules, used for rawrbox development |
| -- | -- |
| `RAWRBOX_TRACE_EXCEPTIONS` | Enables exception tracing |
| `RAWRBOX_INTERPROCEDURAL_OPTIMIZATION` | Enables IPO compilation |
| OPTION NAME | NOTE | DEFAULT |
| :----------------------------------------- | :------------------------------------------------------------------------------------------------- | ------- |
| `RAWRBOX_BUILD_TESTING` | Builds & enables project tests | OFF |
| `RAWRBOX_BUILD_SAMPLES` | Builds the project sample | OFF |
| -- | -- | -- |
| `RAWRBOX_CONTENT_FOLDER` | The content folder to output assets. Default is `assets` | OFF |
| -- | -- | -- |
| `RAWRBOX_USE_WAYLAND` | Enables WAYLAND compiling on LINUX | OFF |
| -- | -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_RENDER` | Builds and the renderer, disable for renderless programs | ON |
| `RAWRBOX_BUILD_RAWRBOX_UI` | Builds rawrbox ui (alternative to imgui) | OFF |
| `RAWRBOX_BUILD_RAWRBOX_RESOURCES` | Builds the resouces manager (aka handling and storing loaded resources) | OFF |
| `RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS` | Builds the 3D physics engine | OFF |
| `RAWRBOX_BUILD_RAWRBOX_2D_PHYSICS` | Builds the 2D physics engine | OFF |
| `RAWRBOX_BUILD_RAWRBOX_BASS` | Enables BASS support. ⚠️ [BASS IS ONLY FREE FOR OPEN SOURCE PROJECTS](https://www.un4seen.com/) ⚠️ | OFF |
| `RAWRBOX_BUILD_RAWRBOX_ASSIMP` | Enables assimp model loading | OFF |
| `RAWRBOX_BUILD_RAWRBOX_WEBM` | Enables WEBM loading | OFF |
| `RAWRBOX_BUILD_RAWRBOX_NETWORK` | Builds network support | OFF |
| `RAWRBOX_BUILD_RAWRBOX_IMGUI` | Builds imgui support | OFF |
| -- | -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_SCRIPTING` | Enables lua & modding support | OFF |
| `RAWRBOX_SCRIPTING_UNSAFE` | Enables io support on lua (loading and saving files on the data folder) | OFF |
| `RAWRBOX_SCRIPTING_EXCEPTION` | Enables scripting throwing exceptions instead of catching them | OFF |
| `RAWRBOX_SCRIPTING_WORKSHOP_MODDING` | Enables workshop utilities (useful for steam workshop / mod.io) | OFF |
| -- | -- | -- |
| `RAWRBOX_BUILD_RAWRBOX_STEAMWORKS` | Enables steamworks support | OFF |
| `STEAMWORKS_APPID` | Sets the steamworks appid | OFF |
| -- | -- | -- |
| `RAWRBOX_BUILD_QHULL` | Builds QHull util | OFF |
| -- | -- | -- |
| `RAWRBOX_BUILD_MSVC_MULTITHREADED_RUNTIME` | Builds libraries with MSVC Multithreaded runtime (Auto-enabled if jolt is used) | OFF |
| -- | -- | -- |
| `RAWRBOX_DISABLE_SUPPORT_DX12` | Disable dx12 support | OFF |
| `RAWRBOX_DISABLE_SUPPORT_VULKAN` | Disable vulkan support | OFF |
| -- | -- | -- |
| `RAWRBOX_DEV_MODE` | Enables all the modules, used for rawrbox development | OFF |
| -- | -- | -- |
| `RAWRBOX_TRACE_EXCEPTIONS` | Enables exception tracing | ON |
| `RAWRBOX_INTERPROCEDURAL_OPTIMIZATION` | Enables IPO compilation on release | ON |

<br/><br/>

Expand Down
6 changes: 5 additions & 1 deletion rawrbox.bass/src/resources/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ namespace rawrbox {
} else {
loaded = rawrbox::BASS::loadSound(this->filePath, this->flags);
}
#ifdef RAWRBOX_TRACE_EXCEPTIONS
} catch (const cpptrace::exception_with_message& e) {
fmt::print("\n\t{}\n\t\t └── Loading fallback sound!\n", e.message());
#else
} catch (const std::exception& e) {
#endif
fmt::print("\n\t{}\n\t\t └── Loading fallback sound!\n", e.what());
loaded = rawrbox::BASS::loadSound("./assets/sound/error.ogg", this->flags);
}

Expand Down
4 changes: 0 additions & 4 deletions rawrbox.engine/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#include <rawrbox/utils/threading.hpp>
#include <rawrbox/utils/timer.hpp>

#ifdef RAWRBOX_TRACE_EXCEPTIONS
#include <cpptrace/cpptrace.hpp>
#endif

#include <fmt/format.h>

#include <chrono>
Expand Down
Loading

0 comments on commit f6e8909

Please sign in to comment.