[CMake] Precompiled headers (was Re: problem: using options other
than -D with VS.NET)
Brad King
brad.king at kitware.com
Tue Oct 19 10:28:18 EDT 2004
Erik van der Wal wrote:
> Brad King wrote:
>
>> Bojan Resnik wrote:
>>
>>> A related question - are there any plans to explicitly support
>>> generation and usage of precompiled headers for compilers that support
>>> it?
>>
>>
>>
>> Currently it is not on the feature list, but it sounds like a good
>> idea. Please add it to the bug tracker as a feature request:
>
>
> Well noticed, Bojan, I was indeed referring to precompiled headers. In
> the wxArt2D library we currently use these (not implemented by me).
> Like Brad, I think cmake supporting precompiled headers is a good idea.
> The precompiled headers in wxart2d are implemented, by creating it using
> some dummy.cpp file, which only includes the (central) header. This is
> done by using the /Yc option.
> Next all following c++ files should use this file (/Yu option).
> This approach allways worked with VC6, but now we experience problems
> with .NET.
> The first problem started this thread and was cmake not accepting the
> /Yu option.
> The next problem is related to the compile order. The approach that was
> taken, needs the precompiled header to be created first, i.e. compile
> dummy.cpp first. Most generators I have seen so far, compile in the
> order in which they have been put in the CmakeLists.txt. The .NET
> generator however seems to compile in reverse order.
>
> Questions:
> Is the compile order specified in cmake?
> If yes, is this a .NET generator bug?
I think the reverse ordering might be a bug, but I'm not sure. Please
add it to the bug tracker here:
http://www.cmake.org/Bug
so that it will at least be investigated at some point.
> If no, can ADD_DEPENDENCIES be used somehow, to first compile dummy.cpp?
Yes. Create an executable target for dummy.cpp:
ADD_EXECUTABLE(precompile_headers dummy.cpp)
ADD_LIBRARY(mylib ...)
ADD_DEPENDENCIES(mylib precompile_headers)
This should make sure that the executable is built before the library.
-Brad
More information about the CMake
mailing list