Skip to content

Replace deprecated CMAKE_COMPILER_IS_GNU(CC|CXX) with CMAKE_(C|CXX)_COMPILER_ID #4056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 10.6
Choose a base branch
from

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented May 22, 2025

Description

Replace deprecated use of CMAKE_COMPILER_IS_GNU(CC|CXX) with CMAKE_(C|CXX)COMPILER_ID
throughout the tree. Some places already use CMAKE
(C|CXX)_COMPILER_ID.

As of CMake 3.24 CMAKE_COMPILER_IS_GNU(CC|CXX) are deprecated and should be replaced with
CMAKE_(C|CXX)_COMPILER_ID which were introduced with CMake 2.6.

How can this PR be tested?

Build and check the various paths are taken as appropriate.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@brad0 brad0 force-pushed the 10.6_cmake_compiler branch from 2ca81ac to 3c6209d Compare May 22, 2025 02:03
@brad0
Copy link
Contributor Author

brad0 commented May 22, 2025

cc @grooverdan

…OMPILER_ID

As of CMake 3.24 CMAKE_COMPILER_IS_GNU(CC|CXX) are deprecated and should
be replaced with CMAKE_(C|CXX)_COMPILER_ID which were introduced with
CMake 2.6.
@brad0 brad0 force-pushed the 10.6_cmake_compiler branch from 3c6209d to 7a4af63 Compare May 22, 2025 06:07
@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label May 22, 2025
@svoj
Copy link
Contributor

svoj commented May 22, 2025

@brad0 thanks for updating your patch. There is no need to create new PR. You can force update original branch and change target version. It is better to keep discussion in one place.

@vaintroub
Copy link
Member

vaintroub commented May 22, 2025

You are aware that CMAKE_COMPILER_IS_GNU(CC|CXX) and CMAKE_(C|CXX)_COMPILER_ID STREQUAL "GNU" are not the same thing? That CMAKE_COMPILER_IS_GNU(CC|CXX) is either gcc or command-line compatible clang?
In some contexts one just wants to set GNU-compatible flags. And it seems that at least mroonga might want to use it like this.

@brad0
Copy link
Contributor Author

brad0 commented May 22, 2025

You are aware that CMAKE_COMPILER_IS_GNU(CC|CXX) and CMAKE_(C|CXX)_COMPILER_ID STREQUAL "GNU" are not the same thing?

That IS how CMake handles things.

  # Set old compiler id variables.
  if(CMAKE_C_COMPILER_ID MATCHES "GNU")
    set(CMAKE_COMPILER_IS_GNUCC 1)
  endif()
  # Set old compiler id variables.
  if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
    set(CMAKE_COMPILER_IS_GNUCXX 1)
  endif()

You can see examples in CMake's own codebase where they're checking for GCC using CMAKE_COMPILER_IS_GNUCC
and then use CMAKE_C_COMPILER_ID to check for Clang.

  if((CMAKE_COMPILER_IS_GNUCC              AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) OR
     (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6))

That CMAKE_COMPILER_IS_GNU(CC|CXX) is either gcc or command-line compatible clang?

That is NOT the case. CMAKE_COMPILER_IS_GNU(CC|CXX) is only set for GCC.

I started this patch as step 1 to fix a test that should be executing with Clang but does not at the moment with it only checking CMAKE_COMPILER_IS_GNUCC.

@vaintroub
Copy link
Member

Indeed, sorry for confusion, heh. this seems not to be the case already since Oct 2013 (https://cmake.org/pipermail/cmake/2013-October/056071.html) and version 2.8.10 or so, but I was sure it is still the case.

@brad0
Copy link
Contributor Author

brad0 commented May 23, 2025

Indeed, sorry for confusion, heh. this seems not to be the case already since Oct 2013 (https://cmake.org/pipermail/cmake/2013-October/056071.html) and version 2.8.10 or so, but I was sure it is still the case.

Ah, I see why you thought that. When CMake didn't understand identifying Clang it made sense why it did that, but the corrections in behavior make sense to be able to differentiate the two properly (and other variants).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.
Development

Successfully merging this pull request may close these issues.

3 participants