[CMake] Exclude file from build on a given target

Philip Lowman philip at yhbt.com
Tue May 26 23:08:31 EDT 2009


If you want to exclude certain source files from certain targets you can use
a list and then list(REMOVE_ITEM...)

set(FOO_SRCS foo.cc bar.cc)
list(REMOVE_ITEM FOO_SRCS bar.cc)
add_library(foo ${FOO_SRCS})

Alternatively, only add the unusual source files to the targets you want.

set(FOO_SRCS foo.cc bar.cc)
if(WHATEVER)
   list(FOO_SRCS APPEND whatever.cc)
endif()

On Tue, May 26, 2009 at 5:52 PM, Daniel Tavares
<daniel.tavares at slipg8.com>wrote:

>  Is it possible to exclude a file from build for a specific build target?
> As far as I could read on the documentation and discussion threads, setting
> HEADER_FILE_ONLY to TRUE changes the file property for all targets.
>
>
>
> I’m converting a Visual Studio 2005 project to CMake and this project
> excludes a couple of files from the build depending on the build target.
>
>
>
>
>
> Thanks,
>
> Daniel
>
>
>
>
>
> _______________________________________________
> 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
>



-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090526/4d3ffb95/attachment-0001.htm>


More information about the CMake mailing list