[CMake] Easy target to create an object file?

Brad King brad.king at kitware.com
Wed Mar 23 15:43:20 EST 2005


Tanner Lovelace wrote:
> For various reasons, on the windows platform, in addition to
> creating a static library, I also need to create an object
> file from one of the same source files, but with a different
> set of #defines applied to it.  Is there any easier way to
> do this other than just creating a custom target to do it?

Since it is only the windows platform the custom target may not be too 
hard.  The other option is to create a subdirectory and in its 
CMakeLists.txt file add a static library that has only this one source 
file in it.  Then you can change the flags for building this one file by 
changing the flags for that whole directory.  It will build the library 
and as a side effect leave behind the desired object file.  A post-build 
command for the library can copy the object file to wherever you need it.

-Brad


More information about the CMake mailing list