Skip to content

Commit

Permalink
clang ci fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph J. Steinhagen <[email protected]>
  • Loading branch information
RalphSteinhagen committed Feb 6, 2024
1 parent c96c823 commit d54e000
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit d54e000

Please sign in to comment.