[CMake] Visual Studio Warning Level
James Bigler
jamesbigler at gmail.com
Fri Mar 27 17:35:15 EDT 2009
I manage all the warning levels by hand.
If you are truly in a rush this is what I do:
# The idea is to match a string that ends with cl but doesn't have icl in it.
set(COMPILER_NAME_REGEXPR "([^i]|^)cl.*$")
if(CMAKE_C_COMPILER MATCHES ${COMPILER_NAME_REGEXPR}
AND CMAKE_CXX_COMPILER MATCHES ${COMPILER_NAME_REGEXPR})
set(USING_WINDOWS_CL TRUE)
# We should set this macro as well to get our nice trig functions
add_definitions(-D_USE_MATH_DEFINES)
# Microsoft does some stupid things like #define min and max.
add_definitions(-DNOMINMAX)
endif()
# This code is kind of off the seat of my pants, but I do something similar.
if(USING_WINDOWS_CL)
set(flag "/W4")
# Only add the flag in once
if(NOT CMAKE_CXX_FLAGS MATCHES "${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" CACHE LIST
"Compile flags" FORCE)
endif()
endif()
James
More information about the CMake
mailing list