diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e65dfac2..2f244ec4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,11 +84,19 @@ jobs: if: matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug' uses: SonarSource/sonarcloud-github-c-cpp@v2 - - name: Configure CMake - if: matrix.configurations.compiler != 'emscripten' + - name: Configure CMake Clang + if: matrix.configurations.compiler == 'clang17' shell: bash run: | - cmake -S . -B ../build -DDISABLE_EXTERNAL_DEPS_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=${{ matrix.configurations.compiler == 'gcc13' && matrix.cmake-build-type == 'Debug'}} + export CC=clang-17 + export CXX=clang++-17 + cmake -S . -B ../build -DDISABLE_EXTERNAL_DEPS_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DCMAKE_LINKER=/usr/bin/clang-17 + + - name: Configure CMake GCC + if: matrix.configurations.compiler == 'gcc13' + shell: bash + run: | + cmake -S . -B ../build -DDISABLE_EXTERNAL_DEPS_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=${{ matrix.cmake-build-type == 'Debug'}} - name: Configure CMake Emscripten if: matrix.configurations.compiler == 'emscripten' diff --git a/CMakeLists.txt b/CMakeLists.txt index e62afd2a..db61ad93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,14 +44,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|GNU|Intel)") if (CMAKE_BUILD_TYPE STREQUAL "" AND NOT CMAKE_CXX_FLAGS MATCHES "-O[123gs]") message(WARNING "It seems you are compiling without optimization. Please set CMAKE_BUILD_TYPE or CMAKE_CXX_FLAGS.") endif () - - if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") # set default C++ STL to Clang's libc++ when using Clang - add_compile_options(-stdlib=libc++ -fcolor-diagnostics) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-fdiagnostics-color=always) - endif() - endif () # Initialize a variable to hold all the compiler flags -> exported into global config.h(.in) @@ -69,6 +61,13 @@ endif() # Replace ; with space string(REPLACE ";" " " ALL_COMPILER_FLAGS "${ALL_COMPILER_FLAGS}") +if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") # set default C++ STL to Clang's libc++ when using Clang + add_compile_options(-stdlib=libc++ -fcolor-diagnostics) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-fdiagnostics-color=always) +endif() + # Mainly for FMT set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) diff --git a/core/test/CMakeLists.txt b/core/test/CMakeLists.txt index eca74fde..6373e36f 100644 --- a/core/test/CMakeLists.txt +++ b/core/test/CMakeLists.txt @@ -10,7 +10,7 @@ function(setup_test_no_asan TARGET_NAME) endfunction() function(setup_test TARGET_NAME) - if (NOT EMSCRIPTEN) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # limited to gcc due to a Ubuntu packaging bug of libc++, see https://github.com/llvm/llvm-project/issues/59432 target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address) # for testing consider enabling -D_GLIBCXX_DEBUG and -D_GLIBCXX_SANITIZE_VECTOR target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address) # for testing consider enabling -D_GLIBCXX_DEBUG and -D_GLIBCXX_SANITIZE_VECTOR endif ()