[CMake] Object files of a target/source file
Michael Wild
themiwi at gmail.com
Thu Dec 11 10:43:02 EST 2008
On 11. Dec, 2008, at 16:25, Michael Wild wrote:
> Hi all
>
> Does anyone of you know how to reliably obtain the list of object
> files belonging to a target? And in the same line, how would I
> obtain the object file which corresponds to a certain source file
> (provided that it is only used for a single target)?
>
> Using the approach shown in the CMake-Book (4th ed., p. 52) which
> simply replaces .cxx by .obj (obviously on Windows) does not work
> reliably, especially if the sources are not in
> CMAKE_CURRENT_SOURCE_DIR. On Windows (this is the case I'm
> interested in, regrettably), particularly with MSVC, additional
> problems arise if the same target has multiple files with the same
> file name in different directories. Because, by default, all object
> files seem to be built in ${CMAKE_CURRENT_BINARY_DIR}/$
> {CMAKE_CFG_INTDIR}, EXCEPT if there are name clashes. In this case
> one of the objects gets built in ${CMAKE_CURRENT_BINARY_DIR}/$
> {CMAKE_CFG_INTDIR}, the others in subdirectories, in order to
> prevent the name clash.
>
> So, you see, obtaining the object file name is anything but trivial.
> I scourged the documentation and Google, but couldn't find anything
> useful...
>
>
> Thanks for your help in advance
>
> Michael
In case you wonder why I need the object files:
I'm working on porting a rather huge code to Windows which
a) consists of about 70 shared libraries
b) has cyclic dependencies between the libraries (yes, i agree...).
Under Unix-like platforms this is no problem, but under Windows I need
to create an import libraries in order to break the cycle.
c) is making heavy use of C++-templates (and typedefs thereof), so
identifying the places where I would need to insert these ugly and
stupid XXX_EXPORTS macros is just pure torture.
So, I hope someone here is coming up with a really good solution to
the problem...
Michael
More information about the CMake
mailing list