Skip to content

Commit

Permalink
Select newest clang be default (#6833)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtropets authored Feb 18, 2025
1 parent 4fcd369 commit f441407
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
git config --global --add safe.directory /__w/CCF/CCF
mkdir build
cd build
CC=`which clang` CXX=`which clang++` cmake -GNinja -DCOMPILE_TARGET=${{ matrix.platform.name }} -DCMAKE_BUILD_TYPE=Debug ..
cmake -GNinja -DCOMPILE_TARGET=${{ matrix.platform.name }} -DCMAKE_BUILD_TYPE=Debug ..
ninja
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/long-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ jobs:
git config --global --add safe.directory /__w/CCF/CCF
mkdir build
cd build
CC=`which clang` CXX=`which clang++` cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TEST=ON ..
cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TEST=ON ..
ninja
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
git config --global --add safe.directory /__w/CCF/CCF
mkdir build
cd build
CC=`which clang` CXX=`which clang++` cmake -GNinja -DCOMPILE_TARGET=${{ matrix.platform.name }} -DCLIENT_PROTOCOLS_TEST=ON -DCMAKE_BUILD_TYPE=Release ..
cmake -GNinja -DCOMPILE_TARGET=${{ matrix.platform.name }} -DCLIENT_PROTOCOLS_TEST=ON -DCMAKE_BUILD_TYPE=Release ..
ninja -v | tee build.log
- name: "Install Extended Testing Tools"
Expand Down
25 changes: 12 additions & 13 deletions cmake/preproject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@

# Note: this needs to be done before project(), otherwise CMAKE_*_COMPILER is
# already set by CMake. If the user has not expressed any choice, we attempt to
# default to Clang >= 11. If they have expressed even a partial choice, the
# set a default Clang choice. If they have expressed even a partial choice, the
# usual CMake selection logic applies. If we cannot find both a suitable clang
# and a suitable clang++, the usual CMake selection logic applies
if((NOT CMAKE_C_COMPILER)
AND (NOT CMAKE_CXX_COMPILER)
AND "$ENV{CC}" STREQUAL ""
AND "$ENV{CXX}" STREQUAL ""
)
find_program(FOUND_CMAKE_C_COMPILER NAMES clang-15)
find_program(FOUND_CMAKE_CXX_COMPILER NAMES clang++-15)
find_program(FOUND_CMAKE_C_COMPILER NAMES clang)
find_program(FOUND_CMAKE_CXX_COMPILER NAMES clang++)

# vvvvv Ubuntu-20.04, to be removed after support dropped. vvvvv #
if(NOT (FOUND_CMAKE_C_COMPILER AND FOUND_CMAKE_CXX_COMPILER))
find_program(FOUND_CMAKE_C_COMPILER NAMES clang-15)
find_program(FOUND_CMAKE_CXX_COMPILER NAMES clang++-15)
endif()
# ^^^^^ Ubuntu-20.04, to be removed after support dropped. ^^^^^ #

if(NOT (FOUND_CMAKE_C_COMPILER AND FOUND_CMAKE_CXX_COMPILER))
message(
WARNING
"Clang 11 or Clang 15 not found, will use default compiler. "
"Clang not found, will use default compiler. "
"Override the compiler by setting CC and CXX environment variables."
)
else()
Expand All @@ -27,15 +35,6 @@ if((NOT CMAKE_C_COMPILER)
endif()
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 11)
message(WARNING "CCF officially supports Clang >= 11 only, "
"but your Clang version (${CMAKE_C_COMPILER_VERSION}) "
"is older than that. Build problems may occur."
)
endif()
endif()

# Build Release by default, with debug info
set(default_build_type "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down

0 comments on commit f441407

Please sign in to comment.