[CMake] Include source files on a per-configuration basis

Robert Dailey rcdailey at gmail.com
Thu Oct 13 15:37:22 EDT 2011


In visual studio, there is a way to exclude a source file from the build on
a per-configuration basis (debug vs release). The actual VCPROJ looks like
this when you exclude a CPP file from the build for only DEBUG
configuration:


<File
RelativePath="C:\Code\work\rdailey-t510-sandbox\n2\gpr\security\gtisecprovcleartext.cpp">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>


Is there a way in CMake to make it generate this? There has to be some sort
of platform agnostic feature for this, and for other platforms it will
implement it accordingly

---------
Robert Dailey


On Wed, Oct 5, 2011 at 3:47 PM, Robert Dailey <rcdailey at gmail.com> wrote:

> In my particular CMake project, I have three CPP files:
>
>     a.cpp
>     b.cpp
>     c.cpp
>
> I want 'a.cpp' to be compiled in all configurations (release & debug).<br>
> I only want 'b.cpp' to be compiled in DEBUG configuration.<br>
> I only want 'c.cpp' to be compiled in RELEASE configuration.
>
> How can I do this? I need something similar to the `debug` and `optimized`
> keywords that are accepted by the `target_link_libraries()` CMake operation.
>
> ---------
> Robert Dailey
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111013/825b3461/attachment.htm>


More information about the CMake mailing list