forked from dlrdave/activizdotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MsvcMacros.cmake
73 lines (59 loc) · 1.78 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()
endmacro()
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()
endmacro()
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()
endforeach()
endif()
endmacro()
macro(MSVC_TREAT_WARNINGS_AS_ERRORS)
if(MSVC)
APPEND_FLAGS("CMAKE_C_FLAGS" "/WX")
APPEND_FLAGS("CMAKE_CXX_FLAGS" "/WX")
endif()
endmacro()
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()
endforeach()
endif()
endmacro()
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()
endforeach()
endif()
endmacro()
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()
endmacro()
macro(MSVC80_SUPPRESS_CRT_DEPRECATED_WARNINGS)
if(MSVC80)
add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
add_definitions("-D_SCL_SECURE_NO_DEPRECATE")
endif()
endmacro()