-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_type.cmake
76 lines (70 loc) · 2.08 KB
/
build_type.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
74
75
76
include_guard(GLOBAL)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT isMultiConfig)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Debug
CACHE STRING "" FORCE)
endif()
endif()
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
function(has_build_type build_type out_var)
set(out_var OFF)
if(isMultiConfig)
if(${build_type} IN_LIST CMAKE_CONFIGURATION_TYPES)
set(out_var ON)
endif()
else()
get_property(
build_type_strings
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS)
if(${build_type} IN_LIST build_type_strings)
set(out_var ON)
endif()
endif()
return(PROPAGATE ${out_var})
endfunction()
function(add_custom_build_type build_type)
has_build_type(build_type result)
if(result)
return()
endif()
if(isMultiConfig)
list(APPEND CMAKE_CONFIGURATION_TYPES ${build_type})
set(CMAKE_CONFIGURATION_TYPES
"${CMAKE_CONFIGURATION_TYPES}"
CACHE STRING "" FORCE)
else()
get_property(
build_type_strings
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS)
list(APPEND build_type_strings ${build_type})
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"${build_type_strings}")
endif()
foreach(lang IN LISTS languages)
set(CMAKE_${lang}_FLAGS_${build_type}
""
CACHE STRING "")
endforeach()
foreach(targettype IN ITEMS EXE SHARED STATIC MODULE)
set(CMAKE_${targettype}_LINKER_FLAGS_${build_type}
""
CACHE STRING "")
endforeach()
endfunction()
function(add_custom_build_type_like build_type existed_build_type)
add_custom_build_type(${build_type})
foreach(lang IN LISTS languages)
set(CMAKE_${lang}_FLAGS_${build_type}
"${CMAKE_${lang}_FLAGS_${existed_build_type}}"
CACHE STRING "" FORCE)
endforeach()
foreach(targettype IN ITEMS EXE SHARED STATIC MODULE)
set(CMAKE_${targettype}_LINKER_FLAGS_${build_type}
"${CMAKE_${targettype}_LINKER_FLAGS_${existed_build_type}}"
CACHE STRING "" FORCE)
endforeach()
endfunction()