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

Robert Dailey rcdailey at gmail.com
Thu Oct 13 16:36:43 EDT 2011


On Thu, Oct 13, 2011 at 3:16 PM, David Cole <david.cole at kitware.com> wrote:

> On Thu, Oct 13, 2011 at 3:37 PM, Robert Dailey <rcdailey at gmail.com> wrote:
> > 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
> >
> >
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> > http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
> >
>
> At present, the only time we generate ExcludedFromBuild="true" is when
> the source file property HEADER_FILE_ONLY is set to a non-false value.
> That is on a per-source-file basis, though, not on a per-configuration
> basis.
>
> What you want is a new feature request for CMake. It does not exist yet.


I was able to find this existing feature request for what seems to be the
same thing I want:
http://www.itk.org/Bug/view.php?id=11902

I've voiced my vote for it. I hope it will be implemented.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111013/b2a89507/attachment.htm>


More information about the CMake mailing list