-
Notifications
You must be signed in to change notification settings - Fork 3
/
MsvcMacros.cmake
73 lines (59 loc) · 2.08 KB
/
MsvcMacros.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
MACRO(APPEND_FLAGS var flags)
IF(NOT "${${var}}" MATCHES "${flags}")
SET(${var} "${${var}} ${flags}")
#MESSAGE(STATUS "INFO: ${var} changed to '${${var}}'")
ENDIF(NOT "${${var}}" MATCHES "${flags}")
ENDMACRO(APPEND_FLAGS)
MACRO(REPLACE_FLAGS var these those)
IF("${${var}}" MATCHES "${these}")
STRING(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}")
#MESSAGE(STATUS "INFO: ${var} changed to '${${var}}'")
ENDIF("${${var}}" MATCHES "${these}")
ENDMACRO(REPLACE_FLAGS)
MACRO(MSVC_FORCE_WARNING_LEVEL level)
IF(MSVC)
FOREACH(lang C CXX)
FOREACH(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
REPLACE_FLAGS("CMAKE_${lang}_FLAGS${suffix}" "/W[1-4]" "/W${level}")
ENDFOREACH(suffix)
ENDFOREACH(lang)
ENDIF(MSVC)
ENDMACRO(MSVC_FORCE_WARNING_LEVEL)
MACRO(MSVC_TREAT_WARNINGS_AS_ERRORS)
IF(MSVC)
APPEND_FLAGS("CMAKE_C_FLAGS" "/WX")
APPEND_FLAGS("CMAKE_CXX_FLAGS" "/WX")
ENDIF(MSVC)
ENDMACRO(MSVC_TREAT_WARNINGS_AS_ERRORS)
MACRO(MSVC_LINK_TO_STATIC_CRT)
IF(MSVC)
FOREACH(lang C CXX)
FOREACH(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
REPLACE_FLAGS("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT")
ENDFOREACH(suffix)
ENDFOREACH(lang)
ENDIF(MSVC)
ENDMACRO(MSVC_LINK_TO_STATIC_CRT)
MACRO(MSVC_LINK_TO_DLL_CRT)
IF(MSVC)
FOREACH(lang C CXX)
FOREACH(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
REPLACE_FLAGS("CMAKE_${lang}_FLAGS${suffix}" "/MT" "/MD")
ENDFOREACH(suffix)
ENDFOREACH(lang)
ENDIF(MSVC)
ENDMACRO(MSVC_LINK_TO_DLL_CRT)
MACRO(MSVC80_FORCE_MANIFEST_LINKER_FLAG)
IF(MSVC80)
APPEND_FLAGS("CMAKE_EXE_LINKER_FLAGS" "/MANIFEST")
APPEND_FLAGS("CMAKE_MODULE_LINKER_FLAGS" "/MANIFEST")
APPEND_FLAGS("CMAKE_SHARED_LINKER_FLAGS" "/MANIFEST")
ENDIF(MSVC80)
ENDMACRO(MSVC80_FORCE_MANIFEST_LINKER_FLAG)
MACRO(MSVC_SUPPRESS_CRT_DEPRECATED_WARNINGS)
IF(MSVC)
ADD_DEFINITIONS("-D_CRT_NONSTDC_NO_DEPRECATE")
ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE")
ADD_DEFINITIONS("-D_SCL_SECURE_NO_DEPRECATE")
ENDIF(MSVC)
ENDMACRO(MSVC_SUPPRESS_CRT_DEPRECATED_WARNINGS)