summaryrefslogtreecommitdiff
path: root/templates/cmake.mpd
blob: 9e39dc43fa244bf5db7c8b6a6b369bc83335ec43 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
cmake_minimum_required(VERSION <%cmake_minimum_required(3.12.0)%>)

<%marker(top)%>
project(<%project_name%> <%language%>)
option(BUILD_SHARED_LIBS "Build using shared libraries" <%if(need_staticflags)%>OFF<%else%>ON<%endif%>)

<%if(pre_find_package)%>
<%pre_find_package%>
<%endif%>
<%foreach(packages)%>
find_package(<%package%> REQUIRED)
<%endfor%>

<%if(header_files)%>
set(HEADER_FILES_<%uc(normalize(project_name))%> <%header_files%>)

<%endif%>
<%if(inline_files)%>
set(INLINE_FILES_<%uc(normalize(project_name))%> <%inline_files%>)

<%endif%>
<%if(template_files)%>
set(TEMPLATE_FILES_<%uc(normalize(project_name))%> <%template_files%>)

<%endif%>
set(SOURCE_FILES_<%uc(normalize(project_name))%> <%source_files%>)
<%if(libs || lit_libs || pure_libs)%>
<%foreach(libs)%>
<%if(cmake_macro(lib))%>
if(<%cmake_macro(lib)%>)
  set(<%cmake_macro(lib)%>_DEFINED TRUE)
endif()
<%endif%>
<%endfor%>
if(CMAKE_CONFIGURATION_TYPES)
set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%> <%foreach(configurations)%><%fornotfirst("                          ")%>$<$<CONFIG:<%configuration%>>:<%foreach(libs)%><%fornotfirst(" ")%><%if(cmake_macro(lib))%>$<IF:$<BOOL:${<%cmake_macro(lib)%>_DEFINED}>,<%lib%>${LIBRARY_DECORATOR}<%lib_modifier%>,><%else%><%lib%>${LIBRARY_DECORATOR}<%lib_modifier%><%endif%><%endfor%>><%fornotlast("\n")%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
else()
set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%><%foreach(libs)%> <%if(cmake_macro(lib))%>$<IF:$<BOOL:${<%cmake_macro(lib)%>_DEFINED}>,<%lib%>${LIBRARY_DECORATOR},><%else%><%lib%>${LIBRARY_DECORATOR}<%endif%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
endif()
<%endif%>
set(PROJECT_TARGET_<%uc(normalize(project_name))%> <%if(exename)%><%exename%><%else%><%if(sharedname)%><%sharedname%>${LIBRARY_DECORATOR}<%else%><%if(staticname)%><%staticname%>${LIBRARY_DECORATOR}<%else%><%project_name%>${LIBRARY_DECORATOR}<%endif%><%endif%><%endif%>)
<%marker(macros)%>

<%if(exeout)%>
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_exeout%>)
<%if(use_lib_modifier)%>
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG <%env_exeout%>)
<%endif%>
<%endif%>
<%if(!exename)%>
<%if(libout)%>
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY <%env_libout%>)
<%if(use_lib_modifier)%>
<%foreach(configurations)%>
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
<%endfor%>
<%endif%>
<%endif%>
<%if(dllout)%>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_dllout%>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_dllout%>)
<%if(use_lib_modifier)%>
<%foreach(configurations)%>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
<%endfor%>
<%endif%>
<%else%>
<%if(libout)%>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_libout%>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_libout%>)
<%if(use_lib_modifier)%>
<%foreach(configurations)%>
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
<%endfor%>
<%endif%>
<%endif%>
<%endif%>
<%endif%>

<%if(compile_flags)%>
target_compile_options(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%compile_flags%>)

<%endif%>
<%if(exename)%>
add_executable(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
target_link_libraries(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%>})
<%if(staticflags)%>
if(NOT BUILD_SHARED_LIBS)
  target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
  set_property(TARGET ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTY
               MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
<%endif%>
<%else%>
<%if(sharedname)%>
add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
<%if(dynamicflags)%>
if(BUILD_SHARED_LIBS)
  target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%dynamicflags%>)
<%if(staticflags)%>
else()
  target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
<%endif%>
endif()
<%else%>
<%if(staticflags)%>
if(NOT BUILD_SHARED_LIBS)
  target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
endif()
<%endif%>
<%endif%>
target_link_libraries(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%>})
<%else%>
<%if(staticname)%>
add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
<%if(staticflags)%>
target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
<%endif%>
<%endif%>
<%endif%>
<%if(use_lib_modifier)%>
<%foreach(configurations)%>
<%if(lib_modifier)%>
set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES <%uc(configuration)%>_POSTFIX "<%lib_modifier%>")
<%endif%>
<%endfor%>
<%endif%>
<%endif%>

if(CMAKE_CONFIGURATION_TYPES)
target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC
<%foreach(configurations)%>                           $<$<CONFIG:<%configuration%>>:MPC_LIB_MODIFIER="${LIBRARY_DECORATOR}<%lib_modifier%>"><%fornotlast("\n")%><%endfor%>)
endif()

<%if(includes)%>
target_include_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_includes%>)

<%endif%>
<%if(libpaths)%>
target_link_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_libpaths%>)

<%endif%>
<%if(pch_header)%>
target_precompile_headers(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%pch_header%>)

<%endif%>
<%if(pch_source)%>
target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%pch_defines%>)
<%endif%>
<%if(macros)%>
target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%macros%>)

<%endif%>
<%if(custom_types)%>
<%foreach(custom_types)%>
<%if(custom_type->input_files)%>
<%if(custom_type->command)%>

include(<%custom_type%> OPTIONAL)
<%foreach(custom_type->input_files)%>
<%uc(custom_type)%>_TARGET_SOURCES(
    ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%custom_type->input_file%>
    <%uc(custom_type)%>_OPTIONS <%if(flag_overrides(custom_type->input_file, commandflags))%><%flag_overrides(custom_type->input_file, commandflags)%><%else%><%custom_type->commandflags%><%endif%><%if(custom_type->output_option)%> <%custom_type->output_option%> <%if(flag_overrides(custom_type->input_file, gendir))%><%flag_overrides(custom_type->input_file, gendir)%>/<%basename(custom_type->input_file->output_file)%><%else%><%custom_type->input_file->output_file%><%endif%><%endif%>)

<%endfor%>
<%else%>
<%foreach(custom_type->input_files)%>
<%if(custom_type->input_file->commands)%>
<%if(forfirst)%>
include(<%custom_type%> OPTIONAL)
<%endif%>
<%uc(custom_type)%>_TARGET_SOURCES(
    ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%custom_type->input_file%>
<%foreach(custom_type->input_file->commands)%>
    <%uc(custom_type->input_file->command->type)%>_OPTIONS <%custom_type->input_file->command->flags%><%fornotlast("\n")%><%endfor%>)

<%endif%>
<%endfor%>
<%endif%>
<%endif%>
<%endfor%>
<%endif%>

<%marker(local)%>
<%marker(bottom)%>