Skip to content

Implement CMake build scripts and github actions.#114

Open
iSLC wants to merge 3 commits intoproject-valhalla:mainfrom
iSLC:main
Open

Implement CMake build scripts and github actions.#114
iSLC wants to merge 3 commits intoproject-valhalla:mainfrom
iSLC:main

Conversation

@iSLC
Copy link
Copy Markdown

@iSLC iSLC commented Jan 2, 2026

Only Windows and Linux for now.
Builds dependencies and links statically against them.
Minimally intrusive approach. Only adds a few files and submodules.
Uploads resulted binaries of each run so they can be downloaded by anyone. Like nightly builds (without the data).

iSLC added 2 commits January 2, 2026 17:41
Only Windows and Linux for now.
Builds dependencies and links statically against them.
Minimally intrusive approach. Only adds a few files and submodules.
@garsipal
Copy link
Copy Markdown
Member

garsipal commented Jan 9, 2026

Appreciate it, I'll look into this in a while as I'm working on multiple things 👍

Fix some compiler flags not being applied on Linux.
@garsipal garsipal added the QoL Feels good label Jan 12, 2026
@user1-github
Copy link
Copy Markdown
Contributor

user1-github commented Feb 25, 2026

Just wanted to leave my opinion here:

I think if the devs will want to switch away from the current makefile to your cmake setup exclusively, it would be nice to also have an option to dynamically link libraries (at least on Linux).

Statically linking them means the library version is fixed with the game version, so you won't be able to update it in case that library version has a bug.

It's especially beneficial for SDL libraries, which constantly receive improvements on Linux. For example, many Linux distros now ship sdl2-compat instead of SDL2 which runs on top of SDL3 that is constantly receiving improvements in areas like native Wayland integration (the modern Linux windowing system).

Also, the makefile sets the following buildflags:
-O3 -fomit-frame-pointer -ffast-math -Wall -Wimplicit-fallthrough -fsigned-char -fno-exceptions -fno-rtti
(see Line 1 and 2 in the makefile).
It's probably a good idea to add them to the cmake setup, as these are more aggressive optimizations than the flags many environments default to, so the game should perform better with these flags. Though I heard combining -ffast-math with LTO will probably cause problems.

@iSLC
Copy link
Copy Markdown
Author

iSLC commented Feb 26, 2026

@user1-github makes perfect sense. I'll see if I can work on something like that as soon as I get some time. Also, I don't think anyone needs to give up on the make file build script. This can be just an alternative since it integrates well with the github actions and code editors like VS Code through extensions.

Which is the main reason I made it. I just open the folder with VS Code, the extension picks up the build scripts, I select the compiler I want to build with, and what I want to build from the script. And that's it. You're set to build for release or start to add breakpoints and debug code.

Also, the flags are added. See:

Line 333 in CMakeLists.txt file.

# GNU compatible options
if (MSYS OR MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    target_compile_options(Client PRIVATE -Wimplicit-fallthrough -fsigned-char -fno-exceptions -fno-rtti)
    if(CMAKE_BUILD_TYPE STREQUAL "Release")
        target_compile_options(Client PRIVATE -fomit-frame-pointer -ffast-math)
    endif()
endif()

Line 466 (identic but for server)
Line 571 (identic but for master)

And the warnings are handled by a separate helper script from cmake/Warnings.cmake. But with a few warnings disabled because output becomes too verbose on the more recent compiler versions.

# CMake scripts extensions
# Helper that can set default warning flags for you
if(NOT MSVC)
    target_set_warnings(Client ENABLE ALL DISABLE Annoying extra pedantic unused ignored-qualifiers cast-function-type)
else()
    target_set_warnings(Client DISABLE ALL) # MSVC has a lot to say about this code. let's ignore it
endif()

Repeat for server,master etc.

@user1-github
Copy link
Copy Markdown
Contributor

Yeah, I probably just missed the flags while looking at CMakeLists.txt.

If you'll decide to add a dynamic linking setup, Blue Nebula (a Cube 2 engine based game) already has a setup for detecting the SDL2 libraries, so it might help you.

@garsipal garsipal added the pending review Something that is being considered, investigated or put on hold label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending review Something that is being considered, investigated or put on hold QoL Feels good

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants