From b6f6235249d92beed3d11c31a1d0184aec8775cf Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Sun, 11 Oct 2026 20:06:19 +0300 Subject: [PATCH] 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. --- .github/workflows/appimage.yml | 3 ++- .github/workflows/cmake.yml | 3 ++- .gitignore | 3 +-- CMakeLists.txt | 4 ---- README.md | 11 +++++++---- dev/AppImageBuilder.yml | 4 ++++ dev/cmake/BuildAppdir.cmake | 5 ++++- src/CMakeLists.txt | 8 ++++---- src/window/detail/CMakeLists.txt | 4 +--- src/window/wayland/CMakeLists.txt | 27 +++++++++++++++++++++------ 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 7b53b3fbf..4955f1bdc 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -31,7 +31,8 @@ jobs: sudo apt-get update 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 \ - 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 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 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6956a1f3d..f9a55c816 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -39,7 +39,8 @@ jobs: # make && make install INSTALL_INC=/usr/include/lua run: | 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 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 diff --git a/.gitignore b/.gitignore index 4d0155832..0fc04afdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ Debug/src/**/*.d Debug/src/**/*.o -Debug/voxel_engine - /build /cmake-build-** /screenshots @@ -36,6 +34,7 @@ Debug/voxel_engine /Default/ AppDir appimage-build/ +*.AppImage* # macOS folder attributes *.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index a9ac24a1d..a91c908cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -execute_process(COMMAND ${CMAKE_COMMAND} --version) - option(VOXELENGINE_BUILD_APPDIR "Pack linux build" OFF) option(VOXELENGINE_BUILD_TESTS "Build tests" OFF) @@ -36,8 +34,6 @@ endif() target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc $<$:winmm>) -target_link_options(VoxelCore PRIVATE $<$:-no-pie>) - # Deploy res to build dir add_custom_command( TARGET VoxelCore diff --git a/README.md b/README.md index 41fcad58e..d45cdaef2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ sudo make install ```sh 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 @@ -58,9 +58,12 @@ sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2 opens #### Wayland -On Linux the engine draws the window frame itself and needs `wayland-client`, -`wayland-egl`, `wayland-scanner`, `wayland-protocols`, `libxkbcommon` and EGL. -Build with `-DVOXELCORE_WAYLAND=OFF` to fall back to GLFW. +On Linux the engine draws the window frame itself and needs `libwayland-dev` +(with `libwayland-bin` for `wayland-scanner`), `libxkbcommon-dev` and +`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 diff --git a/dev/AppImageBuilder.yml b/dev/AppImageBuilder.yml index bed1dde47..79d2d29dc 100644 --- a/dev/AppImageBuilder.yml +++ b/dev/AppImageBuilder.yml @@ -32,6 +32,10 @@ AppDir: - libvorbisfile3 - libluajit-5.1-2 - libfreetype6 + - libwayland-client0 + - libwayland-cursor0 + - libwayland-egl1 + - libxkbcommon0 exclude: - hicolor-icon-theme - sound-theme-freedesktop diff --git a/dev/cmake/BuildAppdir.cmake b/dev/cmake/BuildAppdir.cmake index 7445d1016..b1016252a 100644 --- a/dev/cmake/BuildAppdir.cmake +++ b/dev/cmake/BuildAppdir.cmake @@ -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}/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/.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/) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02a974cc1..4a3317b8d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,10 +116,10 @@ set(VOXEL_COMPILE_OPTIONS -Wduplicated-cond >) -# Everything the engine sources and their public headers include: the backends -# compile against the same surface, and a missing include directory shows up as -# a build failure only on the platforms that keep the library outside the -# default include path. +# The include directory and the window/render dependencies shared by the engine +# and the window backends: glfw, GLEW, OpenGL and glm. The remaining engine +# dependencies (luajit, EnTT, OpenAL, zlib and others) are linked to VoxelCoreSrc +# only, even though the public headers pull them in. add_library(VoxelCoreInterface INTERFACE) target_include_directories(VoxelCoreInterface INTERFACE diff --git a/src/window/detail/CMakeLists.txt b/src/window/detail/CMakeLists.txt index a309ad51a..de716ca02 100644 --- a/src/window/detail/CMakeLists.txt +++ b/src/window/detail/CMakeLists.txt @@ -1,5 +1,3 @@ -project(VoxelWindowBackends) - # Input state shared by the window backends. 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 # the frame. A wayland-only build of GLFW does not answer, and the frame then # falls back to moving the window itself. -if(UNIX AND NOT APPLE) +if(NOT WIN32 AND NOT APPLE) find_package(X11) if(X11_FOUND) target_compile_definitions(VoxelGLFW PRIVATE VOXEL_X11_FRAME=1) diff --git a/src/window/wayland/CMakeLists.txt b/src/window/wayland/CMakeLists.txt index fe8a7b810..1ebbb7933 100644 --- a/src/window/wayland/CMakeLists.txt +++ b/src/window/wayland/CMakeLists.txt @@ -1,5 +1,3 @@ -project(VoxelWayland) - # The library is linked from the parent directory, so the imported targets of # its dependencies have to be visible outside of this directory too. 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_program(WAYLAND_SCANNER wayland-scanner) - if(NOT wayland-client_FOUND OR NOT xkbcommon_FOUND OR NOT egl_FOUND - OR NOT WAYLAND_EGL_LIBRARY OR NOT WAYLAND_SCANNER) - message(STATUS "Wayland backend is off: dependencies are not found") + set(wayland_missing) + if(NOT wayland-client_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() endif() @@ -56,7 +70,8 @@ function(voxel_add_wayland_backend) # tablet is referenced by cursor-shape-v1 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})