- More Documentation
- Vulkan Configuration Implementations - Fixed build errors on GCC and Clang
This commit is contained in:
@@ -18,11 +18,22 @@
|
||||
|
||||
# this script handles functionality related to the build process and its info
|
||||
|
||||
# Acquire the build name
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} FENNEC_BUILD_NAME)
|
||||
message(STATUS "Build: ${FENNEC_BUILD_NAME}")
|
||||
|
||||
# Add build name to the compile definitions
|
||||
fennec_add_definitions(FENNEC_BUILD_NAME="${FENNEC_BUILD_NAME}")
|
||||
|
||||
# Check if building for debug
|
||||
if(${FENNEC_BUILD_NAME} MATCHES "debug")
|
||||
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_RELEASE=false)
|
||||
fennec_add_definitions(FENNEC_RELEASE=false FENNEC_DEBUG=true)
|
||||
|
||||
# Release with debug info
|
||||
elseif(${FENNEC_BUILD_NAME} MATCHES "relwithdebinfo")
|
||||
fennec_add_definitions(FENNEC_RELEASE=true FENNEC_DEBUG=true)
|
||||
|
||||
# Any others are considered release without debugging
|
||||
else()
|
||||
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_RELEASE=true)
|
||||
endif()
|
||||
fennec_add_definitions(FENNEC_RELEASE=true FENNEC_DEBUG=false)
|
||||
endif()
|
||||
|
||||
38
cmake/clang.cmake
Normal file
38
cmake/clang.cmake
Normal file
@@ -0,0 +1,38 @@
|
||||
# ======================================================================================================================
|
||||
# fennec, a free and open source game engine
|
||||
# Copyright © 2025 - 2026 Medusa Slockbower
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
# ======================================================================================================================
|
||||
|
||||
# this script sets flags and variables for llvm compilers
|
||||
|
||||
# Receive all warnings and treat as errors
|
||||
add_compile_options("-Wall" "-Wextra" "-pedantic" "-Werror" "-fms-extensions")
|
||||
|
||||
# Use relative directories to hide the user's directory
|
||||
fennec_add_compile_options("-ffile-prefix-map=${FENNEC_SOURCE_DIR}=.")
|
||||
|
||||
# Disable STDLIB, Exceptions, and RTTI, we implement our own. Also include diagnostics and pthread.
|
||||
fennec_add_link_options("-nostdlib" "-fno-exceptions" "-fno-rtti" "-fdiagnostics-all-candidates" "-pthread")
|
||||
|
||||
# Base definitions for Clang
|
||||
fennec_add_definitions(
|
||||
_GLIBCXX_INCLUDE_NEXT_C_HEADERS=1
|
||||
FENNEC_COMPILER_CLANG=1
|
||||
FENNEC_GLIBC=1
|
||||
FENNEC_NO_INLINE=[[clang::noinline]]
|
||||
FENNEC_FUNCTION_NAME=__PRETTY_FUNCTION__
|
||||
)
|
||||
|
||||
@@ -18,13 +18,27 @@
|
||||
|
||||
# this script finds the compiler being used
|
||||
|
||||
# Send a message letting us know the compiler and its version
|
||||
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
|
||||
# Add definitions for the compiler
|
||||
fennec_add_definitions(
|
||||
FENNEC_LONG_COMPILER_NAME="${CMAKE_CXX_COMPILER_ID} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}"
|
||||
)
|
||||
|
||||
# GCC
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
||||
set(FENNEC_COMPILER "GCC")
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/gcc.cmake")
|
||||
set(FENNEC_COMPILER "GCC")
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/gcc.cmake")
|
||||
endif()
|
||||
|
||||
# Clang
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
set(FENNEC_COMPILER "Clang")
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/clang.cmake")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# TODO: MSVC & MinGW
|
||||
|
||||
|
||||
@@ -18,15 +18,20 @@
|
||||
|
||||
# this script sets flags and variables for gnu and gnu-like compilers
|
||||
|
||||
# Receive all warnings and treat as errors
|
||||
add_compile_options("-Wall" "-Wextra" "-pedantic" "-Werror" "-fms-extensions")
|
||||
|
||||
# Use relative directories to hide the user's directory
|
||||
fennec_add_compile_options("-ffile-prefix-map=${FENNEC_SOURCE_DIR}=.")
|
||||
|
||||
# Disable STDLIB, Exceptions, and RTTI, we implement our own. Also include diagnostics and pthread.
|
||||
fennec_add_link_options("-nostdlib" "-fno-exceptions" "-fno-rtti" "-fdiagnostics-all-candidates" "-pthread")
|
||||
|
||||
# Base definitions for GCC
|
||||
fennec_add_definitions(
|
||||
_GLIBCXX_INCLUDE_NEXT_C_HEADERS=1
|
||||
FENNEC_COMPILER_GCC=1
|
||||
FENNEC_GLIBC=1
|
||||
FENNEC_NO_INLINE=[[gnu::noinline]]
|
||||
FENNEC_FUNCTION_NAME=__PRETTY_FUNCTION__
|
||||
)
|
||||
|
||||
@@ -33,9 +33,11 @@ macro(fennec_check_platform)
|
||||
include/fennec/platform/linux/platform.h source/platform/linux/platform.cpp
|
||||
)
|
||||
|
||||
# Add display and graphics for client builds.
|
||||
if(FENNEC_USER_CLIENT)
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/wayland.cmake")
|
||||
|
||||
fennec_init_graphics()
|
||||
fennec_check_wayland()
|
||||
fennec_init_graphics()
|
||||
endif()
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
find_package(OpenGL)
|
||||
|
||||
# Check if EGL is desired
|
||||
if(FENNEC_GRAPHICS_WANT_EGL)
|
||||
fennec_add_sources(
|
||||
include/fennec/platform/opengl/egl/fwd.h
|
||||
include/fennec/platform/opengl/egl/forward.h
|
||||
include/fennec/platform/opengl/egl/error.h
|
||||
include/fennec/platform/opengl/egl/context.h source/platform/opengl/egl/context.cpp
|
||||
include/fennec/platform/opengl/egl/surface.h source/platform/opengl/egl/surface.cpp
|
||||
@@ -29,15 +30,24 @@ if(FENNEC_GRAPHICS_WANT_EGL)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Check that we found OpenGL
|
||||
if(TARGET OpenGL::GL)
|
||||
|
||||
# Link & add definitions for OpenGL
|
||||
fennec_add_link_libraries(OpenGL::GL)
|
||||
fennec_add_definitions(FENNEC_GRAPHICS_OPENGL=1)
|
||||
|
||||
# Cmake Definition for OpenGL detection
|
||||
set(FENNEC_FOUND_OPENGL TRUE)
|
||||
|
||||
# Add OpenGL sources
|
||||
fennec_add_sources(
|
||||
include/fennec/platform/opengl/glad/gl.h source/platform/opengl/glad/gl.c
|
||||
|
||||
include/fennec/renderers/opengl/glcontext.h source/renderers/opengl/glcontext.cpp
|
||||
)
|
||||
else()
|
||||
|
||||
# OpenGL is required if included.
|
||||
message(FATAL_ERROR "No Suitable OpenGL implementation found.")
|
||||
endif()
|
||||
@@ -28,7 +28,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/linux.cmake")
|
||||
endif ()
|
||||
|
||||
# Graphics APIs
|
||||
# Include graphics APIs Second time for any platform specific requirements
|
||||
macro(fennec_init_graphics)
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/opengl.cmake")
|
||||
include("${FENNEC_SOURCE_DIR}/cmake/vulkan.cmake")
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
|
||||
# this script contains the main version
|
||||
|
||||
# Fennec Version Definition
|
||||
# These should only get updated whenever a new release occurs
|
||||
set(FENNEC_VERSION_MAJOR 0)
|
||||
set(FENNEC_VERSION_MINOR 1)
|
||||
set(FENNEC_VERSION_PATCH 0)
|
||||
set(FENNEC_VERSION_STRING "${FENNEC_VERSION_MAJOR}.${FENNEC_VERSION_MINOR}.${FENNEC_VERSION_PATCH}")
|
||||
math(EXPR FENNEC_VERSION_NUM "(${FENNEC_VERSION_MAJOR} << 16) | (${FENNEC_VERSION_MINOR} << 8) | ${FENNEC_VERSION_PATCH}")
|
||||
|
||||
# Define the versions for compilation
|
||||
list(APPEND FENNEC_COMPILE_DEFINITIONS
|
||||
FENNEC_VERSION_MAJOR=${FENNEC_VERSION_MAJOR}
|
||||
FENNEC_VERSION_MINOR=${FENNEC_VERSION_MINOR}
|
||||
|
||||
@@ -16,24 +16,41 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
# ======================================================================================================================
|
||||
|
||||
find_package(Vulkan COMPONENTS glslang volk)
|
||||
find_package(Vulkan COMPONENTS glslang)
|
||||
|
||||
# MoltenVK for Apple Products
|
||||
if(FENNEC_GRAPHICS_WANT_MOLTENVK)
|
||||
find_package(Vulkan COMPONENTS MoltenVK)
|
||||
endif()
|
||||
|
||||
if( TARGET Vulkan::Headers AND TARGET Vulkan::volk # Base Headers and Meta-Loader
|
||||
|
||||
# Headers and Loaders
|
||||
if( TARGET Vulkan::Headers # Base Headers and Meta-Loader
|
||||
AND TARGET Vulkan::glslang # GLSL Compilation
|
||||
AND (NOT FENNEC_GRAPHICS_WANT_MOLTENVK OR TARGET Vulkan::MoltenVK)
|
||||
)
|
||||
fennec_add_link_libraries(Vulkan::volk Vulkan::glslang)
|
||||
# Link & Define Vulkan Libraries
|
||||
fennec_add_link_libraries(Vulkan::glslang)
|
||||
fennec_add_definitions(FENNEC_GRAPHICS_VULKAN=1)
|
||||
|
||||
fennec_add_sources(
|
||||
include/fennec/renderers/vulkan/lib/app_info.h
|
||||
include/fennec/renderers/vulkan/lib/instance.h
|
||||
# Cmake Definition for Vulkan detection
|
||||
set(FENNEC_FOUND_VULKAN TRUE)
|
||||
|
||||
include/fennec/renderers/vulkan/vkcontext.h include/fennec/renderers/vulkan/vkcontext.cpp
|
||||
# Add Vulkan Sources
|
||||
fennec_add_sources(
|
||||
include/fennec/renderers/vulkan/lib/forward.h
|
||||
|
||||
include/fennec/renderers/vulkan/lib/app_info.h
|
||||
include/fennec/renderers/vulkan/lib/debug.h
|
||||
include/fennec/renderers/vulkan/lib/enum.h
|
||||
include/fennec/renderers/vulkan/lib/instance.h
|
||||
include/fennec/renderers/vulkan/lib/physical_device.h
|
||||
include/fennec/renderers/vulkan/lib/surface.h
|
||||
|
||||
include/fennec/platform/vulkan/volk/volk.h source/platform/vulkan/volk/volk.c
|
||||
|
||||
include/fennec/renderers/vulkan/vkcontext.h source/renderers/vulkan/vkcontext.cpp
|
||||
include/fennec/renderers/vulkan/vksurface.h source/renderers/vulkan/vksurface.cpp
|
||||
)
|
||||
else()
|
||||
message(WARNING "No Suitable Vulkan implementation found.")
|
||||
|
||||
@@ -70,11 +70,12 @@ macro(fennec_check_wayland)
|
||||
NAMES wayland-egl libwayland-egl
|
||||
)
|
||||
|
||||
|
||||
# Check that we have found everything needed for Wayland
|
||||
if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY AND WAYLAND_SCANNER)
|
||||
AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY))
|
||||
message(STATUS "Found Wayland: ${WAYLAND_CLIENT_LIBRARY}")
|
||||
|
||||
# Wayland Directories
|
||||
set(WAYLAND_PROTOCOLS_DIR ${FENNEC_SOURCE_DIR}/include/fennec/platform/linux/wayland/lib/protocols)
|
||||
set(WAYLAND_HEADERS_DIR ${FENNEC_SOURCE_DIR}/include/fennec/platform/linux/wayland/lib/headers)
|
||||
set(WAYLAND_SOURCES_DIR ${FENNEC_SOURCE_DIR}/source/platform/linux/wayland/lib/sources)
|
||||
@@ -117,7 +118,7 @@ macro(fennec_check_wayland)
|
||||
include/fennec/platform/linux/wayland/lib/loader.h source/platform/linux/wayland/lib/loader.cpp
|
||||
|
||||
# Fennec Files
|
||||
include/fennec/platform/linux/wayland/fwd.h
|
||||
include/fennec/platform/linux/wayland/forward.h
|
||||
include/fennec/platform/linux/wayland/server.h source/platform/linux/wayland/server.cpp
|
||||
include/fennec/platform/linux/wayland/window.h source/platform/linux/wayland/window.cpp
|
||||
|
||||
@@ -126,6 +127,12 @@ macro(fennec_check_wayland)
|
||||
include/fennec/platform/linux/wayland/egl/surface.h source/platform/linux/wayland/egl/surface.cpp
|
||||
)
|
||||
|
||||
if(FENNEC_FOUND_VULKAN)
|
||||
fennec_add_sources(
|
||||
include/fennec/platform/linux/wayland/vulkan/context.h source/platform/linux/wayland/vulkan/context.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
fennec_add_definitions(
|
||||
FENNEC_HAS_WAYLAND=1
|
||||
FENNEC_LIB_WAYLAND="${WAYLAND_CLIENT_LIBRARY}"
|
||||
|
||||
Reference in New Issue
Block a user