17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 05:09:20 +02:00
Files
maszyna/betterRenderer/CMakeLists.txt
maj00r 5b4df01565 pick the AVX2 spelling by driver, not by platform
betterRenderer gated on WIN32, and WIN32 is true for clang's GNU driver
too, so /arch:AVX2 reached a driver that reads it as a file name.

Swept every compile and link option in the tree for MSVC-style flags
without an MSVC guard; this was the only one left.
2026-09-10 14:14:53 +02:00

127 lines
4.1 KiB
CMake

set(LIBMANUL_NAME "betterRenderer")
set(LIBMANUL_WITH_DX12 OFF)
set(LIBMANUL_WITH_VULKAN OFF)
if (WIN32)
set(LIBMANUL_WITH_DX12 ON)
elseif (UNIX)
set(LIBMANUL_WITH_VULKAN ON)
endif ()
if (LIBMANUL_WITH_VULKAN)
find_package(Vulkan 1.3.230 REQUIRED)
include_directories(${Vulkan_INCLUDE_DIRS})
endif ()
# Third-party deps
add_subdirectory("thirdparty/nvrhi")
add_subdirectory("thirdparty/yaml-cpp")
add_subdirectory("thirdparty/fmt")
add_subdirectory("thirdparty/entt")
add_subdirectory("thirdparty/fsr2")
set(CMAKE_CXX_STANDARD 20)
add_subdirectory("thirdparty/bvh")
add_subdirectory("mashadercompiler")
add_subdirectory("shaders")
# Source code
file(GLOB_RECURSE src
"renderer/*.cpp"
"renderer/*.hpp"
"renderer/*.h")
add_library(${LIBMANUL_NAME} ${src})
# The project's own types reach this renderer as C++20 modules; linking the
# target that owns the module file set is what makes them importable.
target_link_libraries(${LIBMANUL_NAME} eu07_modules)
# CXX_EXTENSIONS must match eu07_modules: a BMI built with -std=c++20 is
# refused by a translation unit compiled with -std=gnu++20.
set_target_properties(${LIBMANUL_NAME} PROPERTIES
CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
target_include_directories(${LIBMANUL_NAME} PUBLIC
"renderer/include")
target_include_directories(${LIBMANUL_NAME} PRIVATE
"renderer/source"
"${GLOBAL_INCLUDE_DIR}"
"${IMGUI_DIR}"
"${GLM_INCLUDE_DIR}")
# Needs more refactoring to get rid of that unfortunately...
target_include_directories(${LIBMANUL_NAME} PRIVATE
"${GLOBAL_ROOT_DIR}")
# DynObj requires MOVER.h
target_include_directories(${LIBMANUL_NAME} PRIVATE
"${GLOBAL_ROOT_DIR}/McZapkie")
# OpenAL required by MOVER.h
target_include_directories(${LIBMANUL_NAME} PRIVATE
"${OPENAL_INCLUDE_DIR}")
# GLuint, GLint typedef'd here
target_include_directories(${LIBMANUL_NAME} PRIVATE
"${DEPS_DIR}/glad/include")
# Python.h
find_package(Python3 3.14 REQUIRED COMPONENTS Development)
target_include_directories(${LIBMANUL_NAME} PRIVATE
"${Python3_INCLUDE_DIRS}")
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
GLM_ENABLE_EXPERIMENTAL
GLM_FORCE_SWIZZLE
GLM_FORCE_CTOR_INIT
GLM_FORCE_INLINE
GLM_FORCE_INTRINSICS)
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
_USE_MATH_DEFINES)
# windows headers included SOMEWHERE
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
NOMINMAX)
# to avoid global_settings changing size...
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
${DEFINITIONS})
# we need to include libserialport stuff to include uart because of
# the setting class having mismatched size across TUs otherwise
target_include_directories(${LIBMANUL_NAME} PRIVATE
${libserialport_INCLUDE_DIR} ${LUAJIT_INCLUDE_DIR})
if (LIBMANUL_WITH_DX12)
target_link_libraries(${LIBMANUL_NAME} nvrhi_d3d12 dxgi.lib)
target_compile_definitions(${LIBMANUL_NAME} PUBLIC "LIBMANUL_WITH_D3D12=1" "GLFW_EXPOSE_NATIVE_WIN32")
else ()
target_compile_definitions(${LIBMANUL_NAME} PUBLIC "LIBMANUL_WITH_D3D12=0")
endif ()
if (LIBMANUL_WITH_VULKAN)
target_link_libraries(${LIBMANUL_NAME} nvrhi_vk Vulkan::Headers)
target_compile_definitions(${LIBMANUL_NAME} PUBLIC "LIBMANUL_WITH_VULKAN=1" "GLFW_INCLUDE_VULKAN")
else ()
target_compile_definitions(${LIBMANUL_NAME} PUBLIC "LIBMANUL_WITH_VULKAN=0")
endif ()
# Which spelling to use follows the compiler driver, not the platform: the
# Windows build runs clang's GNU driver, which reads /arch:AVX2 as a file name.
if(ENABLE_AVX2)
if (MSVC)
target_compile_options(${LIBMANUL_NAME} PRIVATE "/arch:AVX2")
else ()
target_compile_options(${LIBMANUL_NAME} PRIVATE "-mavx2")
endif ()
endif()
target_sources(${LIBMANUL_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/eu07_source/register.cpp")
set_target_properties(nvrhi yaml-cpp fmt EnTT glfw yaml-cpp-parse yaml-cpp-read yaml-cpp-sandbox PROPERTIES FOLDER "libraries")
target_link_libraries(${LIBMANUL_NAME} ${LIBMANUL_NAME}_fsr2 nvrhi yaml-cpp fmt EnTT glfw bvh)
add_dependencies(${LIBMANUL_NAME} ${LIBMANUL_NAME}_shaders)