Correctly configure NXT_ENABLE_ASSERTS on multiconfiguration generators (#88)
And also set a default build type for single-configuration generators
This commit is contained in:
parent
35bf424035
commit
59dc03f101
|
@ -15,6 +15,11 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(nxt C CXX)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
|
||||
"Build type (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# Configuration options
|
||||
################################################################################
|
||||
|
@ -35,6 +40,7 @@ option(NXT_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL
|
|||
option(NXT_ENABLE_NULL "Enable compilation of the Null backend" ON)
|
||||
option(NXT_ENABLE_OPENGL "Enable compilation of the OpenGL backend" ON)
|
||||
option(NXT_ENABLE_VULKAN "Enable compilation of the Vulkan backend" OFF)
|
||||
option(NXT_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
|
||||
|
||||
################################################################################
|
||||
# Precompute compile flags and defines, functions to set them
|
||||
|
@ -46,9 +52,9 @@ set(NXT_INTERNAL_FLAGS "")
|
|||
set(NXT_INTERNAL_DEFS "")
|
||||
set(NXT_GENERATED_FLAGS "")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
list(APPEND NXT_DEFS "NXT_ENABLE_ASSERTS")
|
||||
endif()
|
||||
set(NXT_ENABLE_ASSERTS $<OR:$<CONFIG:Debug>,$<BOOL:${NXT_ALWAYS_ASSERT}>>)
|
||||
|
||||
list(APPEND NXT_DEFS $<${NXT_ENABLE_ASSERTS}:NXT_ENABLE_ASSERTS>)
|
||||
|
||||
if (NXT_ENABLE_D3D12)
|
||||
list(APPEND NXT_INTERNAL_DEFS "NXT_ENABLE_BACKEND_D3D12")
|
||||
|
|
|
@ -24,7 +24,7 @@ function(add_nxt_sample target sources)
|
|||
target_link_libraries(${target} sample_utils)
|
||||
target_include_directories(${target} SYSTEM PRIVATE ${GLM_INCLUDE_DIR})
|
||||
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
NXTInternaltarget("examples" ${target})
|
||||
NXTInternalTarget("examples" ${target})
|
||||
|
||||
# Suppress some warnings in our sample dependencies
|
||||
if (MSVC)
|
||||
|
|
|
@ -68,7 +68,7 @@ void HandleAssertionFailure(const char* file, const char* function, int line, co
|
|||
#define NXT_ASSERT(condition) NXT_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition)
|
||||
#define NXT_UNREACHABLE() \
|
||||
do { \
|
||||
NXT_ASSERT(false && "Unreachable code hit"); NXT_BUILTIN_UNREACHABLE(); \
|
||||
NXT_ASSERT(NXT_ASSERT_LOOP_CONDITION && "Unreachable code hit"); NXT_BUILTIN_UNREACHABLE(); \
|
||||
} while(NXT_ASSERT_LOOP_CONDITION)
|
||||
|
||||
#if !defined(NXT_SKIP_ASSERT_SHORTHANDS)
|
||||
|
|
|
@ -62,7 +62,9 @@ void* AlignVoidPtr(void* ptr, size_t alignment) {
|
|||
}
|
||||
|
||||
uint32_t Align(uint32_t value, size_t alignment) {
|
||||
ASSERT(alignment <= UINT32_MAX);
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
return (value + (alignment - 1)) & ~(alignment - 1);
|
||||
uint32_t alignment32 = static_cast<uint32_t>(alignment);
|
||||
return (value + (alignment32 - 1)) & ~(alignment32 - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue