[CMake] Specify compiler flags for only one file

Alexander Neundorf a.neundorf-work at gmx.net
Wed Oct 19 13:29:49 EDT 2011


On Wednesday 19 October 2011, Renan Greinert wrote:
> Hello everybody,
> 
> 
> 
> I have a simple Project like this:
> 
> 
> 
> 
> 
> set(PROJ_SOURCES
> 
>   main.cpp
> 
>   manager.cpp
> 
>   exceptionhandler.cpp
> 
>   sqlite3.c )
> 
> 
> 
> #and the following flags for visual studio
> 
> set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} /EHsc /Oi /Ot /GF /GS- /W4")
> 
> 
> 
> The problem is that we want to compile with warnings level 4 (/W4), but we
> have 3rd part files (sqlite3.c in the example) and it throws thousands of
> warnings. So, only that file, I'd like to compile with /W0 param.
> 
> 
> Is it possible to do that with CMake?

set_source_files_properties(... COMPILE_FLAGS ... ) should do it.

Alex


More information about the CMake mailing list