Hello, About three months ago, Microsoft has released Visual Studio 2015 Update 1 with an interesting feature - the preview version of "Clang with Microsoft CodeGen" (a.k.a. Clang/C2). It is a separate compiler, built from frontend of Clang and backend of Microsoft's C++ compiler (known as C2). One of advantages of this compiler over cl.exe is full support of C++14 and GNU extensions. I thought, it would be interesting to make it usable with CMake.
Basically, to switch the compiler one needs to select appropriate toolset - "c140_clang_3_7". CMake already has support of toolsets, so it's already possible to generate VS project with the following command: > cmake.exe -G "Visual Studio 14 2015" -T "v140_clang_3_7" <src dir> Unfortunately, as this toolset is a bit different, it requires some different settings in the project file than these used with cl.exe compiler. This is what I am trying to fix with my patches. Following is the list of patches with descriptions: 1. kwsys: fix build on VS Clang/C2 toolset Makes it possible to build CMake itself with Clang/C2. This compiler does not support inline assembly in the cl.exe format. 2. CMakeDetermineCompilerId: allow to detect clang.exe bundled with Visual Studio CMAKE_C(XX)?_COMPILER variables should point to clang.exe instead of cl.exe 3. Visual Studio: in Clang/C2 toolset, setup correct compiler settings clang.exe takes most of options in clang/gcc-compatible format instead of cl.exe format. 4. Clang testable features: don't enable cxx_decltype_incomplete_return_type in MSVC simluation mode This feature does not work. Honestly, I am not sure about the reason - may be the bug in the compiler. 5. Visual Studio 14: support of <CppLanguageStandard> tag in project files Projects using Clang/C2 use this tag to control language standard version. 6. Tests: fix AliasTarget building on Clang/C2 Clang in C++98 mode is unable to parse some of headers bundled with MSVC, so using C++11 is necessary. 7. Tests: fix Module.GenerateExportHeader building on Clang/C2 Clang/C2 uses gcc attributes syntax for deprecations, but uses cl.exe syntax for dllimports/exports. Also, includes same fix as in patch 6. 8. Tests: fix Module.WriteCompilerDetectionHeader building on Clang/C2 Visual Studio does not handle this test very well. Not sure why. 9. Tests: fix Complex building on Clang/C2 Same as in patch 6. 10. Tests: fix complexOneConfig building on Clang/C2 Same as in patch 6. 11. Tests: do not build ExternalProjectLocal/TutorialStep5 when path is too long This toolset uses a bit longer names of some files, which may cause full path size to exceed 256 characters. 12. Tests: fix Plugin building on Clang/C2 Same as in patch 6. 13. Tests: fix PDBDirectoryAndName on Clang/C2 Clang/C2 does not generate pdb files for static libraries. Note that debugging information is not lost - they're put into the .lib itself, and when the binary is created, they seem to be extracted and placed into binary's own pdb file. 14. Tests: do not build PrecompiledHeader on Clang/C2 Precompiled headers are not (yet?) supported in this compiler. 15. Tests: disable VSMidl on Clang/C2 I don't know why this test fails. As you can see, most of the changes are tests adjustments. In case of patches 8 and 15 I cannot provide good explanations on why these tests are failing - all suggestions are welcome! What can be guessed from the list of patches, I have successfully compiled CMake itself, and got all tests passing. Checked with aforementioned VS version, on Windows Server 2012. Patches are attached, they apply on top of "next" branch (d7b1a40b0f039ed46522d5c9f3c7c421833ba32c). I would highly appreciate any feedback or review! Best Regards Mariusz Plucinski PS For anybody who would like to run it: the precondition is to install Visual Studio 2015 Update 1 with "Clang with Microsoft CodeGen". Information about this process and more information about the feature itself are available in Visual C++ Team Blog on MSDN: https://blogs.msdn.microsoft.com/vcblog/2015/12/04/clang-with-microsoft-codegen-in-vs-2015-update-1/
0001-kwsys-fix-build-on-VS-Clang-C2-toolset.patch
Description: Binary data
0002-CMakeDetermineCompilerId-allow-to-detect-clang.exe-b.patch
Description: Binary data
0003-Visual-Studio-in-Clang-C2-toolset-setup-correct-comp.patch
Description: Binary data
0004-Clang-testable-features-don-t-enable-cxx_decltype_in.patch
Description: Binary data
0005-Visual-Studio-14-support-of-CppLanguageStandard-tag-.patch
Description: Binary data
0006-Tests-fix-AliasTarget-building-on-Clang-C2.patch
Description: Binary data
0007-Tests-fix-Module.GenerateExportHeader-building-on-Cl.patch
Description: Binary data
0008-Tests-fix-Module.WriteCompilerDetectionHeader-buildi.patch
Description: Binary data
0009-Tests-fix-Complex-building-on-Clang-C2.patch
Description: Binary data
0010-Tests-fix-complexOneConfig-building-on-Clang-C2.patch
Description: Binary data
0011-Tests-do-not-build-ExternalProjectLocal-TutorialStep.patch
Description: Binary data
0012-Tests-fix-Plugin-building-on-Clang-C2.patch
Description: Binary data
0013-Tests-fix-PDBDirectoryAndName-on-Clang-C2.patch
Description: Binary data
0014-Tests-do-not-build-PrecompiledHeader-on-Clang-C2.patch
Description: Binary data
0015-Tests-disable-VSMidl-on-Clang-C2.patch
Description: Binary data
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers