Compare commits
3 Commits
v2
...
7c1612be63
| Author | SHA1 | Date | |
|---|---|---|---|
|
7c1612be63
|
|||
|
a32cd24417
|
|||
|
2b5c9ac062
|
@@ -6,9 +6,19 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
||||
|
||||
project(nova VERSION 0.0.1)
|
||||
enable_language(CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
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 +31,47 @@ 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)
|
||||
string(REPLACE "," ";" SANITIZERS ${NOVA_SANITIZERS})
|
||||
foreach(sanitizer IN LISTS SANITIZERS)
|
||||
add_compile_options(/fsanitize=${sanitizer})
|
||||
endforeach()
|
||||
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 (NOVA_SANITIZERS)
|
||||
add_compile_options(-fsanitize=${NOVA_SANITIZERS})
|
||||
add_link_options(-fsanitize=${NOVA_SANITIZERS})
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_definitions(
|
||||
NOVA_COMPILER_GCC
|
||||
)
|
||||
else()
|
||||
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()
|
||||
error("Unsupported compiler")
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_compile_definitions(
|
||||
NOVA_PLATFORM_WINDOWS
|
||||
NOMINMAX
|
||||
@@ -54,16 +79,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)
|
||||
|
||||
@@ -14,6 +14,6 @@ target_include_directories(nova
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
target_compile_definitions(nova
|
||||
PRIVATE NOVA_EXPORT_SYMBOLS
|
||||
set_target_properties(nova PROPERTIES
|
||||
DEFINE_SYMBOL NOVA_EXPORT_SYMBOLS
|
||||
)
|
||||
|
||||
35
engine/include/nova/core/types.hpp
Normal file
35
engine/include/nova/core/types.hpp
Normal 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;
|
||||
19
engine/include/nova/utils/overloaded.hpp
Normal file
19
engine/include/nova/utils/overloaded.hpp
Normal 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
|
||||
Reference in New Issue
Block a user