Modernize CMake Buildsystem - #10936
Draft
jschmidt-icinga wants to merge 18 commits into
Draft
jschmidt-icinga wants to merge 18 commits into
jschmidt-icinga wants to merge 18 commits into
Conversation
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
14 times, most recently
from
July 14, 2026 15:26
6b21e50 to
0f6b36c
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
4 times, most recently
from
July 23, 2026 08:00
3d8202c to
91bce12
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
2 times, most recently
from
July 23, 2026 10:43
e20a1a9 to
f8aa552
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
3 times, most recently
from
July 28, 2026 09:22
1da63ab to
6ee8b7c
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
from
July 30, 2026 09:58
6ee8b7c to
85c0e33
Compare
jschmidt-icinga
marked this pull request as ready for review
July 30, 2026 09:59
Member
|
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
from
July 31, 2026 14:52
85c0e33 to
0eecda0
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
2 times, most recently
from
August 5, 2026 08:54
20a4186 to
cdeda60
Compare
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
2 times, most recently
from
August 6, 2026 08:45
47bb3ae to
b117c99
Compare
The Boost::thread CMake target depends on it. Actually it's needed only on *suse*:15.*, but can't harm having it on the other GHAs too.
This is required for the CMake unity builds because unlike mkunity it does not guarantee the order that source files are included, which would otherwise require that a source file that includes `i2-base.hpp` comes first, so `win32.hpp`, which set these flags is at the very start of each unity build file. This would otherwise cause syntax errors like `C2589` when C++ constructs like `std::min()` or `std::numeric_limits<T>::max()` are used because `windows.h` without `NOMINMAX` defined will define `min()` and `max()` macros.
We should not have function definitions in CMakeLists.txt.
The old form is deprecated and less clear. Also removes a an old block that used to support old MSVC versions that don't have the override keyword.
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
3 times, most recently
from
September 25, 2026 09:06
02131f3 to
c3d83b5
Compare
Autodetection can still be overridden by setting USE_SYSTEMD:BOOL to `ON` or `OFF` when the build dir is configured.
Most of this wasn't used anywhere except for determining atomics support. There was even a (severely broken) `check_cxx_source_compiles` snippet already in place, which is what you are supposed to do to detect if atomics support requires a library independently of the processor architecture. This fixes the snippet and uses it for a proper check to determine support, with and without library.
This effectively removes manual treatment for the AIX/OpenBSD/SunPro etc. systems. At least on OpenBSD it has been verified that CMake just does this correctly. On the other system we'll be relying on the same thing, only that it remains untested for now (I'm not sure anyone ever tested the original code on these systems either).
Some options don't fit into presets, because they're required to build the project. There's also a few linker flags we just set without explanation.
Most lib/* targets don't actually depend on other lib/* targets, they depend on their generated files. If that dependency is expressed correctly, it turns out all those targets can easily be built in parallel.
CMake 3.31 onwards support this natively, but since it isn't much additional work, I also added a custom target for use on lower CMake versions.
I would have prefered to use presets here right away, but since Debian 11 is still on CMake 3.18, with presets being introduced in 3.19, it makes no sense to use them for everything but Debian 11 at this point. We can still migrate to presets once Debian 11 is removed. TODO: Disable unity builds on a single target like on master
jschmidt-icinga
force-pushed
the
modernize-cmake
branch
2 times, most recently
from
October 1, 2026 14:05
1fbfd56 to
e243dd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This modernizes several aspects of our build-system.
Features
mkclassnow operates directly on the library targets and.tifiles are now added to targets directly instead of the generated-ti.hppheaders.remotedoesn't have to wait forbaseetc.). Prior to this PR this made unity builds actually slow down the build in some cases, whereas now they are always faster for fresh builds (See the build time measurements below).codegentarget now works and includes all generated files, which allows to generate all code needed to build the project, but without actually building anything (exceptmkclass). This is a prerequisite for checking the source tree withclang-tidyor other linters and static analyzers in their own GHAs.cmake --list-presetsand set up a build dir with for examplecmake --preset debug-clang-ninja.binaryDir(<src>/build), so it will overwrite an existing build directory everytime the preset is switched. To set different build dirs, just add-B <dir>after--preset <foo>.CMAKE_C_FLAGS/CMAKE_CXX_FLAGSnot immediately required to build correctly are moved out of the CMakeLists.txt and into the presets. This includes all warnings and optimization flags, which should be left for the user to decide on.CFLAGS/CXXFLAGSor CMake variables at configure time. This works additively with the flags set in the presets for maximum flexibility.USE_SYSTEMD:BOOLtoONwill stillREQUIREsystemd to be present and toOFFwill still disable systemd support even if it's present.Build times
I've measured the build times between master and this PR, both with and without Unity builds turned on:
You can see that the new unity builds in combination with the generated header targets scale a lot better with the number of jobs.
Caveats and Future Considerations
There's still a couple things left over after this PR:
install()-related commands and variables.CMAKE_CROSSCOMPILING_EMULATORsomkclassand test discovery can run, but I didn't test this yet.lib/baseandlib/configwhich should be resolved long-term, most likely by further splitting up both of these modules and abstracting out common dependencies.Testing
I've tested this on my own system with a variety of configurations (essentially the CMake Presets provided). Also I've tested on FreeBSD and OpenBSD systems to verify the additional find modules I've added.
Closes #10404, closes #10777.