[CMake] Removing a compile flag for a specific file

David Larsson laserallan at gmail.com
Fri May 8 08:51:27 EDT 2009


Hi!
I have built a simple system to get precompiled header support in visual
c++.
The mechanism behind this functionality is adding the command line flags
when compiling every source file. /Yu to specify a header file that should
be precompiled and what /Fp as name for the actually generated precompiled
header file.

I use CMAKE_CXX_FLAGS to set this property:
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yu${pchbase}.h
/Fp$(IntDir)/$(TargetName).pch /D \"USE_PRECOMPILED\"" )

Now I added a c (as opposed to c++) file to my project and this c file is
not compatible with precompiled headers and the compilation fails.

First, should really CMAKE_CXX_FLAGS affect targets suffixed .c at all?
Shouldn't it be only for c++ files like suffixed .cpp or .cxx?

Since it does affect my C file, is there a way of actively remove flags for
a specific file?

For this particular case I can't rename my c file to cpp and compile it in
c++ mode since the actual reason I want the file to be compiled is to make
sure that some header files doesn't contain anything c++ specific.

/David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090508/4e7f28b8/attachment-0001.htm>


More information about the CMake mailing list