summaryrefslogtreecommitdiffstats
path: root/cmake/scripts/windowsstore/Macros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/scripts/windowsstore/Macros.cmake')
-rw-r--r--cmake/scripts/windowsstore/Macros.cmake181
1 files changed, 181 insertions, 0 deletions
diff --git a/cmake/scripts/windowsstore/Macros.cmake b/cmake/scripts/windowsstore/Macros.cmake
new file mode 100644
index 0000000..6e7d1d0
--- /dev/null
+++ b/cmake/scripts/windowsstore/Macros.cmake
@@ -0,0 +1,181 @@
1function(core_link_library lib wraplib)
2 message(AUTHOR_WARNING "core_link_library is not compatible with windows.")
3endfunction()
4
5function(find_soname lib)
6 # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h.
7 # Therefore the output of this function is unused.
8endfunction()
9
10# Add precompiled header to target
11# Arguments:
12# target existing target that will be set up to compile with a precompiled header
13# pch_header the precompiled header file
14# pch_source the precompiled header source file
15# Optional Arguments:
16# PCH_TARGET build precompiled header as separate target with the given name
17# so that the same precompiled header can be used for multiple libraries
18# EXCLUDE_SOURCES if not all target sources shall use the precompiled header,
19# the relevant files can be listed here
20# On return:
21# Compiles the pch_source into a precompiled header and adds the header to
22# the given target
23function(add_precompiled_header target pch_header pch_source)
24 cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN})
25
26 if(PCH_PCH_TARGET)
27 set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch)
28 else()
29 set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch)
30 endif()
31
32 # Set compile options and dependency for sources
33 get_target_property(sources ${target} SOURCES)
34 list(REMOVE_ITEM sources ${pch_source})
35 foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES)
36 list(REMOVE_ITEM sources ${exclude_source})
37 endforeach()
38 set_source_files_properties(${sources}
39 PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\""
40 OBJECT_DEPENDS "${pch_binary}")
41
42 # Set compile options for precompiled header
43 if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch)
44 set_source_files_properties(${pch_source}
45 PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\""
46 OBJECT_OUTPUTS "${pch_binary}")
47 endif()
48
49 # Compile precompiled header
50 if(PCH_PCH_TARGET)
51 # As own target for usage in multiple libraries
52 if(NOT TARGET ${PCH_PCH_TARGET}_pch)
53 add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source})
54 set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_NAME vc140
55 COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}
56 FOLDER "Build Utilities")
57 endif()
58 # From VS2012 onwards, precompiled headers have to be linked against (LNK2011).
59 target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch)
60 set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME vc140
61 COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR})
62 else()
63 # As part of the target
64 target_sources(${target} PRIVATE ${pch_source})
65 endif()
66endfunction()
67
68macro(winstore_set_assets target)
69 file(GLOB ASSET_FILES "${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/media/*.png")
70 set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
71 set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "media")
72 source_group("media" FILES ${ASSET_FILES})
73 set(RESOURCES ${RESOURCES} ${ASSET_FILES}
74 "${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/kodi_temp_key.pfx")
75 set(LICENSE_FILES
76 ${CMAKE_SOURCE_DIR}/LICENSE.GPL
77 ${CMAKE_SOURCE_DIR}/copying.txt
78 ${CMAKE_SOURCE_DIR}/privacy-policy.txt)
79 if(EXISTS "${CMAKE_SOURCE_DIR}/known_issues.txt")
80 list(APPEND LICENSE_FILES ${CMAKE_SOURCE_DIR}/known_issues.txt)
81 endif()
82 set_property(SOURCE ${LICENSE_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
83 list(APPEND RESOURCES ${LICENSE_FILES})
84endmacro()
85
86macro(winstore_generate_manifest target)
87 configure_file(
88 ${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/${APP_MANIFEST_NAME}.in
89 ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME}
90 @ONLY)
91 set(RESOURCES ${RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME})
92endmacro()
93
94macro(add_deployment_content_group path link match exclude)
95 set(_link "")
96 set(_exclude "")
97 file(TO_NATIVE_PATH ${path} _path)
98 file(TO_NATIVE_PATH ${match} _match)
99 if (NOT "${link}" STREQUAL "")
100 file(TO_NATIVE_PATH ${link} _link)
101 set(_link "${_link}\\")
102 endif()
103 if(NOT "${exclude}" STREQUAL "")
104 string(REPLACE "/" "\\" _exclude ${exclude})
105 endif()
106 string(CONCAT UWP_DEPLOYMENT_CONTENT_STR "${UWP_DEPLOYMENT_CONTENT_STR}"
107 " <EmbedResources Include=\"${_path}\\${_match}\" Exclude=\"${_exclude}\">\n"
108 " <Link>${_link}%(RecursiveDir)%(FileName)%(Extension)</Link>\n"
109 " <DeploymentContent>true</DeploymentContent>\n"
110 " </EmbedResources>\n")
111endmacro()
112
113macro(winstore_append_props target)
114 # exclude debug dlls from packaging
115 set(DEBUG_DLLS zlibd.dll freetyped.dll sqlite3d.dll)
116 foreach(_dll ${DEBUG_DLLS})
117 if (DEBUG_DLLS_EXCLUDE)
118 list(APPEND DEBUG_DLLS_EXCLUDE "\;$(BuildRootPath)/dlls/${_dll}")
119 else()
120 list(APPEND DEBUG_DLLS_EXCLUDE "$(BuildRootPath)/dlls/${_dll}")
121 endif()
122 string(CONCAT DEBUG_DLLS_LINKAGE_PROPS "${DEBUG_DLLS_LINKAGE_PROPS}"
123 " <ItemGroup Label=\"Binaries\">\n"
124 " <None Include=\"$(BinPath)\\${_dll}\" Condition=\"'$(Configuration)'=='Debug'\">\n"
125 " <DeploymentContent>true</DeploymentContent>\n"
126 " </None>\n"
127 " </ItemGroup>\n")
128 endforeach(_dll DEBUG_DLLS)
129
130 add_deployment_content_group($(BuildRootPath)/dlls "" *.dll "${DEBUG_DLLS_EXCLUDE}")
131 add_deployment_content_group($(BuildRootPath)/system system **/* "$(BuildRootPath)/**/*.glsl")
132 add_deployment_content_group($(BuildRootPath)/media media **/* "")
133 add_deployment_content_group($(BuildRootPath)/userdata userdata **/* "")
134 add_deployment_content_group($(BuildRootPath)/addons addons **/* "")
135 add_deployment_content_group($(BinaryAddonsPath) addons **/* "")
136
137 foreach(xbt_file ${XBT_FILES})
138 file(RELATIVE_PATH relative ${CMAKE_CURRENT_BINARY_DIR} ${xbt_file})
139 file(TO_NATIVE_PATH ${relative} relative)
140 string(CONCAT XBT_FILE_PROPS "${XBT_FILE_PROPS}"
141 " <ItemGroup Label=\"SkinsMedia\">\n"
142 " <None Include=\"$(BuildRootPath)\\${relative}\">\n"
143 " <Link>${relative}</Link>\n"
144 " <DeploymentContent>true</DeploymentContent>\n"
145 " </None>\n"
146 " </ItemGroup>\n")
147 endforeach()
148
149 set(VCPROJECT_PROPS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}.props")
150 file(TO_NATIVE_PATH ${DEPENDENCIES_DIR} DEPENDENCIES_DIR_NATIVE)
151 file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} CMAKE_CURRENT_BINARY_DIR_NATIVE)
152 file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/project/Win32BuildSetup/BUILD_WIN32/addons BINARY_ADDONS_DIR_NATIVE)
153
154 file(WRITE ${VCPROJECT_PROPS_FILE}
155 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
156 "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
157 " <ImportGroup Label=\"PropertySheets\" />\n"
158 " <PropertyGroup Label=\"APP_DLLS\">\n"
159 " <BinPath>${DEPENDENCIES_DIR_NATIVE}\\bin</BinPath>\n"
160 " <BuildRootPath>${CMAKE_CURRENT_BINARY_DIR_NATIVE}</BuildRootPath>\n"
161 " <BinaryAddonsPath>${BINARY_ADDONS_DIR_NATIVE}</BinaryAddonsPath>\n"
162 " </PropertyGroup>\n"
163 "${DEBUG_DLLS_LINKAGE_PROPS}"
164 "${XBT_FILE_PROPS}"
165 " <ItemGroup>\n"
166 "${UWP_DEPLOYMENT_CONTENT_STR}"
167 " </ItemGroup>\n"
168 " <Target Name=\"_CollectCustomResources\" Inputs=\"@(EmbedResources)\" Outputs=\"@(EmbedResources->'$(OutputPath)\\PackageLayout\\%(Link)')\" BeforeTargets=\"AssignTargetPaths\">\n"
169 " <Message Text=\"Collecting package resources...\"/>\n"
170 " <ItemGroup>\n"
171 " <None Include=\"@(EmbedResources)\" />\n"
172 " </ItemGroup>\n"
173 " </Target>\n"
174 "</Project>")
175endmacro()
176
177macro(winstore_add_target_properties target)
178 winstore_set_assets(${target})
179 winstore_generate_manifest(${target})
180 winstore_append_props(${target})
181endmacro() \ No newline at end of file