Use preprocessor to exclude platform specify code instead of cmake
This commit is contained in:
@@ -66,7 +66,7 @@ IncludeCategories:
|
|||||||
CaseSensitive: false
|
CaseSensitive: false
|
||||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentPPDirectives: BeforeHash
|
IndentPPDirectives: None
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
|||||||
@@ -8,54 +8,30 @@ set(NOVA_VULKAN ON CACHE BOOL "Enable Vulkan support")
|
|||||||
set(NOVA_WAYLAND ON CACHE BOOL "Enable Wayland support")
|
set(NOVA_WAYLAND ON CACHE BOOL "Enable Wayland support")
|
||||||
set(NOVA_X11 ON CACHE BOOL "Enable X11 support")
|
set(NOVA_X11 ON CACHE BOOL "Enable X11 support")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(NOVA_WAYLAND OFF)
|
||||||
|
set(NOVA_X11 OFF)
|
||||||
|
else ()
|
||||||
|
set(NOVA_DX12 OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOVA_VULKAN)
|
||||||
|
find_package(Vulkan REQUIRED)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(ENGINE_SRC
|
set(ENGINE_SRC
|
||||||
core/debug.cpp
|
core/debug.cpp
|
||||||
|
drivers/dx12/render_driver.cpp
|
||||||
|
drivers/linux/system_driver.cpp
|
||||||
|
drivers/linux/wayland/system_driver.cpp
|
||||||
|
drivers/linux/x11/system_driver.cpp
|
||||||
|
drivers/windows/system_driver.cpp
|
||||||
|
drivers/vulkan/render_driver.cpp
|
||||||
platform/system.cpp
|
platform/system.cpp
|
||||||
render/renderer.cpp
|
render/renderer.cpp
|
||||||
render/render_device.cpp
|
render/render_device.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/windows/system_driver.cpp
|
|
||||||
)
|
|
||||||
set(NOVA_WAYLAND OFF)
|
|
||||||
set(NOVA_X11 OFF)
|
|
||||||
else ()
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/linux/system_driver.cpp
|
|
||||||
)
|
|
||||||
set(NOVA_DX12 OFF)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOVA_DX12)
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/dx12/render_driver.cpp
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
if (NOVA_VULKAN)
|
|
||||||
find_package(Vulkan REQUIRED)
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/vulkan/render_driver.cpp
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
if (NOVA_WAYLAND)
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/linux/wayland/system_driver.cpp
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
if (NOVA_X11)
|
|
||||||
set(ENGINE_SRC
|
|
||||||
${ENGINE_SRC}
|
|
||||||
drivers/linux/x11/system_driver.cpp
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
list(TRANSFORM ENGINE_SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
list(TRANSFORM ENGINE_SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
#ifndef NOVA_API
|
#ifndef NOVA_API
|
||||||
#ifdef NOVA_WINDOWS
|
#ifdef NOVA_WINDOWS
|
||||||
#ifdef NOVA_DLL_EXPORT
|
#ifdef NOVA_DLL_EXPORT
|
||||||
@@ -23,3 +24,4 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
// clang-format on
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ namespace Nova {
|
|||||||
#define NOVA_TRACE(...) ::Nova::Debug::get_logger()->trace(__VA_ARGS__)
|
#define NOVA_TRACE(...) ::Nova::Debug::get_logger()->trace(__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define NOVA_FUNC_NAME ::Nova::Internals::_format_func_name(__FUNCTION__)
|
#define NOVA_FUNC_NAME ::Nova::Internals::_format_func_name(__FUNCTION__)
|
||||||
#else
|
#else
|
||||||
#define NOVA_FUNC_NAME ::Nova::Internals::_format_func_name(__PRETTY_FUNCTION__)
|
#define NOVA_FUNC_NAME ::Nova::Internals::_format_func_name(__PRETTY_FUNCTION__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NOVA_AUTO_TRACE() NOVA_TRACE("{}()", NOVA_FUNC_NAME)
|
#define NOVA_AUTO_TRACE() NOVA_TRACE("{}()", NOVA_FUNC_NAME)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_DX12
|
||||||
|
|
||||||
#include "drivers/dx12/render_driver.h"
|
#include "drivers/dx12/render_driver.h"
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
@@ -17,3 +19,5 @@ DX12RenderDriver::DX12RenderDriver() {
|
|||||||
DX12RenderDriver::~DX12RenderDriver() {
|
DX12RenderDriver::~DX12RenderDriver() {
|
||||||
NOVA_AUTO_TRACE();
|
NOVA_AUTO_TRACE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_DX12
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_DX12
|
||||||
|
|
||||||
#include <nova/render/render_driver.h>
|
#include <nova/render/render_driver.h>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
@@ -15,3 +17,5 @@ namespace Nova {
|
|||||||
~DX12RenderDriver() override;
|
~DX12RenderDriver() override;
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_DX12
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_LINUX
|
||||||
|
|
||||||
#include "drivers/linux/system_driver.h"
|
#include "drivers/linux/system_driver.h"
|
||||||
|
|
||||||
#ifdef NOVA_WAYLAND
|
#include "drivers/linux/wayland/system_driver.h" // IWYU pragma: keep
|
||||||
#include "drivers/linux/wayland/system_driver.h"
|
#include "drivers/linux/x11/system_driver.h" // IWYU pragma: keep
|
||||||
#endif
|
|
||||||
#ifdef NOVA_X11
|
|
||||||
#include "drivers/linux/x11/system_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
|
|
||||||
@@ -47,3 +45,5 @@ std::unique_ptr<SystemDriver> LinuxSystemDriver::get_default_driver() {
|
|||||||
NOVA_WARN("Unsupported display server");
|
NOVA_WARN("Unsupported display server");
|
||||||
return std::make_unique<LinuxSystemDriver>();
|
return std::make_unique<LinuxSystemDriver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_LINUX
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_LINUX
|
||||||
|
|
||||||
#include <nova/platform/system_driver.h>
|
#include <nova/platform/system_driver.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -21,3 +23,5 @@ namespace Nova {
|
|||||||
static std::unique_ptr<SystemDriver> get_default_driver();
|
static std::unique_ptr<SystemDriver> get_default_driver();
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_LINUX
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_WAYLAND
|
||||||
|
|
||||||
#include "drivers/linux/wayland/system_driver.h"
|
#include "drivers/linux/wayland/system_driver.h"
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
@@ -17,3 +19,5 @@ WaylandSystemDriver::WaylandSystemDriver() {
|
|||||||
WaylandSystemDriver::~WaylandSystemDriver() {
|
WaylandSystemDriver::~WaylandSystemDriver() {
|
||||||
NOVA_AUTO_TRACE();
|
NOVA_AUTO_TRACE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_WAYLAND
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_WAYLAND
|
||||||
|
|
||||||
#include "drivers/linux/system_driver.h"
|
#include "drivers/linux/system_driver.h"
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
@@ -15,3 +17,5 @@ namespace Nova {
|
|||||||
~WaylandSystemDriver() override;
|
~WaylandSystemDriver() override;
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_WAYLAND
|
||||||
|
|||||||
@@ -4,11 +4,13 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_X11
|
||||||
|
|
||||||
#include "drivers/linux/x11/system_driver.h"
|
#include "drivers/linux/x11/system_driver.h"
|
||||||
|
|
||||||
#ifdef NOVA_VULKAN
|
#ifdef NOVA_VULKAN
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_xlib.h>
|
#include <vulkan/vulkan_xlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
@@ -30,3 +32,5 @@ const char* X11SystemDriver::get_surface_extension() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_X11
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_X11
|
||||||
|
|
||||||
#include "drivers/linux/system_driver.h"
|
#include "drivers/linux/system_driver.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
@@ -19,3 +21,5 @@ namespace Nova {
|
|||||||
[[nodiscard]] const char* get_surface_extension() const override;
|
[[nodiscard]] const char* get_surface_extension() const override;
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_X11
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_VULKAN
|
||||||
|
|
||||||
#include "drivers/vulkan/render_driver.h"
|
#include "drivers/vulkan/render_driver.h"
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
@@ -344,3 +346,5 @@ VkAllocationCallbacks* VulkanRenderDriver::_get_allocator(const VkObjectType typ
|
|||||||
(void)type;
|
(void)type;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_VULKAN
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_VULKAN
|
||||||
|
|
||||||
#include <nova/render/render_driver.h>
|
#include <nova/render/render_driver.h>
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
@@ -51,3 +53,5 @@ namespace Nova {
|
|||||||
static VkAllocationCallbacks* _get_allocator(VkObjectType type);
|
static VkAllocationCallbacks* _get_allocator(VkObjectType type);
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_VULKAN
|
||||||
|
|||||||
@@ -4,11 +4,13 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_WINDOWS
|
||||||
|
|
||||||
#include "drivers/windows/system_driver.h"
|
#include "drivers/windows/system_driver.h"
|
||||||
|
|
||||||
#ifdef NOVA_VULKAN
|
#ifdef NOVA_VULKAN
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_win32.h>
|
#include <vulkan/vulkan_win32.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
@@ -30,3 +32,5 @@ const char* WindowsSystemDriver::get_surface_extension() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_WINDOWS
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_WINDOWS
|
||||||
|
|
||||||
#include <nova/platform/system_driver.h>
|
#include <nova/platform/system_driver.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@@ -18,3 +20,5 @@ namespace Nova {
|
|||||||
[[nodiscard]] const char* get_surface_extension() const override;
|
[[nodiscard]] const char* get_surface_extension() const override;
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_WINDOWS
|
||||||
|
|||||||
@@ -4,12 +4,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NOVA_WINDOWS
|
#include "drivers/linux/system_driver.h" // IWYU pragma: keep
|
||||||
#include "drivers/windows/system_driver.h"
|
#include "drivers/windows/system_driver.h" // IWYU pragma: keep
|
||||||
#endif
|
|
||||||
#ifdef NOVA_LINUX
|
|
||||||
#include "drivers/linux/system_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
#include <nova/platform/system.h>
|
#include <nova/platform/system.h>
|
||||||
|
|||||||
@@ -4,12 +4,8 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NOVA_DX12
|
#include "drivers/dx12/render_driver.h" // IWYU pragma: keep
|
||||||
#include "drivers/dx12/render_driver.h"
|
#include "drivers/vulkan/render_driver.h" // IWYU pragma: keep
|
||||||
#endif
|
|
||||||
#ifdef NOVA_VULKAN
|
|
||||||
#include "drivers/vulkan/render_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
#include <nova/render/renderer.h>
|
#include <nova/render/renderer.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user