solvespace/cmake/DisableWarnings.cmake
whitequark 7f0083aa1d CMake: correctly use if(STREQUAL).
If an operand is a string, it should be quoted to prevent expansion.
This doesn't matter with "GNU", but does with "MSVC" (which expands
to "YES").
2016-08-01 00:48:37 +00:00

16 lines
655 B
CMake

# Disables all warnings on MSVC and GNU-compatible compilers.
function(disable_warnings)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" PARENT_SCOPE)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0" PARENT_SCOPE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w" PARENT_SCOPE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0" PARENT_SCOPE)
endif()
endfunction()