Fix the issues found while reviewing the build files

Install the Wayland development packages in both workflows and bundle the
runtime libraries in the AppImage: the release build had no native Wayland
backend at all, and the engine silently fell back to GLFW there.

Build the window backends on every platform that is not Windows and not
Apple, glob the wayland sources with CONFIGURE_DEPENDS, and report a
missing Wayland dependency with the list of what is missing.

Also drop the dead nested project() calls and the duplicate -no-pie
option, make .dirIcon the file appimagetool expects, and describe the
real Linux dependencies in the README.
This commit is contained in:
alexei-zebra 2026-10-11 20:06:19 +03:00
parent 3a574ade8c
commit b6f6235249
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
10 changed files with 46 additions and 26 deletions

View file

@ -31,7 +31,8 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y build-essential libglfw3-dev libglfw3 libglew-dev libglew2.2 \ sudo apt-get install -y build-essential libglfw3-dev libglfw3 libglew-dev libglew2.2 \
libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev \ libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev \
libcurl4-openssl-dev libssl-dev libgtest-dev libfreetype6-dev cmake squashfs-tools valgrind libcurl4-openssl-dev libssl-dev libgtest-dev libfreetype6-dev cmake squashfs-tools valgrind \
libwayland-dev libxkbcommon-dev libegl1-mesa-dev libsystemd-dev
# fix luajit paths # fix luajit paths
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua sudo ln -s /usr/include/luajit-2.1 /usr/include/lua

View file

@ -39,7 +39,8 @@ jobs:
# make && make install INSTALL_INC=/usr/include/lua # make && make install INSTALL_INC=/usr/include/lua
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libgtest-dev libcurl4-openssl-dev libssl-dev libfreetype6-dev # the Wayland backend is on by default on Linux (VOXELCORE_WAYLAND)
sudo apt-get install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libgtest-dev libcurl4-openssl-dev libssl-dev libfreetype6-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libsystemd-dev
# fix luajit paths # fix luajit paths
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua-5.1.a sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua-5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua sudo ln -s /usr/include/luajit-2.1 /usr/include/lua

3
.gitignore vendored
View file

@ -1,8 +1,6 @@
Debug/src/**/*.d Debug/src/**/*.d
Debug/src/**/*.o Debug/src/**/*.o
Debug/voxel_engine
/build /build
/cmake-build-** /cmake-build-**
/screenshots /screenshots
@ -36,6 +34,7 @@ Debug/voxel_engine
/Default/ /Default/
AppDir AppDir
appimage-build/ appimage-build/
*.AppImage*
# macOS folder attributes # macOS folder attributes
*.DS_Store *.DS_Store

View file

@ -5,8 +5,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
execute_process(COMMAND ${CMAKE_COMMAND} --version)
option(VOXELENGINE_BUILD_APPDIR "Pack linux build" OFF) option(VOXELENGINE_BUILD_APPDIR "Pack linux build" OFF)
option(VOXELENGINE_BUILD_TESTS "Build tests" OFF) option(VOXELENGINE_BUILD_TESTS "Build tests" OFF)
@ -36,8 +34,6 @@ endif()
target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc
$<$<PLATFORM_ID:Windows>:winmm>) $<$<PLATFORM_ID:Windows>:winmm>)
target_link_options(VoxelCore PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
# Deploy res to build dir # Deploy res to build dir
add_custom_command( add_custom_command(
TARGET VoxelCore TARGET VoxelCore

View file

@ -27,7 +27,7 @@ sudo make install
```sh ```sh
su - su -
apt-get install libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel libssl-devel apt-get install entt-devel libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel libssl-devel
``` ```
#### Debian based distros #### Debian based distros
@ -58,9 +58,12 @@ sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2 opens
#### Wayland #### Wayland
On Linux the engine draws the window frame itself and needs `wayland-client`, On Linux the engine draws the window frame itself and needs `libwayland-dev`
`wayland-egl`, `wayland-scanner`, `wayland-protocols`, `libxkbcommon` and EGL. (with `libwayland-bin` for `wayland-scanner`), `libxkbcommon-dev` and
Build with `-DVOXELCORE_WAYLAND=OFF` to fall back to GLFW. `libegl-dev`. The protocol XML descriptions are vendored in
`src/window/wayland/protocols`, so the `wayland-protocols` package is not used.
`libsystemd-dev` is optional and adds the window button layout read through
sd-bus. Build with `-DVOXELCORE_WAYLAND=OFF` to fall back to GLFW.
### Building engine with CMake ### Building engine with CMake

View file

@ -32,6 +32,10 @@ AppDir:
- libvorbisfile3 - libvorbisfile3
- libluajit-5.1-2 - libluajit-5.1-2
- libfreetype6 - libfreetype6
- libwayland-client0
- libwayland-cursor0
- libwayland-egl1
- libxkbcommon0
exclude: exclude:
- hicolor-icon-theme - hicolor-icon-theme
- sound-theme-freedesktop - sound-theme-freedesktop

View file

@ -6,7 +6,10 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/VoxelCore)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/VoxelCore) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/VoxelCore)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/icons/hicolor/256x256) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/icons/hicolor/256x256)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/.dirIcon) # .dirIcon is the icon of the AppDir itself and has to be a file, not a directory
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/.dirIcon)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.png
${CMAKE_CURRENT_SOURCE_DIR}/AppDir/.dirIcon COPYONLY)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/applications) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/applications)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)

View file

@ -116,10 +116,10 @@ set(VOXEL_COMPILE_OPTIONS
-Wduplicated-cond -Wduplicated-cond
>) >)
# Everything the engine sources and their public headers include: the backends # The include directory and the window/render dependencies shared by the engine
# compile against the same surface, and a missing include directory shows up as # and the window backends: glfw, GLEW, OpenGL and glm. The remaining engine
# a build failure only on the platforms that keep the library outside the # dependencies (luajit, EnTT, OpenAL, zlib and others) are linked to VoxelCoreSrc
# default include path. # only, even though the public headers pull them in.
add_library(VoxelCoreInterface INTERFACE) add_library(VoxelCoreInterface INTERFACE)
target_include_directories(VoxelCoreInterface INTERFACE target_include_directories(VoxelCoreInterface INTERFACE

View file

@ -1,5 +1,3 @@
project(VoxelWindowBackends)
# Input state shared by the window backends. # Input state shared by the window backends.
add_library(VoxelWindowBase STATIC BaseInput.cpp) add_library(VoxelWindowBase STATIC BaseInput.cpp)
@ -17,7 +15,7 @@ target_link_libraries(
# On X11 the window manager moves and resizes the window when the engine draws # On X11 the window manager moves and resizes the window when the engine draws
# the frame. A wayland-only build of GLFW does not answer, and the frame then # the frame. A wayland-only build of GLFW does not answer, and the frame then
# falls back to moving the window itself. # falls back to moving the window itself.
if(UNIX AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
find_package(X11) find_package(X11)
if(X11_FOUND) if(X11_FOUND)
target_compile_definitions(VoxelGLFW PRIVATE VOXEL_X11_FRAME=1) target_compile_definitions(VoxelGLFW PRIVATE VOXEL_X11_FRAME=1)

View file

@ -1,5 +1,3 @@
project(VoxelWayland)
# The library is linked from the parent directory, so the imported targets of # The library is linked from the parent directory, so the imported targets of
# its dependencies have to be visible outside of this directory too. # its dependencies have to be visible outside of this directory too.
function(voxel_wayland_pkg_config MODULE) function(voxel_wayland_pkg_config MODULE)
@ -32,9 +30,25 @@ function(voxel_add_wayland_backend)
find_library(WAYLAND_EGL_LIBRARY NAMES wayland-egl libwayland-egl.so.1) find_library(WAYLAND_EGL_LIBRARY NAMES wayland-egl libwayland-egl.so.1)
find_program(WAYLAND_SCANNER wayland-scanner) find_program(WAYLAND_SCANNER wayland-scanner)
if(NOT wayland-client_FOUND OR NOT xkbcommon_FOUND OR NOT egl_FOUND set(wayland_missing)
OR NOT WAYLAND_EGL_LIBRARY OR NOT WAYLAND_SCANNER) if(NOT wayland-client_FOUND)
message(STATUS "Wayland backend is off: dependencies are not found") list(APPEND wayland_missing wayland-client)
endif()
if(NOT xkbcommon_FOUND)
list(APPEND wayland_missing xkbcommon)
endif()
if(NOT egl_FOUND)
list(APPEND wayland_missing egl)
endif()
if(NOT WAYLAND_EGL_LIBRARY)
list(APPEND wayland_missing wayland-egl)
endif()
if(NOT WAYLAND_SCANNER)
list(APPEND wayland_missing wayland-scanner)
endif()
if(wayland_missing)
list(JOIN wayland_missing ", " wayland_missing)
message(WARNING "Wayland backend is off: not found: ${wayland_missing}")
return() return()
endif() endif()
@ -56,7 +70,8 @@ function(voxel_add_wayland_backend)
# tablet is referenced by cursor-shape-v1 # tablet is referenced by cursor-shape-v1
voxel_wayland_protocol(tablet-unstable-v2.xml tablet-unstable-v2) voxel_wayland_protocol(tablet-unstable-v2.xml tablet-unstable-v2)
file(GLOB wayland_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) file(GLOB wayland_sources CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_library(VoxelWayland STATIC ${wayland_sources} ${WAYLAND_SOURCES}) add_library(VoxelWayland STATIC ${wayland_sources} ${WAYLAND_SOURCES})