[CMake] Compiler detection fails for custom Visual Studio Toolset

Nicolas Schneider nioncode at gmail.com
Tue Feb 16 17:24:57 EST 2016


I'm trying to build a Windows Driver with CMake, which requires using
the 'WindowsUserModeDriver10.0' PlatformToolset.

Trying to use this Toolset with CMake fails:
cmake -T "WindowsUserModeDriver10.0" ..
>   ClCompile:
> 
>     C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /IcmTC_b2982.dir\Debug\ /Zi /W3 /WX /Od /Ob0 /O
> y- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _X86_=1 /D i386=1 /D STD_CALL /D WIN32_LEAN_AND_MEAN=1
> /D _WIN32_WINNT=0x0A00 /D WINVER=0x0A00 /D WINNT=1 /D NTDDI_VERSION=0x0A000001 /D _MBCS /D UMDF_VERSION_MAJOR=2 /D UMDF_
> VERSION_MINOR=15 /D UMDF_USING_NTSTATUS /D _UNICODE /D UNICODE /GF /Gm- /RTC1 /MDd /Zp8 /GS /Gy /fp:precise /Zc:wchar_t-
>  /Zc:forScope /Zc:inline /GR- /Fo"cmTC_b2982.dir\Debug\\" /Fd"cmTC_b2982.dir\Debug\vc140.pdb" /Gz /TC /wd4603 /wd4627 /w
> d4986 /wd4987 /wd4996 /FI"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared\warning.h" /analyze- /error
> Report:queue /d1import_no_registry /d2AllowCompatibleILVersions /d2Zi+ "C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFi
> les\CMakeTmp\testCCompiler.c"
>     Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
>     Copyright (C) Microsoft Corporation.  All rights reserved.
> 
>     cl /c /IcmTC_b2982.dir\Debug\ /Zi /W3 /WX /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /
> D _X86_=1 /D i386=1 /D STD_CALL /D WIN32_LEAN_AND_MEAN=1 /D _WIN32_WINNT=0x0A00 /D WINVER=0x0A00 /D WINNT=1 /D NTDDI_VER
> SION=0x0A000001 /D _MBCS /D UMDF_VERSION_MAJOR=2 /D UMDF_VERSION_MINOR=15 /D UMDF_USING_NTSTATUS /D _UNICODE /D UNICODE
> /GF /Gm- /RTC1 /MDd /Zp8 /GS /Gy /fp:precise /Zc:wchar_t- /Zc:forScope /Zc:inline /GR- /Fo"cmTC_b2982.dir\Debug\\" /Fd"c
> mTC_b2982.dir\Debug\vc140.pdb" /Gz /TC /wd4603 /wd4627 /wd4986 /wd4987 /wd4996 /FI"C:\Program Files (x86)\Windows Kits\1
> 0\Include\10.0.10586.0\shared\warning.h" /analyze- /errorReport:queue /d1import_no_registry /d2AllowCompatibleILVersions
>  /d2Zi+ "C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFiles\CMakeTmp\testCCompiler.c"
> 
>     testCCompiler.c
> 
> 
>   C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFiles\CMakeTmp\testCCompiler.c(11):
>   error C2220: warning treated as error - no 'object' file generated
>   [C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFiles\CMakeTmp\cmTC_b2982.vcxproj]
> 
> 
> 
>   C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFiles\CMakeTmp\testCCompiler.c(11):
>   warning C4007: 'main': must be '__cdecl'
>   [C:\vagrant\WindowsDriver\cmake-bug\build\CMakeFiles\CMakeTmp\cmTC_b2982.vcxproj]

The main function of testCCompiler.c must be changed to __cdecl in order
to pass the compilation test.

To bypass this issue, I currently do use: `cmake -T
"WindowsUserModeDriver10.0" -DCMAKE_C_COMPILER_WORKS=1
-DCMAKE_CXX_COMPILER_WORKS=1 ..`

which I rather would not.
Also, incremental linking must be disabled even for Debug Builds,
otherwise the build fails. So after configuring, I compile with `cmake
--build . -- /p:LinkIncremental=false`

It would be great if incremental build could be disabled for Windows
Driver Toolsets directly in the vcxproj so that other developers can
build from the Visual Studio Gui without issues.

Any thoughts on that?


More information about the CMake mailing list