[CMake] Variable with created object files

Hendrik Sattler post at hendrik-sattler.de
Mon May 19 08:02:52 EDT 2008


Zitat von Christoph Cullmann <cullmann at absint.com>:
> If have following cmake file:
>
> AUX_SOURCE_DIRECTORY(src SOURCES)
>
> ADD_LIBRARY(aitraceerwin
>     lib/init
>     lib/map
>     lib/vector
>     lib/list
>     lib/base
>     ${SOURCES}
> )
>
> Now I need a variable containing all object files created during the compile
> of aitraceerwin library, or in other words all object files matching to the
> passed sources. Best pratice for that? (I could imagine some regex on the
> sources, but for example on unix you get .o, on windows .obj files somewhere,
> is there a better way)

There is currently no good way. The same question applies to build  
targets that do not support libraries: what is then going to happen on  
ADD_LIBRARY()?

My suggestion is to create a "virtual library" (as opposed to static  
and dynamic) that is just a list of object files, abstracted in a  
target. Linking this to another target would only add the object files  
to that target. Such a target would do nothing on INSTALL().
Would that be a solution?

HS




More information about the CMake mailing list