Skip to content

Conversation

@mhucka
Copy link
Collaborator

@mhucka mhucka commented Jan 20, 2026

Previously, the CMakeLists.txt files added -flto to some of the compilation targets unconditionally. The addition should only be done if the compiler supports LTO, and it shouldn't be done if the cmake configuration is the debug configuration.

This PR moves the detection of availability of LTO to the top-level CMakeLists.txt file, and defines a CMake macro to set it in the sub-CMakeLists.txt files. The macro avoids repeating some gnarly CMake syntax all over the place.

Previously, the CMakeLists.txt files added `-flto` to some of the
compilation targets unconditionally. The addition should only be done if
the compiler supports LTO, and it shouldn't be done if the cmake
configuration is the debug configuration.
@github-actions github-actions bot added the size: S 10< lines changed <50 label Jan 20, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refactors the CMake build configuration to conditionally enable Link-Time Optimization (LTO). It introduces a check for LTO support and uses the INTERPROCEDURAL_OPTIMIZATION property, which is correctly disabled for debug builds. This is a good improvement for build robustness and developer experience. My main feedback is about code duplication introduced across the various CMakeLists.txt files for different CPU architectures. I've suggested a refactoring to abstract this logic into a reusable function to improve maintainability, in line with the project's style guide.

@mhucka mhucka changed the title Set LTO option only if not using debug config Set LTO option only if it's supported and the build is not a debug build Jan 20, 2026
The CMake files now check if OpenMP can be used. The Makefiles should too.
@github-actions github-actions bot added size: M 50< lines changed <250 and removed size: S 10< lines changed <50 labels Jan 20, 2026
@github-actions github-actions bot added size: S 10< lines changed <50 and removed size: M 50< lines changed <250 labels Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant