[CMake] Adding non-build-related sources to IDE projects

Bill Hoffman bill.hoffman at kitware.com
Fri Feb 29 20:22:11 EST 2008


Bryan O'Sullivan wrote:
> Is there an appropriate way to cause an IDE like Visual Studio or Xcode 
> to present entries for source files such as .h files and .xml files, 
> which do not get compiled?
> 
> I'm currently listing those files as sources for library and executable 
> targets.  This doesn't work very well: I have to make sure I'm not 
> generating a Makefile, because then the files are listed in the Makefile 
> rule and cause compilation to fail.  Under Xcode, doing this causes lots 
> of build warnings as xcodebuild complains that it has no rules for .txt 
> or .xml files.
> 
> Is there a better way?
> 

That is the right way.   .h files should not be a problem.  For other 
files you might have to call set_source_files_properties with the 
HEADER_FILE_ONLY set to true.  I just realized the documentation for 
this is bogus...  What it does is keep it from being compiled by 
makefiles and various IDE's.

-Bill


More information about the CMake mailing list