[CMake] Including source files multiple times

Yuri V. Timenkov ytimenkov at parallels.com
Fri Aug 8 00:46:35 EDT 2008


On Thursday 07 August 2008 19:14:48 Mike Jackson wrote:
> I have an issue where some common source code is getting included
> multiple times during cmake. I understand why it is happening. My
> question is how to avoid it. Here is the basic project setups.
>
> CommonCodeProject
> PVProjectA
> PVProjectB
>
> These are being built as ParaView Extra_External_Modules and I would
> like to be able to include either one or both of them in a ParaView
> Build.
>
> PVProjectA and PVProjectB BOTH need the code from CommonCodeProject.
> I have some cmake files inside of CommonCodeProject that lists out
> the various source files. The problem is both PVProjectA and
> PVProjectB include that same cmake file. I have tried setting some
> cmake variables to flag that the files have already been included but
> I don't think I am setting the variable correctly.
>
> Anyone have some pointers on how to achieve the desired results?
Make CommonCodeProject static library and link both projects to it. CMake will 
do the rest.
However, you may need to tune -fPIC compiler option usage if you want to embed 
these files into shared libraries.
>
> Thanks



More information about the CMake mailing list