Fix build system

This commit is contained in:
User
2026-01-30 21:52:00 +01:00
parent 17c1ae1638
commit 7afab23173
5 changed files with 16 additions and 8 deletions

View File

@@ -14,9 +14,10 @@
namespace emilib { namespace emilib {
// (Crydsch) fixes for standalone usage // (Crydsch) fixes for standalone usage
#define DCHECK_NE_F(x,y) assert((x) != (y))
#define DCHECK_F(x) assert(x) #define DCHECK_F(x) assert(x)
#define DCHECK_NE_F(x,y) assert((x) != (y))
#define DCHECK_EQ_F(x,y) assert((x) == (y)) #define DCHECK_EQ_F(x,y) assert((x) == (y))
#define DCHECK_LT_F(val1, val2) assert((val1) < (val2))
/// like std::equal_to but no need to #include <functional> /// like std::equal_to but no need to #include <functional>
template<typename T> template<typename T>

View File

@@ -10,6 +10,9 @@ project("spacegame"
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O0 -ggdb") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O0 -ggdb")
# Enable LTO support in linker to handle LTO-built dependencies
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
# Enable compiler warnings # Enable compiler warnings
set(SPACEGAME_COMPILER_WARNINGS set(SPACEGAME_COMPILER_WARNINGS
-Wall -Wextra -pedantic -Wall -Wextra -pedantic

View File

@@ -15,9 +15,10 @@ set(CMAKE_STRIP /usr/bin/llvm-strip )
# Note: We can static link with libc++, but not entirely since we depend on dynamic # Note: We can static link with libc++, but not entirely since we depend on dynamic
# libraries such as x11,glx,etc... # libraries such as x11,glx,etc...
# Note: Despite its name '-static-libstdc++' the option causes libc++ to be linked statically # Note: Despite its name '-static-libstdc++' the option causes libc++ to be linked statically
# When linking libc++ statically, we also need to link libc++abi
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++" ) set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++" )
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++") set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++ -lc++abi")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++") set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++ -lc++abi")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++") set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++ -lc++abi")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)

View File

@@ -33,6 +33,8 @@ set_target_properties(spacegame PROPERTIES
target_compile_definitions(spacegame PRIVATE target_compile_definitions(spacegame PRIVATE
$<$<CONFIG:Debug>:_DEBUG> $<$<CONFIG:Debug>:_DEBUG>
$<$<CONFIG:Debug>:BX_CONFIG_DEBUG=1>
$<$<NOT:$<CONFIG:Debug>>:BX_CONFIG_DEBUG=0>
) )
# -m64 - Build for a 64-bit machine # -m64 - Build for a 64-bit machine
@@ -55,13 +57,13 @@ target_include_directories(spacegame PRIVATE
target_link_libraries(spacegame PRIVATE target_link_libraries(spacegame PRIVATE
glfw glfw
bgfx::bx
bgfx::bimg
${BGFX} ${BGFX}
bgfx::bimg
bgfx::bx
Threads::Threads Threads::Threads
c++
) )
################## release ################### ################## release ###################
# Strip binary for release builds # Strip binary for release builds

View File

@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include <algorithm> #include <algorithm>
#include <ranges> #include <ranges>
#include <cstdint>
// Dummy defines for broken intellisense // Dummy defines for broken intellisense
// #define size_t (unsigned long int) // #define size_t (unsigned long int)
@@ -80,7 +81,7 @@ typedef struct color
{ {
uint8_t r, g, b, a; uint8_t r, g, b, a;
color() : r(0), g(0), b(0), a(1) {} color() : r(0), g(0), b(0), a(1) {} // TODO should this be 255 ?
color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {} color(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {}
} Color; } Color;