[CMake] Want to compile a file but does not want to link it in library

Alexander Neundorf a.neundorf-work at gmx.net
Fri May 29 15:51:18 EDT 2009


On Tuesday 26 May 2009, ankit jain wrote:
> Hi all,
>
> I have a folder f1 having 4 files c1.c c2.c c3.c c4.c.
> Now iam compiling all these files with certain definitions and other
> compiler flags.
>
> Now what i want is that when iam building library for this forder f1 it
> does not take c4.c
>
> One way is that i should not include this file in creating library.In that
> case c4.c willnot be compiled but i want c4.c to compile but not be
> included in the library.
>
> Also if i use add_custom_command to compile that file explicitly then i
> have to give all the definitions and other compiler option settings for
> that file explicitly which i dont want to do..
>
> Is there any option in cmake while creating library which allows compiling
> a file but not linking it in library.

Not really.
Why do you want that ?
Slightly similar would be to exclude c4.c from the actual library and 
additionally create a static library "dummy" which contains all the objects 
you just want to compile (since creating a static library is not really 
linking, just putting all the files into an archive without any symbol 
checking etc.)

Alex


More information about the CMake mailing list