From 57f27d88406cac52e5d4ad6d0e2500574ddb527a Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Sun, 23 Apr 2023 13:37:11 +0200 Subject: [PATCH] enable CI for Clang --- .github/workflows/windows.yml | 15 +++++++++++---- CMakeLists.txt | 10 +++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d4dbf0199f444..3bcaa4e6964d9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -58,7 +58,8 @@ jobs: shell: msys2 {0} strategy: matrix: - sys: [ ucrt64 ] + cxx: [ clang++ ] + lib: [ libc++, libstdc++ ] steps: - name: Set timezone run: tzutil /s "Ekaterinburg Standard Time" @@ -68,10 +69,16 @@ jobs: with: release: false msystem: ucrt64 - pacboy: cc:u cmake:u ninja:u lld:u clang:u + pacboy: cmake:u ninja:u clang:u libc++:u gcc-libs:u - name: Configure - run: cmake -B ../build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug - env: { LDFLAGS: -fuse-ld=lld } + run: | + cmake -B ../build -G "Ninja" -DCMAKE_CXX_VERSION=20 \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{format('-stdlib={0}', matrix.lib)}} + - name: Build run: cmake --build ../build - name: Test diff --git a/CMakeLists.txt b/CMakeLists.txt index 633bb0bc33897..f9bd5f62b49aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,11 @@ function(enable_module target) target_compile_options(${target} PRIVATE /interface /dxifcInlineFunctions- INTERFACE /reference fmt=${BMI}) + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(BMI ${CMAKE_CURRENT_BINARY_DIR}/fmt.pcm) + target_compile_options(${target} + PRIVATE -fmodule-output=${BMI} -x c++-module + INTERFACE -fmodule-file=fmt=${BMI}) endif () set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI}) set_source_files_properties(${BMI} PROPERTIES GENERATED ON) @@ -88,7 +93,10 @@ option(FMT_MODULE "Build a module instead of a traditional library." OFF) option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF) set(FMT_CAN_MODULE OFF) -if (CMAKE_CXX_STANDARD GREATER 17 AND MSVC AND MSVC_VERSION GREATER 1933) +if (CMAKE_CXX_STANDARD GREATER 17 AND ( + (MSVC AND MSVC_VERSION GREATER 1933) OR + ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND + (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16.0")))) set(FMT_CAN_MODULE ON) endif () if (NOT FMT_CAN_MODULE)