sakra / cotire

CMake module to speed up builds.
MIT License
1.3k stars 143 forks source link

MSVC 2017 /Fp and /Yc and /Yu Flags Broken On 391bf6b7609e14f5976bd5247b68d63cbf8d4d12 #173

Open gblikas opened 5 years ago

gblikas commented 5 years ago

Running the default example /CMakeLists.txt (top-most CMake Project), via the following command has some interesting command-line settings, which do not seem to actually utilize a pch system. I am running MSVC 2017 (x64).

mkdir build 
cd build
cmake -G "Visual Studio 15 2017 Win64" ../

In particular, here is [example Property Page] -> [C/C++] -> [Command Line] output:

/GS /TP /W3 /Zc:wchar_t /Zi /Gm- /Od /Ob0 /Fd"example.dir\Debug\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /MDd /FC /Fa"Debug/" /EHsc /nologo /Fo"example.dir\Debug\" /Fp"example.dir\Debug\example.pch" /diagnostics:classic 

For one, /Yu is not used, which causes the core MSVC system not to use a pre-compiled header (afaik, I am not a MSVC wiz). However, it is set in the following 2 methods:

https://github.com/sakra/cotire/blob/391bf6b7609e14f5976bd5247b68d63cbf8d4d12/CMake/cotire.cmake#L1627

and

https://github.com/sakra/cotire/blob/391bf6b7609e14f5976bd5247b68d63cbf8d4d12/CMake/cotire.cmake#L1786

Another interesting quirk is that /Fp"example.dir\Debug\example.pch doesn't exist:

image

It seems like in either the _unity build, or standard target name build, both should point to the pch content in /build/src/Debug/cotire:

image


If this is already explained in the documentation, I would love to figure out where. I am new to Cotire, so sorry for any obvious mistakes I may have made. Additionally, here is my vswhere.exe output, and CMake version information.

gblikas commented 5 years ago

@sakra Have you gotten a chance to look at this?

enricodetoma commented 5 years ago

I understand that it might not be a solution for you if you need/want to use Visual Studio IDE, but I'm using VSCode + Visual C++ 2017 + Cotire + Ninja build and /Yu and /Fp flags are all correctly set.

I decided to abandon Visual Studio IDE because it's intellisense was too slow, and I'm quite happy with the current setup, now.

gblikas commented 5 years ago

@enricodetoma Have you had a similar experience using a similar setup like I have?

enricodetoma commented 5 years ago

Sorry no. I wasn't using cotire yet, when I used cmake + visual studio ide.