[CMake] CFLAGS and CPPFLAGS

Alexander Neundorf a.neundorf-work at gmx.net
Fri Apr 17 11:12:56 EDT 2009


On Friday 17 April 2009, christophe laferriere wrote:
> Hi all,
>
> I'm currently using add_definition("-Wall -std=c99 -pedantic") to have
> CFLAGS sets, but I'm now adding some tests that uses the project
> library I'm working on, and those tests are in C++. So I'm getting an
> error about the -std=c99 flag which does not work for C++.
>
> So my question is what is the best way to have both CFLAGS and
> CPPFLAGS (apparently not using add_definition()).

There are at least two ways:
either set the environment variables CFLAGS and CPPFLAGS before running cmake 
initially, AFAIK cmake will pick them up then.
or
set the cmake variables CMAKE_C_FLAGS and CMAKE_CXX__FLAGS in your cmake 
files.

Alex


More information about the CMake mailing list