Compare commits

...

3 Commits

Author SHA1 Message Date
ab1baec49e More CMakeLists improvements 2025-11-05 23:35:36 +10:00
12237c6e4f Add Utils::Overloaded helper 2025-11-04 21:51:39 +10:00
c9474e1214 Add primitive types aliases 2025-11-04 21:45:00 +10:00
4 changed files with 89 additions and 19 deletions

View File

@@ -9,6 +9,14 @@ enable_language(CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
endif()
set(NOVA_SANITIZERS "" CACHE STRING "Sanitizers to enable (address, undefined, leak)")
set(NOVA_WERROR OFF CACHE BOOL "Treat compiler warnings as errors")
add_compile_definitions(
NOVA_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
@@ -21,32 +29,44 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
/W4
/permissive-
/EHsc
$<$<BOOL:${NOVA_WERROR}>:/WX>
)
add_compile_definitions(
NOVA_COMPILER_MSVC
)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (NOVA_SANITIZERS)
add_compile_options(/fsanitize=${NOVA_SANITIZERS})
endif()
add_compile_definitions(NOVA_COMPILER_MSVC)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wold-style-cast
$<$<BOOL:${NOVA_WERROR}>:-Werror>
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(
NOVA_COMPILER_GCC
)
else()
add_compile_definitions(
NOVA_COMPILER_CLANG
)
endif()
else()
error("Unsupported compiler")
if (NOVA_SANITIZERS)
add_compile_options(-fsanitize=${NOVA_SANITIZERS})
add_link_options(-fsanitize=${NOVA_SANITIZERS})
endif()
if (WIN32)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(NOVA_COMPILER_GCC)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_definitions(NOVA_COMPILER_CLANG)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_definitions(
NOVA_COMPILER_CLANG
NOVA_COMPILER_APPLE_CLANG
)
endif()
else()
message(FATAL_ERROR "Unsupported compiler")
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_compile_definitions(
NOVA_PLATFORM_WINDOWS
NOMINMAX
@@ -54,16 +74,12 @@ if (WIN32)
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_WARNINGS
)
elseif (APPLE)
add_compile_definitions(
NOVA_PLATFORM_MACOS
)
elseif (UNIX)
add_compile_definitions(
NOVA_PLATFORM_LINUX
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions(NOVA_PLATFORM_MACOS)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_compile_definitions(NOVA_PLATFORM_LINUX)
else()
error("Unsupported platform")
message(FATAL_ERROR "Unsupported platform")
endif()
add_subdirectory(engine)

View File

@@ -0,0 +1,35 @@
/**
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include <cstddef>
#include <cstdint>
namespace Nova::Types {
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using usize = size_t;
using uptr = uintptr_t;
using umax = uintmax_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using isize = ptrdiff_t;
using iptr = intptr_t;
using imax = intmax_t;
using f32 = float;
using f64 = double;
} // namespace Nova::Types
using namespace Nova::Types;

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
namespace Nova::Utils {
template<typename... Ts>
struct Overloaded : Ts... {
using Ts::operator()...;
};
template<typename... Ts>
Overloaded(Ts...) -> Overloaded<Ts...>;
} // namespace Nova::Utils