Changes to handle the fact that clang response files expect unix paths
[MPC.git] / templates / cmake.mpd
blobc9bbcaf367a2bbebf3fbd856776f7b2a8805f269
1 cmake_minimum_required(VERSION <%cmake_minimum_required(3.12.0)%>)
3 <%marker(top)%>
4 project(<%project_name%> <%language%>)
5 option(BUILD_SHARED_LIBS "Build using shared libraries" <%if(need_staticflags)%>OFF<%else%>ON<%endif%>)
7 <%if(pre_find_package)%>
8 <%pre_find_package%>
9 <%endif%>
10 <%foreach(packages)%>
11 find_package(<%package%> REQUIRED)
12 <%endfor%>
14 <%if(header_files)%>
15 set(HEADER_FILES_<%uc(normalize(project_name))%> <%header_files%>)
17 <%endif%>
18 <%if(inline_files)%>
19 set(INLINE_FILES_<%uc(normalize(project_name))%> <%inline_files%>)
21 <%endif%>
22 <%if(template_files)%>
23 set(TEMPLATE_FILES_<%uc(normalize(project_name))%> <%template_files%>)
25 <%endif%>
26 set(SOURCE_FILES_<%uc(normalize(project_name))%> <%source_files%>)
27 <%if(libs || lit_libs || pure_libs)%>
28 <%foreach(libs)%>
29 <%if(cmake_macro(lib))%>
30 if(<%cmake_macro(lib)%>)
31   set(<%cmake_macro(lib)%>_DEFINED TRUE)
32 endif()
33 <%endif%>
34 <%endfor%>
35 if(CMAKE_CONFIGURATION_TYPES)
36 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%>)
37 else()
38 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%>)
39 endif()
40 <%endif%>
41 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%>)
42 <%marker(macros)%>
44 <%if(exeout)%>
45 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_exeout%>)
46 <%if(use_lib_modifier)%>
47 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG <%env_exeout%>)
48 <%endif%>
49 <%endif%>
50 <%if(!exename)%>
51 <%if(libout)%>
52 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY <%env_libout%>)
53 <%if(use_lib_modifier)%>
54 <%foreach(configurations)%>
55 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
56 <%endfor%>
57 <%endif%>
58 <%endif%>
59 <%if(dllout)%>
60 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_dllout%>)
61 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_dllout%>)
62 <%if(use_lib_modifier)%>
63 <%foreach(configurations)%>
64 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
65 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
66 <%endfor%>
67 <%endif%>
68 <%else%>
69 <%if(libout)%>
70 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_libout%>)
71 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_libout%>)
72 <%if(use_lib_modifier)%>
73 <%foreach(configurations)%>
74 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
75 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
76 <%endfor%>
77 <%endif%>
78 <%endif%>
79 <%endif%>
80 <%endif%>
82 <%if(compile_flags)%>
83 target_compile_options(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%compile_flags%>)
85 <%endif%>
86 <%if(exename)%>
87 add_executable(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
88 target_link_libraries(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%>})
89 <%if(staticflags)%>
90 if(NOT BUILD_SHARED_LIBS)
91   target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
92   set_property(TARGET ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTY
93                MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
94 endif()
95 <%endif%>
96 <%else%>
97 <%if(sharedname)%>
98 add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
99 <%if(dynamicflags)%>
100 if(BUILD_SHARED_LIBS)
101   target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%dynamicflags%>)
102 <%if(staticflags)%>
103 else()
104   target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
105 <%endif%>
106 endif()
107 <%else%>
108 <%if(staticflags)%>
109 if(NOT BUILD_SHARED_LIBS)
110   target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
111 endif()
112 <%endif%>
113 <%endif%>
114 target_link_libraries(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%>})
115 <%else%>
116 <%if(staticname)%>
117 add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
118 <%if(staticflags)%>
119 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
120 <%endif%>
121 <%endif%>
122 <%endif%>
123 <%if(use_lib_modifier)%>
124 <%foreach(configurations)%>
125 <%if(lib_modifier)%>
126 set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES <%uc(configuration)%>_POSTFIX "<%lib_modifier%>")
127 <%endif%>
128 <%endfor%>
129 <%endif%>
130 <%endif%>
131 <%if(languagestandard)%>
132 target_compile_features(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC "cxx_std_<%languagestandard%>")
134 <%endif%>
136 if(CMAKE_CONFIGURATION_TYPES)
137 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC
138 <%foreach(configurations)%>                           $<$<CONFIG:<%configuration%>>:MPC_LIB_MODIFIER="${LIBRARY_DECORATOR}<%lib_modifier%>"><%fornotlast("\n")%><%endfor%>)
139 endif()
141 <%if(includes)%>
142 target_include_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_includes%>)
144 <%endif%>
145 <%if(libpaths)%>
146 target_link_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_libpaths%>)
148 <%endif%>
149 <%if(pch_header)%>
150 target_precompile_headers(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%pch_header%>)
152 <%endif%>
153 <%if(pch_source)%>
154 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%pch_defines%>)
155 <%endif%>
156 <%if(macros)%>
157 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%macros%>)
159 <%endif%>
160 <%if(custom_types)%>
161 <%foreach(custom_types)%>
162 <%if(custom_type->input_files)%>
163 <%if(custom_type->command)%>
165 include(<%custom_type%> OPTIONAL)
166 <%foreach(custom_type->input_files)%>
167 <%uc(custom_type)%>_TARGET_SOURCES(
168     ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%custom_type->input_file%>
169     <%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%>)
171 <%endfor%>
172 <%else%>
173 <%foreach(custom_type->input_files)%>
174 <%if(custom_type->input_file->commands)%>
175 <%if(forfirst)%>
176 include(<%custom_type%> OPTIONAL)
177 <%endif%>
178 <%uc(custom_type)%>_TARGET_SOURCES(
179     ${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%custom_type->input_file%>
180 <%foreach(custom_type->input_file->commands)%>
181     <%uc(custom_type->input_file->command->type)%>_OPTIONS <%custom_type->input_file->command->flags%><%fornotlast("\n")%><%endfor%>)
183 <%endif%>
184 <%endfor%>
185 <%endif%>
186 <%endif%>
187 <%endfor%>
188 <%endif%>
190 <%marker(local)%>
191 <%marker(bottom)%>