Corrade adds /wd*** warning disablements to "clang.exe" on windows.
See CI run here: https://github.com/jonesmz/osp-magnum/runs/8295594455
Note that this isn't clang-cl.exe, this is clang.exe
During the configuration we get :
-- The CXX compiler identification is Clang 15.0.0 with GNU-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IPO / LTO enabled
-- The C compiler identification is Clang 15.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
Note that in the same run, ClangCL has this configuration output:
-- The CXX compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IPO / LTO enabled
-- The C compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
and then later:
FAILED: 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj
C:\PROGRA~1\LLVM\bin\c++.exe -DNOMINMAX -DUNICODE -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -ID:/a/osp-magnum/osp-magnum/3rdparty/corrade/src -ID:/a/osp-magnum/osp-magnum/build/3rdparty/corrade/src -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -flto=thin -fno-omit-frame-pointer /W4 /wd4127 /wd4251 /wd4244 /wd4267 /wd4324 /wd4351 /wd4373 /wd4458 /wd4510 /wd4610 /wd4512 /wd4661 /wd4702 /wd4706 /wd4800 /wd4910 -Wno-microsoft-cast -std=c++20 -MD -MT 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj -MF 3rdparty\corrade\src\Corrade\CMakeFiles\CorradeMain.dir\CorradeMain.cpp.obj.d -o 3rdparty/corrade/src/Corrade/CMakeFiles/CorradeMain.dir/CorradeMain.cpp.obj -c D:/a/osp-magnum/osp-magnum/3rdparty/corrade/src/Corrade/CorradeMain.cpp
c++: error: no such file or directory: '/W4'
c++: error: no such file or directory: '/wd4127'
c++: error: no such file or directory: '/wd4251'
c++: error: no such file or directory: '/wd4244'
c++: error: no such file or directory: '/wd4267'
c++: error: no such file or directory: '/wd4324'
c++: error: no such file or directory: '/wd4351'
c++: error: no such file or directory: '/wd4373'
c++: error: no such file or directory: '/wd4458'
c++: error: no such file or directory: '/wd4510'
c++: error: no such file or directory: '/wd4610'
c++: error: no such file or directory: '/wd4512'
c++: error: no such file or directory: '/wd4661'
c++: error: no such file or directory: '/wd4702'
c++: error: no such file or directory: '/wd4706'
c++: error: no such file or directory: '/wd4800'
c++: error: no such file or directory: '/wd4910'
These appear to be coming from https://github.com/mosra/corrade/blob/master/modules/UseCorrade.cmake around line 158
Which is perplexing, as i see this check
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
Obviously the COMPILER_ID isn't "MSVC", but perhaps cmake has somehow decided that Clang 15.0.0 with GNU-like command-line is simulating "MSVC"?
Looking at this issue in the cmake bug tracker, there's apparently also a CMAKE_CXX_COMPILER_FRONTEND_VARIANT which will be set to either "MSVC" or "GNU" depending on if we're using clang-cl.exe or clang.exe
https://gitlab.kitware.com/cmake/cmake/-/issues/19724
What a cursed issue you got into, heh... wasn't even aware of such distinction. Going with _FRONTEND_VARIANT seems to be the way, yes, but looking at https://discourse.cmake.org/t/clang-on-windows-detected-with-msvc-interface/3470/9 linked from there it seems it won't be that simple and likely more changes will be needed to get non-CL Clang fully working :sweat_smile:
Once you make this work, could you open a PR with the necessary changes to UseCorrade? Ideally it would do the detection correctly just once at the top: https://github.com/mosra/corrade/blob/e6b4d952e757ab99a0b67e516235b7f91904dca0/modules/UseCorrade.cmake#L41-L49
and then use the CORRADE_TARGET_ defines from there onwards, instead of repeating complex checks for CMAKE_CXX_COMPILER_ID etc. Thanks in advance! :+1: