1 cmake_minimum_required(VERSION <%cmake_minimum_required(3.12.0)%>)
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)%>
11 find_package(<%package%> REQUIRED)
15 set(HEADER_FILES_<%uc(normalize(project_name))%> <%header_files%>)
19 set(INLINE_FILES_<%uc(normalize(project_name))%> <%inline_files%>)
22 <%if(template_files)%>
23 set(TEMPLATE_FILES_<%uc(normalize(project_name))%> <%template_files%>)
26 set(SOURCE_FILES_<%uc(normalize(project_name))%> <%source_files%>)
27 <%if(libs || lit_libs || pure_libs)%>
29 <%if(cmake_macro(lib))%>
30 if(<%cmake_macro(lib)%>)
31 set(<%cmake_macro(lib)%>_DEFINED TRUE)
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%>)
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%>)
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%>)
45 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_exeout%>)
46 <%if(use_lib_modifier)%>
47 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG <%env_exeout%>)
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%>)
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%>)
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%>)
83 target_compile_options(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%compile_flags%>)
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))%>})
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>")
98 add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
100 if(BUILD_SHARED_LIBS)
101 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%dynamicflags%>)
104 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
109 if(NOT BUILD_SHARED_LIBS)
110 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
114 target_link_libraries(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%>})
117 add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} ${SOURCE_FILES_<%uc(normalize(project_name))%>})
119 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%staticflags%>)
123 <%if(use_lib_modifier)%>
124 <%foreach(configurations)%>
126 set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES <%uc(configuration)%>_POSTFIX "<%lib_modifier%>")
131 <%if(languagestandard)%>
132 target_compile_features(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC "cxx_std_<%languagestandard%>")
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%>)
142 target_include_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_includes%>)
146 target_link_directories(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%env_libpaths%>)
150 target_precompile_headers(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%pch_header%>)
154 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%pch_defines%>)
157 target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%macros%>)
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%>)
173 <%foreach(custom_type->input_files)%>
174 <%if(custom_type->input_file->commands)%>
176 include(<%custom_type%> OPTIONAL)
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%>)