diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/cmake.mpd | 187 | ||||
-rw-r--r-- | templates/cmakedll.mpt | 18 | ||||
-rw-r--r-- | templates/cmakeexe.mpt | 3 |
3 files changed, 208 insertions, 0 deletions
diff --git a/templates/cmake.mpd b/templates/cmake.mpd new file mode 100644 index 00000000..9e39dc43 --- /dev/null +++ b/templates/cmake.mpd @@ -0,0 +1,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)%> diff --git a/templates/cmakedll.mpt b/templates/cmakedll.mpt new file mode 100644 index 00000000..4b83cf64 --- /dev/null +++ b/templates/cmakedll.mpt @@ -0,0 +1,18 @@ +// -*- MPC -*- + +conditional_include "common" + +configurations = Debug Release + +// *********************************************************************** +// Configuration Section +// *********************************************************************** + +Debug { + lib_modifier = d +} + +Release { +} + +conditional_include "user_cmakedll" diff --git a/templates/cmakeexe.mpt b/templates/cmakeexe.mpt new file mode 100644 index 00000000..55c1608f --- /dev/null +++ b/templates/cmakeexe.mpt @@ -0,0 +1,3 @@ +// -*- MPC -*- +conditional_include "cmakedll" +conditional_include "user_cmakeexe" |