Skip to content

Remove old CMake code about gcc version check for -frounding-math (#6923 )#9356

Open
RajdeepKushwaha5 wants to merge 2 commits intoCGAL:mainfrom
RajdeepKushwaha5:fix/cmake-gcc-frounding-math-dead-code
Open

Remove old CMake code about gcc version check for -frounding-math (#6923 )#9356
RajdeepKushwaha5 wants to merge 2 commits intoCGAL:mainfrom
RajdeepKushwaha5:fix/cmake-gcc-frounding-math-dead-code

Conversation

@RajdeepKushwaha5
Copy link
Contributor

Root Cause:
Installation/CMakeLists.txt contained a dead code block that attempted to add -frounding-math for GCC using:

if("${GCC_VERSION}" MATCHES "^[4-9].")
  message(STATUS "Using gcc version 4 (or greater). Adding -frounding-math")
  uniquely_add_flags(CGAL_CXX_FLAGS "-frounding-math")
endif()

The regex ^[4-9]. only matches single-digit GCC major versions (4-9). GCC 10, 11, 12, 13, 14, etc. do NOT match, so the flag was silently never added via this path for any modern GCC.

Furthermore, this code is entirely redundant: the correct mechanism is in Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake, which uses:

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3)
  target_compile_options(target INTERFACE "-frounding-math")
endif()

This correctly handles all GCC 4+ via CMake's modern target_compile_options interface mechanism.

Fix:
Removed the 4-line dead block from Installation/CMakeLists.txt.

Files changed:

  • Installation/CMakeLists.txt - removed 5 lines (4 code + 1 blank)

…6923)

The regex "${GCC_VERSION}" MATCHES "^[4-9]." only matches
single-digit GCC major versions (4 through 9), silently failing
for GCC 10 and later. The flag was therefore never added for any
modern GCC version via this code path.

This code is also redundant: CGAL_SetupCGALDependencies.cmake
already adds -frounding-math correctly using
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3 via
target_compile_options() on the CGAL interface target, which
is the authoritative mechanism for this flag.
Copilot AI review requested due to automatic review settings March 1, 2026 19:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes a redundant/incorrect GCC-version regex block from Installation/CMakeLists.txt that attempted to add -frounding-math, relying instead on the existing target-based mechanism that handles compiler versions correctly.

Changes:

  • Removed the legacy GCC version regex check that added -frounding-math via CGAL_CXX_FLAGS.
  • Eliminated an outdated status message and the associated dead code path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lrineau lrineau self-requested a review March 1, 2026 20:01
@lrineau
Copy link
Member

lrineau commented Mar 1, 2026

A lot of code around those lines should be removed: obsolete and unused. I will try to review that.

@lrineau lrineau added the Not yet approved The feature or pull-request has not yet been approved. label Mar 1, 2026
@RajdeepKushwaha5
Copy link
Contributor Author

A lot of code around those lines should be removed: obsolete and unused. I will try to review that.

Thanks for the note! I'd be happy to expand this PR to also remove the SunPro, Intel Classic (icl/icpc), and Alpha architecture dead code blocks if that would help. Alternatively, I can keep this PR focused on the -frounding-math dead code and you can handle the broader cleanup separately — whatever you prefer.

@lrineau
Copy link
Member

lrineau commented Mar 1, 2026

If I remember well, all that code was indeed moved to cmake/modules/CGAL_SetupCGALDependencies.cmake. Please make sure it is the case.

All compiler flag logic for MSVC, SunPro, Intel Classic (icl/icpc), and
GCC was already migrated to the modern target-based mechanism in
Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake, which uses
target_compile_options()/target_link_libraries() INTERFACE. The old
blocks used uniquely_add_flags(CGAL_CXX_FLAGS ...) which is the
obsolete global-variable approach.

Removed dead blocks:
- MSVC: /fp:strict, /fp:except-, /bigobj, _SCL_SECURE_NO_DEPRECATE,
  CMAKE_CXX_WARNING_LEVEL (all superseded by target_compile_options in
  CGAL_setup_CGAL_flags())
- SunPro: -features=extensions, -library=stlport4, -D_GNU_SOURCE,
  linker flags (superseded by target_compile_options +
  target_link_libraries in CGAL_setup_CGAL_flags())
- Intel Classic (icl/icpc): /fp:strict / -fp-model=strict, version
  check for < 11.0 (superseded; Intel < 11.0 from 2008 cannot support
  the C++17 that CGAL now requires)
- GCC: -Wall for test suite, -frounding-math regex check, -g stripping
  from CMAKE_CXX_FLAGS, -mieee -mfp-rounding-mode=d for alpha
  (all superseded by target_compile_options in CGAL_setup_CGAL_flags())

The entire empty FLAGS section header is also removed.

Closes CGAL#6923
@afabri afabri added Ready to be tested and removed Not yet approved The feature or pull-request has not yet been approved. labels Mar 8, 2026
@afabri afabri added this to the 6.2-beta milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants