- More implementations and dependencies for Linux Wayland support

This commit is contained in:
2025-07-26 20:57:25 -04:00
parent 7ea2710ee0
commit 7493b5252a
78 changed files with 3733 additions and 316 deletions

View File

@@ -16,6 +16,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script handles functionality related to the build process and its info
string(TOLOWER ${CMAKE_BUILD_TYPE} FENNEC_BUILD_NAME)
message(STATUS "Build: ${FENNEC_BUILD_NAME}")

View File

@@ -16,6 +16,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script finds the compiler being used
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
set(FENNEC_COMPILER "GCC")
include("${FENNEC_SOURCE_DIR}/cmake/gcc.cmake")

35
cmake/default_user.cmake Normal file
View File

@@ -0,0 +1,35 @@
# ======================================================================================================================
# fennec, a free and open source game engine
# Copyright © 2025 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/>.
# ======================================================================================================================
# sets up cmake variables for client vs server
if(FENNEC_USER_CLIENT)
set(FENNEC_USER_CLIENT 1)
set(FENNEC_USER_SERVER 0)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_USER_CLIENT=1)
elseif(FENNEC_USER_SERVER)
set(FENNEC_USER_CLIENT 0)
set(FENNEC_USER_SERVER 1)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_USER_SERVER=1)
else()
set(FENNEC_USER_CLIENT 1)
set(FENNEC_USER_SERVER 0)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_USER_CLIENT=1)
endif()

View File

@@ -16,8 +16,10 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script sets flags and variables for gnu and gnu-like compilers
add_compile_options("-mxsave" "-Wall" "-Wextra" "-pedantic" "-Werror")
set(FENNEC_PRIVATE_LINK_OPTIONS "-nostdlib" "-fno-exceptions" "-fno-rtti" "-fdiagnostics-all-candidates")
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_COMPILER_GCC=1)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_COMPILER_GCC=1 FENNEC_NO_INLINE=[[gnu::noinline]])

View File

@@ -16,6 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script finds and loads libraries related to the Linux operating system. It also sets platform specific variables.
macro(fennec_check_platform)
# unix
@@ -32,9 +33,10 @@ macro(fennec_check_platform)
include/fennec/platform/linux/platform.h source/platform/linux/platform.cpp
)
# includes
include("${FENNEC_SOURCE_DIR}/cmake/wayland.cmake")
if(FENNEC_USER_CLIENT)
include("${FENNEC_SOURCE_DIR}/cmake/wayland.cmake")
fennec_check_wayland()
endif()
# tests
fennec_check_wayland()
endmacro()

48
cmake/opengl.cmake Normal file
View File

@@ -0,0 +1,48 @@
# ======================================================================================================================
# fennec, a free and open source game engine
# Copyright © 2025 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/>.
# ======================================================================================================================
find_package(OpenGL)
if(TARGET OpenGL::GL) # Core OpenGL Desktop Profile
list(APPEND FENNEC_LINK_LIBRARIES OpenGL::OpenGL)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_OPENGL=1)
elseif(TARGET OpenGL::GLES3) # OpenGL for Embedded Systems 3
list(APPEND FENNEC_LINK_LIBRARIES OpenGL::GLES3)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_GLES3=1)
elseif (TARGET OpenGL::GLES2) # OpenGL for Embedded Systems 2
list(APPEND FENNEC_LINK_LIBRARIES OpenGL::GLES2)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_GLES2=1)
else()
message(FATAL_ERROR "No Suitable OpenGL implementation found.")
endif()
if(FENNEC_GRAPHICS_WANT_EGL)
if(NOT TARGET OpenGL::EGL)
message(FATAL_ERROR "EGL Library not found.")
endif()
list(APPEND FENNEC_LINK_LIBRARIES OpenGL::EGL)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_EGL=1)
list(APPEND FENNEC_EXTRA_SOURCES
include/fennec/platform/opengl/egl/context.h
include/fennec/platform/opengl/egl/surface.h
)
endif()

View File

@@ -16,10 +16,19 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script finds the operating system of the build environment
message(STATUS "OS: ${CMAKE_SYSTEM_NAME}")
include("${FENNEC_SOURCE_DIR}/cmake/default_user.cmake")
# Check for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(FENNEC_PLATFORM "Linux")
include("${FENNEC_SOURCE_DIR}/cmake/linux.cmake")
endif ()
endif ()
# Graphics APIs
if(FENNEC_USER_CLIENT)
include("${FENNEC_SOURCE_DIR}/cmake/opengl.cmake")
endif()

View File

@@ -16,6 +16,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# generic unix functionality
# compile definitions
list(APPEND FENNEC_COMPILE_DEFINITIONS
FENNEC_PLATFORM_UNIX=1

33
cmake/version.cmake Normal file
View File

@@ -0,0 +1,33 @@
# ======================================================================================================================
# fennec, a free and open source game engine
# Copyright © 2025 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 contains the main version
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}")
list(APPEND FENNEC_COMPILE_DEFINITIONS
FENNEC_VERSION_MAJOR=${FENNEC_VERSION_MAJOR}
FENNEC_VERSION_MINOR=${FENNEC_VERSION_MINOR}
FENNEC_VERSION_PATCH=${FENNEC_VERSION_PATCH}
FENNEC_VERSION_STRING=${FENNEC_VERSION_STRING}
FENNEC_VERSION_NUM=${FENNEC_VERSION_NUM}
)

View File

@@ -17,6 +17,7 @@
# ======================================================================================================================
# https://gist.github.com/mariobadr/acc3c8adf4b4e722705be38c3deac59a
# this script finds libwayland and dependencies
macro(fennec_check_wayland)
set(WAYLAND_CLIENT_FOUND 0)
@@ -25,39 +26,55 @@ macro(fennec_check_wayland)
WAYLAND_CLIENT_INCLUDE_DIR
NAMES wayland-client.h
)
find_library(
WAYLAND_CLIENT_LIBRARY
NAMES wayland-client libwayland-client
)
get_filename_component(
WAYLAND_CLIENT_LIBRARY
${WAYLAND_CLIENT_LIBRARY}
NAME
# EGL is required
find_path(
WAYLAND_EGL_INCLUDE_DIR
NAMES wayland-egl.h
)
find_library(
WAYLAND_EGL_LIBRARY
NAMES wayland-egl libwayland-egl
)
if(WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY)
set(WAYLAND_CLIENT_FOUND 1)
add_library(wayland::client UNKNOWN IMPORTED)
set_target_properties(
wayland::client PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_CLIENT_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${WAYLAND_CLIENT_LIBRARY}"
if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY)
AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY))
get_filename_component(
WAYLAND_CLIENT_LIBRARY
${WAYLAND_CLIENT_LIBRARY}
NAME
)
get_filename_component(
WAYLAND_EGL_LIBRARY
${WAYLAND_EGL_LIBRARY}
NAME
)
set(WAYLAND_CLIENT_FOUND 1)
set(WAYLAND_EGL_FOUND 1)
set(FENNEC_GRAPHICS_WANT_EGL 1)
list(APPEND FENNEC_EXTRA_SOURCES
# Dynamic Library Files
include/fennec/platform/linux/wayland/lib/fwd.h
include/fennec/platform/linux/wayland/lib/sym.h
include/fennec/platform/linux/wayland/lib/sym_def.h
include/fennec/platform/linux/wayland/lib/wayland-client.h
include/fennec/platform/linux/wayland/lib/wayland-util.h
include/fennec/platform/linux/wayland/lib/dyn.h source/platform/linux/wayland/lib/dyn.cpp
# Fennec Files
include/fennec/platform/linux/wayland/display.h source/platform/linux/wayland/display.cpp
include/fennec/platform/linux/wayland/displaydev.h source/platform/linux/wayland/displaydev.cpp
include/fennec/platform/linux/wayland/window.h source/platform/linux/wayland/window.cpp
)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_LIB_WAYLAND="${WAYLAND_CLIENT_LIBRARY}")
list(APPEND FENNEC_COMPILE_DEFINITIONS
FENNEC_HAS_WAYLAND=1
FENNEC_LIB_WAYLAND="${WAYLAND_CLIENT_LIBRARY}"
FENNEC_LIB_WAYLAND_EGL="${WAYLAND_EGL_LIBRARY}"
)
endif()
endmacro()