[CMake] Sharing sources between two targets

Nick Gnedin ngnedin at gmail.com
Mon Apr 22 14:45:10 EDT 2013


Folks,

I am using CMake to create 2 targets - a stand-alone executable and a 
library that can be imported by Python. Both share most of the sources. 
If I just specify them as two separate targets, each will compile all 
the sources, so most of the source files end up compiled twice.

Is there a way to share the compiled sources between the two targets? I 
can create an intermediate library, but that is less convenient since 
the executable will then depend on it. What I would really like is to 
have a self-contained executable and a separate library that use the 
same object files.

Many thanks for any hint,

Nick Gnedin


More information about the CMake mailing list