summaryrefslogtreecommitdiffstats
path: root/cmake/scripts/windows
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cmake/scripts/windows/ArchSetup.cmake128
-rw-r--r--cmake/scripts/windows/CFlagOverrides.cmake10
-rw-r--r--cmake/scripts/windows/CXXFlagOverrides.cmake10
-rw-r--r--cmake/scripts/windows/Install.cmake0
-rw-r--r--cmake/scripts/windows/Macros.cmake66
-rw-r--r--cmake/scripts/windows/PathSetup.cmake34
-rw-r--r--cmake/scripts/windows/tools/patch.cmake50
-rw-r--r--cmake/scripts/windowsstore/ArchSetup.cmake127
-rw-r--r--cmake/scripts/windowsstore/CFlagOverrides.cmake17
-rw-r--r--cmake/scripts/windowsstore/CXXFlagOverrides.cmake17
-rw-r--r--cmake/scripts/windowsstore/Install.cmake10
-rw-r--r--cmake/scripts/windowsstore/Macros.cmake182
-rw-r--r--cmake/scripts/windowsstore/PathSetup.cmake34
-rw-r--r--cmake/scripts/windowsstore/tools/patch.cmake50
14 files changed, 735 insertions, 0 deletions
diff --git a/cmake/scripts/windows/ArchSetup.cmake b/cmake/scripts/windows/ArchSetup.cmake
new file mode 100644
index 0000000..f0f8a08
--- /dev/null
+++ b/cmake/scripts/windows/ArchSetup.cmake
@@ -0,0 +1,128 @@
+# Minimum SDK version we support
+set(VS_MINIMUM_SDK_VERSION 10.0.14393.0)
+
+if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS VS_MINIMUM_SDK_VERSION)
+ message(FATAL_ERROR "Detected Windows SDK version is ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}.\n"
+ "Windows SDK ${VS_MINIMUM_SDK_VERSION} or higher is required.\n"
+ "INFO: Windows SDKs can be installed from the Visual Studio installer.")
+endif()
+
+# -------- Host Settings ---------
+
+set(_gentoolset ${CMAKE_GENERATOR_TOOLSET})
+string(REPLACE "host=" "" HOSTTOOLSET "${_gentoolset}")
+unset(_gentoolset)
+
+# -------- Architecture settings ---------
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(ARCH win32)
+ set(SDK_TARGET_ARCH x86)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH x64)
+ set(SDK_TARGET_ARCH x64)
+endif()
+
+
+# -------- Paths (mainly for find_package) ---------
+
+set(PLATFORM_DIR platform/win32)
+set(APP_RENDER_SYSTEM dx11)
+
+set(CORE_MAIN_SOURCE ${CMAKE_SOURCE_DIR}/xbmc/platform/win32/WinMain.cpp)
+
+# Precompiled headers fail with per target output directory. (needs CMake 3.1)
+set(PRECOMPILEDHEADER_DIR ${PROJECT_BINARY_DIR}/${CORE_BUILD_CONFIG}/objs)
+set(CMAKE_SYSTEM_NAME Windows)
+set(DEPS_FOLDER_RELATIVE project/BuildDependencies)
+set(NATIVEPREFIX ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/tools)
+set(DEPENDS_PATH ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/${ARCH})
+set(MINGW_LIBS_DIR ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/mingwlibs/${ARCH})
+
+# mingw libs
+list(APPEND CMAKE_PREFIX_PATH ${MINGW_LIBS_DIR})
+list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIBS_DIR}/bin)
+
+if(NOT TARBALL_DIR)
+ set(TARBALL_DIR "${CMAKE_SOURCE_DIR}/project/BuildDependencies/downloads")
+endif()
+
+# -------- Compiler options ---------
+
+add_options(CXX ALL_BUILDS "/wd\"4996\"")
+set(ARCH_DEFINES -D_WINDOWS -DTARGET_WINDOWS -DTARGET_WINDOWS_DESKTOP -D__SSE__ -D__SSE2__)
+set(SYSTEM_DEFINES -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DHAS_DX -D__STDC_CONSTANT_MACROS
+ -DTAGLIB_STATIC -DNPT_CONFIG_ENABLE_LOGGING
+ -DPLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi"
+ -DPLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi"
+ -DUNICODE -D_UNICODE
+ -DFRIBIDI_STATIC
+ $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO>)
+
+# Additional SYSTEM_DEFINES
+list(APPEND SYSTEM_DEFINES -DHAS_WIN32_NETWORK -DHAS_FILESYSTEM_SMB)
+
+# The /MP option enables /FS by default.
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+ else()
+ set(MP_FLAG "/MP")
+ endif()
+
+ set(CMAKE_CXX_FLAGS "/permissive- ${MP_FLAG} ${CMAKE_CXX_FLAGS}")
+endif()
+
+# Google Test needs to use shared version of runtime libraries
+set(gtest_force_shared_crt ON CACHE STRING "" FORCE)
+
+
+# -------- Linker options ---------
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
+
+# For #pragma comment(lib X)
+# TODO: It would certainly be better to handle these libraries via CMake modules.
+link_directories(${DEPENDS_PATH}/lib)
+
+# Additional libraries
+list(APPEND DEPLIBS bcrypt.lib d3d11.lib DInput8.lib DSound.lib winmm.lib Mpr.lib Iphlpapi.lib WS2_32.lib
+ PowrProf.lib setupapi.lib Shlwapi.lib dwmapi.lib dxguid.lib DelayImp.lib version.lib
+ crypt32.lib)
+
+# NODEFAULTLIB option
+set(_nodefaultlibs_RELEASE libcmt)
+set(_nodefaultlibs_DEBUG libcmt msvcrt)
+foreach(_lib ${_nodefaultlibs_RELEASE})
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:\"${_lib}\"")
+endforeach()
+foreach(_lib ${_nodefaultlibs_DEBUG})
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:\"${_lib}\"")
+endforeach()
+
+# DELAYLOAD option
+set(_delayloadlibs zlib.dll libmariadb.dll libxslt.dll dnssd.dll dwmapi.dll sqlite3.dll
+ d3dcompiler_47.dll)
+foreach(_lib ${_delayloadlibs})
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:\"${_lib}\"")
+endforeach()
+
+# Make the Release version create a PDB
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+# Minimize the size or the resulting DLLs
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF")
+
+
+# -------- Visual Studio options ---------
+
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+ # Generate a batch file that opens Visual Studio with the necessary env variables set.
+ file(WRITE ${CMAKE_BINARY_DIR}/kodi-sln.bat
+ "@echo off\n"
+ "set KODI_HOME=%~dp0\n"
+ "set PATH=%~dp0\\system\n"
+ "set PreferredToolArchitecture=x64\n"
+ "start %~dp0\\${PROJECT_NAME}.sln")
+endif()
diff --git a/cmake/scripts/windows/CFlagOverrides.cmake b/cmake/scripts/windows/CFlagOverrides.cmake
new file mode 100644
index 0000000..cd96689
--- /dev/null
+++ b/cmake/scripts/windows/CFlagOverrides.cmake
@@ -0,0 +1,10 @@
+if(MSVC)
+ if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+ else()
+ set(MP_FLAG "/MP")
+ endif()
+ set(CMAKE_C_FLAGS "/D_UNICODE /DUNICODE /DRPC_USE_NATIVE_WCHAR ${MP_FLAG} /DWIN32 /D_WINDOWS /W3 /Zi /arch:SSE2")
+ set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0")
+ set(CMAKE_C_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG")
+endif()
diff --git a/cmake/scripts/windows/CXXFlagOverrides.cmake b/cmake/scripts/windows/CXXFlagOverrides.cmake
new file mode 100644
index 0000000..72df9de
--- /dev/null
+++ b/cmake/scripts/windows/CXXFlagOverrides.cmake
@@ -0,0 +1,10 @@
+if(MSVC)
+ if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+ else()
+ set(MP_FLAG "/MP")
+ endif()
+ set(CMAKE_CXX_FLAGS "/D_UNICODE /DUNICODE /DRPC_USE_NATIVE_WCHAR ${MP_FLAG} /DWIN32 /D_WINDOWS /W3 /GR /Zi /EHsc /arch:SSE2")
+ set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0")
+ set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG")
+endif()
diff --git a/cmake/scripts/windows/Install.cmake b/cmake/scripts/windows/Install.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cmake/scripts/windows/Install.cmake
diff --git a/cmake/scripts/windows/Macros.cmake b/cmake/scripts/windows/Macros.cmake
new file mode 100644
index 0000000..2d3500d
--- /dev/null
+++ b/cmake/scripts/windows/Macros.cmake
@@ -0,0 +1,66 @@
+function(core_link_library lib wraplib)
+ message(AUTHOR_WARNING "core_link_library is not compatible with windows.")
+endfunction()
+
+function(find_soname lib)
+ # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h.
+ # Therefore the output of this function is unused.
+endfunction()
+
+# Add precompiled header to target
+# Arguments:
+# target existing target that will be set up to compile with a precompiled header
+# pch_header the precompiled header file
+# pch_source the precompiled header source file
+# Optional Arguments:
+# PCH_TARGET build precompiled header as separate target with the given name
+# so that the same precompiled header can be used for multiple libraries
+# EXCLUDE_SOURCES if not all target sources shall use the precompiled header,
+# the relevant files can be listed here
+# On return:
+# Compiles the pch_source into a precompiled header and adds the header to
+# the given target
+function(add_precompiled_header target pch_header pch_source)
+ cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN})
+
+ if(PCH_PCH_TARGET)
+ set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch)
+ else()
+ set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch)
+ endif()
+
+ # Set compile options and dependency for sources
+ get_target_property(sources ${target} SOURCES)
+ list(REMOVE_ITEM sources ${pch_source})
+ foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES)
+ list(REMOVE_ITEM sources ${exclude_source})
+ endforeach()
+ set_source_files_properties(${sources}
+ PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\""
+ OBJECT_DEPENDS "${pch_binary}")
+
+ # Set compile options for precompiled header
+ if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch)
+ set_source_files_properties(${pch_source}
+ PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\""
+ OBJECT_OUTPUTS "${pch_binary}")
+ endif()
+
+ # Compile precompiled header
+ if(PCH_PCH_TARGET)
+ # As own target for usage in multiple libraries
+ if(NOT TARGET ${PCH_PCH_TARGET}_pch)
+ add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source})
+ set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_NAME vc140
+ COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}
+ FOLDER "Build Utilities")
+ endif()
+ # From VS2012 onwards, precompiled headers have to be linked against (LNK2011).
+ target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch)
+ set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME vc140
+ COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR})
+ else()
+ # As part of the target
+ target_sources(${target} PRIVATE ${pch_source})
+ endif()
+endfunction()
diff --git a/cmake/scripts/windows/PathSetup.cmake b/cmake/scripts/windows/PathSetup.cmake
new file mode 100644
index 0000000..f6defde
--- /dev/null
+++ b/cmake/scripts/windows/PathSetup.cmake
@@ -0,0 +1,34 @@
+if(NOT prefix)
+ set(prefix ${CMAKE_INSTALL_PREFIX})
+else()
+ set(CMAKE_INSTALL_PREFIX ${prefix})
+endif()
+if(NOT exec_prefix)
+ set(exec_prefix ${prefix})
+endif()
+if(NOT libdir)
+ set(libdir ${prefix}/lib)
+endif()
+if(NOT bindir)
+ set(bindir ${prefix}/bin)
+endif()
+if(NOT includedir)
+ set(includedir ${prefix}/include)
+endif()
+if(NOT datarootdir)
+ set(datarootdir ${prefix}/share)
+endif()
+if(NOT datadir)
+ set(datadir ${datarootdir})
+endif()
+
+list(APPEND final_message "-- PATH config --")
+list(APPEND final_message "Prefix: ${prefix}")
+list(APPEND final_message "Libdir: ${libdir}")
+list(APPEND final_message "Bindir: ${bindir}")
+list(APPEND final_message "Includedir: ${includedir}")
+list(APPEND final_message "Datarootdir: ${datarootdir}")
+list(APPEND final_message "Datadir: ${datadir}")
+
+set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/${APP_NAME_LC}\"
+ -DINSTALL_PATH=\"${datarootdir}/${APP_NAME_LC}\")
diff --git a/cmake/scripts/windows/tools/patch.cmake b/cmake/scripts/windows/tools/patch.cmake
new file mode 100644
index 0000000..451fc66
--- /dev/null
+++ b/cmake/scripts/windows/tools/patch.cmake
@@ -0,0 +1,50 @@
+# prioritize Git patch.exe
+find_package(Git)
+if(Git_FOUND)
+ get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY)
+ get_filename_component(GIT_DIR ${GIT_DIR} DIRECTORY)
+endif()
+
+find_program(PATCH_FOUND NAMES patch.exe HINTS ${GIT_DIR} PATH_SUFFIXES usr/bin)
+
+if(PATCH_FOUND)
+ message(STATUS "patch utility found at ${PATCH_FOUND}")
+else()
+ set(PATCH_ARCHIVE_NAME "patch-2.7.6-bin")
+ set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip")
+ set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}")
+ set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE})
+
+ # download the archive containing patch.exe
+ message(STATUS "Downloading patch utility from ${PATCH_URL}...")
+ file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS)
+ list(GET PATCH_DL_STATUS 0 PATCH_RETCODE)
+ if(NOT PATCH_RETCODE EQUAL 0)
+ message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}")
+ endif()
+
+ # extract the archive containing patch.exe
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD}
+ WORKING_DIRECTORY ${BUILD_DIR})
+
+ # make sure the extraction worked and that patch.exe is there
+ set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME})
+ set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe)
+ if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH})
+ message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_PATH}")
+ endif()
+
+ # copy patch.exe into the output directory
+ file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin)
+ # copy patch depends
+ file(GLOB PATCH_BINARIES ${PATCH_PATH}/bin/*.dll)
+ if(NOT "${PATCH_BINARIES}" STREQUAL "")
+ file(INSTALL ${PATCH_BINARIES} DESTINATION ${ADDON_DEPENDS_PATH}/bin)
+ endif()
+
+ # make sure that cmake can find the copied patch.exe
+ find_program(PATCH_FOUND NAMES patch patch.exe)
+ if(NOT PATCH_FOUND)
+ message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin")
+ endif()
+endif()
diff --git a/cmake/scripts/windowsstore/ArchSetup.cmake b/cmake/scripts/windowsstore/ArchSetup.cmake
new file mode 100644
index 0000000..f71ca7a
--- /dev/null
+++ b/cmake/scripts/windowsstore/ArchSetup.cmake
@@ -0,0 +1,127 @@
+# Minimum SDK version we support
+set(VS_MINIMUM_SDK_VERSION 10.0.17763.0)
+
+if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS VS_MINIMUM_SDK_VERSION)
+ message(FATAL_ERROR "Detected Windows SDK version is ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}.\n"
+ "Windows SDK ${VS_MINIMUM_SDK_VERSION} or higher is required.\n"
+ "INFO: Windows SDKs can be installed from the Visual Studio installer.")
+endif()
+
+# -------- Host Settings ---------
+
+set(_gentoolset ${CMAKE_GENERATOR_TOOLSET})
+string(REPLACE "host=" "" HOSTTOOLSET ${_gentoolset})
+unset(_gentoolset)
+
+# -------- Architecture settings ---------
+
+check_symbol_exists(_X86_ "Windows.h" _X86_)
+check_symbol_exists(_AMD64_ "Windows.h" _AMD64_)
+check_symbol_exists(_ARM_ "Windows.h" _ARM_)
+
+if(_X86_)
+ set(ARCH win32)
+ set(SDK_TARGET_ARCH x86)
+elseif(_AMD64_)
+ set(ARCH x64)
+ set(SDK_TARGET_ARCH x64)
+elseif(_ARM_)
+ set(ARCH arm)
+ set(SDK_TARGET_ARCH arm)
+else()
+ message(FATAL_ERROR "Unsupported architecture")
+endif()
+
+unset(_X86_)
+unset(_AMD64_)
+unset(_ARM_)
+
+# -------- Paths (mainly for find_package) ---------
+
+set(PLATFORM_DIR platform/win32)
+set(APP_RENDER_SYSTEM dx11)
+set(CORE_MAIN_SOURCE ${CMAKE_SOURCE_DIR}/xbmc/platform/win10/main.cpp)
+
+# Precompiled headers fail with per target output directory. (needs CMake 3.1)
+set(PRECOMPILEDHEADER_DIR ${PROJECT_BINARY_DIR}/${CORE_BUILD_CONFIG}/objs)
+
+set(CMAKE_SYSTEM_NAME WindowsStore)
+set(CORE_SYSTEM_NAME "windowsstore")
+set(PACKAGE_GUID "281d668b-5739-4abd-b3c2-ed1cda572ed2")
+set(APP_MANIFEST_NAME package.appxmanifest)
+set(DEPS_FOLDER_RELATIVE project/BuildDependencies)
+
+set(NATIVEPREFIX ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/tools)
+set(DEPENDS_PATH ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/win10-${ARCH})
+set(MINGW_LIBS_DIR ${CMAKE_SOURCE_DIR}/${DEPS_FOLDER_RELATIVE}/mingwlibs/win10-${ARCH})
+
+# mingw libs
+list(APPEND CMAKE_PREFIX_PATH ${MINGW_LIBS_DIR})
+list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIBS_DIR}/bin)
+
+if(NOT TARBALL_DIR)
+ set(TARBALL_DIR "${CMAKE_SOURCE_DIR}/project/BuildDependencies/downloads")
+endif()
+
+# -------- Compiler options ---------
+
+add_options(CXX ALL_BUILDS "/wd\"4996\"")
+add_options(CXX ALL_BUILDS "/wd\"4146\"")
+add_options(CXX ALL_BUILDS "/wd\"4251\"")
+add_options(CXX ALL_BUILDS "/wd\"4668\"")
+add_options(CXX ALL_BUILDS "/wd\"5033\"")
+set(ARCH_DEFINES -D_WINDOWS -DTARGET_WINDOWS -DTARGET_WINDOWS_STORE -DXBMC_EXPORT -DMS_UWP -DMS_STORE)
+if(NOT SDK_TARGET_ARCH STREQUAL arm)
+ list(APPEND ARCH_DEFINES -D__SSE__ -D__SSE2__)
+endif()
+set(SYSTEM_DEFINES -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DHAS_DX -D__STDC_CONSTANT_MACROS
+ -DTAGLIB_STATIC -DNPT_CONFIG_ENABLE_LOGGING
+ -DPLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi"
+ -DPLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi"
+ -DUNICODE -D_UNICODE
+ -DFRIBIDI_STATIC
+ $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO>)
+
+# Additional SYSTEM_DEFINES
+list(APPEND SYSTEM_DEFINES -DHAS_WIN10_NETWORK)
+
+# The /MP option enables /FS by default.
+if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+else()
+ set(MP_FLAG "/MP")
+endif()
+set(CMAKE_CXX_FLAGS "${MP_FLAG} ${CMAKE_CXX_FLAGS} /EHsc /await /permissive-")
+# Google Test needs to use shared version of runtime libraries
+set(gtest_force_shared_crt ON CACHE STRING "" FORCE)
+
+
+# -------- Linker options ---------
+
+# For #pragma comment(lib X)
+# TODO: It would certainly be better to handle these libraries via CMake modules.
+link_directories(${MINGW_LIBS_DIR}/lib
+ ${DEPENDS_PATH}/lib)
+
+list(APPEND DEPLIBS bcrypt.lib d3d11.lib WS2_32.lib dxguid.lib dloadhelper.lib WindowsApp.lib)
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WINMD:NO")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt /DEBUG:FASTLINK /OPT:NOREF /OPT:NOICF")
+
+# Make the Release version create a PDB
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+# Minimize the size or the resulting DLLs
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF")
+# remove warning
+set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264")
+
+
+# -------- Visual Studio options ---------
+
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+endif()
+
+# -------- Build options ---------
+
+set(ENABLE_OPTICAL OFF CACHE BOOL "" FORCE)
diff --git a/cmake/scripts/windowsstore/CFlagOverrides.cmake b/cmake/scripts/windowsstore/CFlagOverrides.cmake
new file mode 100644
index 0000000..ab2f59c
--- /dev/null
+++ b/cmake/scripts/windowsstore/CFlagOverrides.cmake
@@ -0,0 +1,17 @@
+# compiler flags
+if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+else()
+ set(MP_FLAG "/MP")
+endif()
+string(APPEND CMAKE_C_FLAGS_INIT " /D_UNICODE /DUNICODE ${MP_FLAG} /DWIN32 /D_WINDOWS /W3 /Zi /DTARGET_WINDOWS")
+string(APPEND CMAKE_C_FLAGS_INIT " /DWINAPI_FAMILY=2 /DTARGET_WINDOWS_STORE /D_WINSOCK_DEPRECATED_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE")
+string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " /D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0")
+string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " /MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG")
+# linker flags
+string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " /DYNAMICBASE /NXCOMPAT /APPCONTAINER")
+# win32 specific flags
+if("$ENV{Platform}" STREQUAL X86)
+ string(APPEND CMAKE_C_FLAGS_INIT " /arch:SSE2")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " /SAFESEH")
+endif()
diff --git a/cmake/scripts/windowsstore/CXXFlagOverrides.cmake b/cmake/scripts/windowsstore/CXXFlagOverrides.cmake
new file mode 100644
index 0000000..4ae3ac3
--- /dev/null
+++ b/cmake/scripts/windowsstore/CXXFlagOverrides.cmake
@@ -0,0 +1,17 @@
+# compiler flags
+if(DEFINED ENV{MAXTHREADS})
+ set(MP_FLAG "/MP$ENV{MAXTHREADS}")
+else()
+ set(MP_FLAG "/MP")
+endif()
+string(APPEND CMAKE_CXX_FLAGS_INIT " /D_UNICODE /DUNICODE ${MP_FLAG} /DWIN32 /D_WINDOWS /W3 /GR /Zi /EHsc /DTARGET_WINDOWS")
+string(APPEND CMAKE_CXX_FLAGS_INIT " /DWINAPI_FAMILY=2 /DTARGET_WINDOWS_STORE /D_WINSOCK_DEPRECATED_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE")
+string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " /D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0")
+string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " /MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG")
+# linker flags
+string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " /DYNAMICBASE /NXCOMPAT /APPCONTAINER")
+# win32 specific flags
+if("$ENV{Platform}" STREQUAL X86)
+ string(APPEND CMAKE_CXX_FLAGS_INIT " /arch:SSE2")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " /SAFESEH")
+endif()
diff --git a/cmake/scripts/windowsstore/Install.cmake b/cmake/scripts/windowsstore/Install.cmake
new file mode 100644
index 0000000..a0522d3
--- /dev/null
+++ b/cmake/scripts/windowsstore/Install.cmake
@@ -0,0 +1,10 @@
+# Fix UWP addons security issue caused by empty __init__.py Python Lib files packaged with Kodi
+set(uwp_pythonlibinit_filepattern "${DEPENDS_PATH}/bin/Python/Lib/__init__.py")
+file(GLOB_RECURSE uwp_pythonlibinit_foundfiles "${uwp_pythonlibinit_filepattern}")
+foreach(uwp_pythonlibinit_file ${uwp_pythonlibinit_foundfiles})
+ file(SIZE "${uwp_pythonlibinit_file}" uwp_pythonlibinit_filesize)
+ if(${uwp_pythonlibinit_filesize} EQUAL 0)
+ message("Adding hash comment character in the following empty file: ${uwp_pythonlibinit_file}")
+ file(APPEND ${uwp_pythonlibinit_file} "#")
+ endif()
+endforeach()
diff --git a/cmake/scripts/windowsstore/Macros.cmake b/cmake/scripts/windowsstore/Macros.cmake
new file mode 100644
index 0000000..713e878
--- /dev/null
+++ b/cmake/scripts/windowsstore/Macros.cmake
@@ -0,0 +1,182 @@
+function(core_link_library lib wraplib)
+ message(AUTHOR_WARNING "core_link_library is not compatible with windows.")
+endfunction()
+
+function(find_soname lib)
+ # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h.
+ # Therefore the output of this function is unused.
+endfunction()
+
+# Add precompiled header to target
+# Arguments:
+# target existing target that will be set up to compile with a precompiled header
+# pch_header the precompiled header file
+# pch_source the precompiled header source file
+# Optional Arguments:
+# PCH_TARGET build precompiled header as separate target with the given name
+# so that the same precompiled header can be used for multiple libraries
+# EXCLUDE_SOURCES if not all target sources shall use the precompiled header,
+# the relevant files can be listed here
+# On return:
+# Compiles the pch_source into a precompiled header and adds the header to
+# the given target
+function(add_precompiled_header target pch_header pch_source)
+ cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN})
+
+ if(PCH_PCH_TARGET)
+ set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch)
+ else()
+ set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch)
+ endif()
+
+ # Set compile options and dependency for sources
+ get_target_property(sources ${target} SOURCES)
+ list(REMOVE_ITEM sources ${pch_source})
+ foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES)
+ list(REMOVE_ITEM sources ${exclude_source})
+ endforeach()
+ set_source_files_properties(${sources}
+ PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\""
+ OBJECT_DEPENDS "${pch_binary}")
+
+ # Set compile options for precompiled header
+ if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch)
+ set_source_files_properties(${pch_source}
+ PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\""
+ OBJECT_OUTPUTS "${pch_binary}")
+ endif()
+
+ # Compile precompiled header
+ if(PCH_PCH_TARGET)
+ # As own target for usage in multiple libraries
+ if(NOT TARGET ${PCH_PCH_TARGET}_pch)
+ add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source})
+ set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_NAME vc140
+ COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}
+ FOLDER "Build Utilities")
+ endif()
+ # From VS2012 onwards, precompiled headers have to be linked against (LNK2011).
+ target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch)
+ set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME vc140
+ COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR})
+ else()
+ # As part of the target
+ target_sources(${target} PRIVATE ${pch_source})
+ endif()
+endfunction()
+
+macro(winstore_set_assets target)
+ file(GLOB ASSET_FILES "${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/media/*.png")
+ set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+ set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "media")
+ source_group("media" FILES ${ASSET_FILES})
+ set(RESOURCES ${RESOURCES} ${ASSET_FILES}
+ "${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/kodi_temp_key.pfx")
+
+ set(LICENSE_FILES
+ ${CMAKE_SOURCE_DIR}/LICENSE.md
+ ${CMAKE_SOURCE_DIR}/privacy-policy.txt)
+ if(EXISTS "${CMAKE_SOURCE_DIR}/known_issues.txt")
+ list(APPEND LICENSE_FILES ${CMAKE_SOURCE_DIR}/known_issues.txt)
+ endif()
+ set_property(SOURCE ${LICENSE_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
+ list(APPEND RESOURCES ${LICENSE_FILES})
+endmacro()
+
+macro(winstore_generate_manifest target)
+ configure_file(
+ ${CMAKE_SOURCE_DIR}/tools/windows/packaging/uwp/${APP_MANIFEST_NAME}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME}
+ @ONLY)
+ set(RESOURCES ${RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME})
+endmacro()
+
+macro(add_deployment_content_group path link match exclude)
+ set(_link "")
+ set(_exclude "")
+ file(TO_NATIVE_PATH ${path} _path)
+ file(TO_NATIVE_PATH ${match} _match)
+ if (NOT "${link}" STREQUAL "")
+ file(TO_NATIVE_PATH ${link} _link)
+ set(_link "${_link}\\")
+ endif()
+ if(NOT "${exclude}" STREQUAL "")
+ string(REPLACE "/" "\\" _exclude ${exclude})
+ endif()
+ string(CONCAT UWP_DEPLOYMENT_CONTENT_STR "${UWP_DEPLOYMENT_CONTENT_STR}"
+ " <EmbedResources Include=\"${_path}\\${_match}\" Exclude=\"${_exclude}\">\n"
+ " <Link>${_link}%(RecursiveDir)%(FileName)%(Extension)</Link>\n"
+ " <DeploymentContent>true</DeploymentContent>\n"
+ " </EmbedResources>\n")
+endmacro()
+
+macro(winstore_append_props target)
+ # exclude debug dlls from packaging
+ set(DEBUG_DLLS zlibd.dll)
+ foreach(_dll ${DEBUG_DLLS})
+ if (DEBUG_DLLS_EXCLUDE)
+ list(APPEND DEBUG_DLLS_EXCLUDE "\;$(BuildRootPath)/dlls/${_dll}")
+ else()
+ list(APPEND DEBUG_DLLS_EXCLUDE "$(BuildRootPath)/dlls/${_dll}")
+ endif()
+ string(CONCAT DEBUG_DLLS_LINKAGE_PROPS "${DEBUG_DLLS_LINKAGE_PROPS}"
+ " <ItemGroup Label=\"Binaries\">\n"
+ " <None Include=\"$(BinPath)\\${_dll}\" Condition=\"'$(Configuration)'=='Debug'\">\n"
+ " <DeploymentContent>true</DeploymentContent>\n"
+ " </None>\n"
+ " </ItemGroup>\n")
+ endforeach(_dll DEBUG_DLLS)
+
+ add_deployment_content_group($(BuildRootPath)/dlls "" *.dll "${DEBUG_DLLS_EXCLUDE}")
+ add_deployment_content_group($(BuildRootPath)/system system **/* "$(BuildRootPath)/**/shaders/**")
+ add_deployment_content_group($(BuildRootPath)/system/shaders system/shaders **/*.fx "")
+ add_deployment_content_group($(BuildRootPath)/media media **/* "")
+ add_deployment_content_group($(BuildRootPath)/userdata userdata **/* "")
+ add_deployment_content_group($(BuildRootPath)/addons addons **/* "")
+ add_deployment_content_group($(BinaryAddonsPath) addons **/* "")
+
+ foreach(xbt_file ${XBT_FILES})
+ file(RELATIVE_PATH relative ${CMAKE_CURRENT_BINARY_DIR} ${xbt_file})
+ file(TO_NATIVE_PATH ${relative} relative)
+ string(CONCAT XBT_FILE_PROPS "${XBT_FILE_PROPS}"
+ " <ItemGroup Label=\"SkinsMedia\">\n"
+ " <None Include=\"$(BuildRootPath)\\${relative}\">\n"
+ " <Link>${relative}</Link>\n"
+ " <DeploymentContent>true</DeploymentContent>\n"
+ " </None>\n"
+ " </ItemGroup>\n")
+ endforeach()
+
+ set(VCPROJECT_PROPS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}.props")
+ file(TO_NATIVE_PATH ${DEPENDS_PATH} DEPENDENCIES_DIR_NATIVE)
+ file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} CMAKE_CURRENT_BINARY_DIR_NATIVE)
+ file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/project/Win32BuildSetup/BUILD_WIN32/addons BINARY_ADDONS_DIR_NATIVE)
+
+ file(WRITE ${VCPROJECT_PROPS_FILE}
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
+ " <ImportGroup Label=\"PropertySheets\" />\n"
+ " <PropertyGroup Label=\"APP_DLLS\">\n"
+ " <BinPath>${DEPENDENCIES_DIR_NATIVE}\\bin</BinPath>\n"
+ " <BuildRootPath>${CMAKE_CURRENT_BINARY_DIR_NATIVE}</BuildRootPath>\n"
+ " <BinaryAddonsPath>${BINARY_ADDONS_DIR_NATIVE}</BinaryAddonsPath>\n"
+ " </PropertyGroup>\n"
+ "${DEBUG_DLLS_LINKAGE_PROPS}"
+ "${XBT_FILE_PROPS}"
+ " <ItemGroup>\n"
+ "${UWP_DEPLOYMENT_CONTENT_STR}"
+ " </ItemGroup>\n"
+ " <Target Name=\"_CollectCustomResources\" Inputs=\"@(EmbedResources)\" Outputs=\"@(EmbedResources->'$(OutputPath)\\PackageLayout\\%(Link)')\" BeforeTargets=\"AssignTargetPaths\">\n"
+ " <Message Text=\"Collecting package resources...\"/>\n"
+ " <ItemGroup>\n"
+ " <None Include=\"@(EmbedResources)\" />\n"
+ " </ItemGroup>\n"
+ " </Target>\n"
+ "</Project>")
+endmacro()
+
+macro(winstore_add_target_properties target)
+ winstore_set_assets(${target})
+ winstore_generate_manifest(${target})
+ winstore_append_props(${target})
+endmacro()
diff --git a/cmake/scripts/windowsstore/PathSetup.cmake b/cmake/scripts/windowsstore/PathSetup.cmake
new file mode 100644
index 0000000..8550616
--- /dev/null
+++ b/cmake/scripts/windowsstore/PathSetup.cmake
@@ -0,0 +1,34 @@
+if(NOT prefix)
+ set(prefix ${CMAKE_INSTALL_PREFIX})
+else()
+ set(CMAKE_INSTALL_PREFIX ${prefix})
+endif()
+if(NOT exec_prefix)
+ set(exec_prefix ${prefix})
+endif()
+if(NOT libdir)
+ set(libdir ${prefix}/lib)
+endif()
+if(NOT bindir)
+ set(bindir ${prefix}/bin)
+endif()
+if(NOT includedir)
+ set(includedir ${prefix}/include)
+endif()
+if(NOT datarootdir)
+ set(datarootdir ${prefix}/share)
+endif()
+if(NOT datadir)
+ set(datadir ${datarootdir})
+endif()
+
+list(APPEND final_message "-- PATH config --")
+list(APPEND final_message "Prefix: ${prefix}")
+list(APPEND final_message "Libdir: ${libdir}")
+list(APPEND final_message "Bindir: ${bindir}")
+list(APPEND final_message "Includedir: ${includedir}")
+list(APPEND final_message "Datarootdir: ${datarootdir}")
+list(APPEND final_message "Datadir: ${datadir}")
+
+set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/kodi\"
+ -DINSTALL_PATH=\"${datarootdir}/kodi\")
diff --git a/cmake/scripts/windowsstore/tools/patch.cmake b/cmake/scripts/windowsstore/tools/patch.cmake
new file mode 100644
index 0000000..451fc66
--- /dev/null
+++ b/cmake/scripts/windowsstore/tools/patch.cmake
@@ -0,0 +1,50 @@
+# prioritize Git patch.exe
+find_package(Git)
+if(Git_FOUND)
+ get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY)
+ get_filename_component(GIT_DIR ${GIT_DIR} DIRECTORY)
+endif()
+
+find_program(PATCH_FOUND NAMES patch.exe HINTS ${GIT_DIR} PATH_SUFFIXES usr/bin)
+
+if(PATCH_FOUND)
+ message(STATUS "patch utility found at ${PATCH_FOUND}")
+else()
+ set(PATCH_ARCHIVE_NAME "patch-2.7.6-bin")
+ set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip")
+ set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}")
+ set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE})
+
+ # download the archive containing patch.exe
+ message(STATUS "Downloading patch utility from ${PATCH_URL}...")
+ file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS)
+ list(GET PATCH_DL_STATUS 0 PATCH_RETCODE)
+ if(NOT PATCH_RETCODE EQUAL 0)
+ message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}")
+ endif()
+
+ # extract the archive containing patch.exe
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD}
+ WORKING_DIRECTORY ${BUILD_DIR})
+
+ # make sure the extraction worked and that patch.exe is there
+ set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME})
+ set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe)
+ if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH})
+ message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_PATH}")
+ endif()
+
+ # copy patch.exe into the output directory
+ file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin)
+ # copy patch depends
+ file(GLOB PATCH_BINARIES ${PATCH_PATH}/bin/*.dll)
+ if(NOT "${PATCH_BINARIES}" STREQUAL "")
+ file(INSTALL ${PATCH_BINARIES} DESTINATION ${ADDON_DEPENDS_PATH}/bin)
+ endif()
+
+ # make sure that cmake can find the copied patch.exe
+ find_program(PATCH_FOUND NAMES patch patch.exe)
+ if(NOT PATCH_FOUND)
+ message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin")
+ endif()
+endif()