diff options
| author | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
| commit | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch) | |
| tree | d8de60fc7e17edeb6f0921726c038ee54b281445 /cmake/scripts/windows | |
| parent | ae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff) | |
| download | kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2 kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip | |
sync with upstream
Diffstat (limited to 'cmake/scripts/windows')
| -rw-r--r-- | cmake/scripts/windows/ArchSetup.cmake | 112 | ||||
| -rw-r--r-- | cmake/scripts/windows/CFlagOverrides.cmake | 5 | ||||
| -rw-r--r-- | cmake/scripts/windows/CXXFlagOverrides.cmake | 5 | ||||
| -rw-r--r-- | cmake/scripts/windows/Install.cmake | 0 | ||||
| -rw-r--r-- | cmake/scripts/windows/Macros.cmake | 66 | ||||
| -rw-r--r-- | cmake/scripts/windows/PathSetup.cmake | 34 | ||||
| -rw-r--r-- | cmake/scripts/windows/tools/patch.cmake | 37 |
7 files changed, 259 insertions, 0 deletions
diff --git a/cmake/scripts/windows/ArchSetup.cmake b/cmake/scripts/windows/ArchSetup.cmake new file mode 100644 index 0000000..11c45cf --- /dev/null +++ b/cmake/scripts/windows/ArchSetup.cmake | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | # -------- Architecture settings --------- | ||
| 2 | |||
| 3 | if(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
| 4 | set(ARCH win32) | ||
| 5 | set(SDK_TARGET_ARCH x86) | ||
| 6 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
| 7 | set(ARCH x64) | ||
| 8 | set(SDK_TARGET_ARCH x64) | ||
| 9 | endif() | ||
| 10 | |||
| 11 | |||
| 12 | # -------- Paths (mainly for find_package) --------- | ||
| 13 | |||
| 14 | set(PLATFORM_DIR platform/win32) | ||
| 15 | |||
| 16 | # Precompiled headers fail with per target output directory. (needs CMake 3.1) | ||
| 17 | set(PRECOMPILEDHEADER_DIR ${PROJECT_BINARY_DIR}/${CORE_BUILD_CONFIG}/objs) | ||
| 18 | |||
| 19 | set(CMAKE_SYSTEM_NAME Windows) | ||
| 20 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SOURCE_DIR}/lib/win32) | ||
| 21 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SOURCE_DIR}/lib/win32/ffmpeg) | ||
| 22 | list(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SOURCE_DIR}/lib/win32/ffmpeg/bin) | ||
| 23 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SOURCE_DIR}/project/BuildDependencies/${ARCH}) | ||
| 24 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SOURCE_DIR}/project/BuildDependencies) | ||
| 25 | |||
| 26 | if(${ARCH} STREQUAL win32) | ||
| 27 | set(PYTHON_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/project/BuildDependencies/include/python) | ||
| 28 | else() | ||
| 29 | set(PYTHON_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/project/BuildDependencies/${ARCH}/include/python) | ||
| 30 | endif() | ||
| 31 | |||
| 32 | |||
| 33 | # -------- Compiler options --------- | ||
| 34 | |||
| 35 | add_options(CXX ALL_BUILDS "/wd\"4996\"") | ||
| 36 | set(ARCH_DEFINES -D_WINDOWS -DTARGET_WINDOWS -D__SSE__ -D__SSE2__) | ||
| 37 | set(SYSTEM_DEFINES -DNOMINMAX -DHAS_DX -D__STDC_CONSTANT_MACROS | ||
| 38 | -DTAGLIB_STATIC -DNPT_CONFIG_ENABLE_LOGGING | ||
| 39 | -DPLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 40 | -DPLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 41 | -DUNICODE -D_UNICODE | ||
| 42 | $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO>) | ||
| 43 | |||
| 44 | if(${ARCH} STREQUAL win32) | ||
| 45 | list(APPEND SYSTEM_DEFINES $<$<CONFIG:Debug>:-D_ITERATOR_DEBUG_LEVEL=0>) | ||
| 46 | endif() | ||
| 47 | |||
| 48 | # Make sure /FS is set for Visual Studio in order to prevent simultaneous access to pdb files. | ||
| 49 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 50 | set(CMAKE_CXX_FLAGS "/MP /FS ${CMAKE_CXX_FLAGS}") | ||
| 51 | endif() | ||
| 52 | |||
| 53 | # Google Test needs to use shared version of runtime libraries | ||
| 54 | set(gtest_force_shared_crt ON CACHE STRING "" FORCE) | ||
| 55 | |||
| 56 | |||
| 57 | # -------- Linker options --------- | ||
| 58 | |||
| 59 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") | ||
| 60 | |||
| 61 | # For #pragma comment(lib X) | ||
| 62 | # TODO: It would certainly be better to handle these libraries via CMake modules. | ||
| 63 | if(${ARCH} STREQUAL win32) | ||
| 64 | link_directories(${CMAKE_SOURCE_DIR}/lib/win32/ffmpeg/bin | ||
| 65 | ${CMAKE_SOURCE_DIR}/project/BuildDependencies/${ARCH}/lib | ||
| 66 | ${CMAKE_SOURCE_DIR}/project/BuildDependencies/lib) | ||
| 67 | else() | ||
| 68 | link_directories(${CMAKE_SOURCE_DIR}/lib/win32/ffmpeg/bin | ||
| 69 | ${CMAKE_SOURCE_DIR}/project/BuildDependencies/${ARCH}/lib) | ||
| 70 | endif() | ||
| 71 | |||
| 72 | # Additional libraries | ||
| 73 | list(APPEND DEPLIBS d3d11.lib DInput8.lib DSound.lib winmm.lib Mpr.lib Iphlpapi.lib WS2_32.lib | ||
| 74 | PowrProf.lib setupapi.lib dwmapi.lib dxguid.lib DelayImp.lib) | ||
| 75 | |||
| 76 | # NODEFAULTLIB option | ||
| 77 | set(_nodefaultlibs_RELEASE libcmt) | ||
| 78 | set(_nodefaultlibs_DEBUG libcmt msvcrt) | ||
| 79 | foreach(_lib ${_nodefaultlibs_RELEASE}) | ||
| 80 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:\"${_lib}\"") | ||
| 81 | endforeach() | ||
| 82 | foreach(_lib ${_nodefaultlibs_DEBUG}) | ||
| 83 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:\"${_lib}\"") | ||
| 84 | endforeach() | ||
| 85 | |||
| 86 | # DELAYLOAD option | ||
| 87 | set(_delayloadlibs zlib.dll libmysql.dll libxslt.dll dnssd.dll dwmapi.dll ssh.dll sqlite3.dll | ||
| 88 | avcodec-57.dll avfilter-6.dll avformat-57.dll avutil-55.dll | ||
| 89 | postproc-54.dll swresample-2.dll swscale-4.dll d3dcompiler_47.dll) | ||
| 90 | foreach(_lib ${_delayloadlibs}) | ||
| 91 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:\"${_lib}\"") | ||
| 92 | endforeach() | ||
| 93 | |||
| 94 | # Make the Release version create a PDB | ||
| 95 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") | ||
| 96 | # Minimize the size or the resulting DLLs | ||
| 97 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF") | ||
| 98 | |||
| 99 | |||
| 100 | # -------- Visual Studio options --------- | ||
| 101 | |||
| 102 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 103 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
| 104 | |||
| 105 | # Generate a batch file that opens Visual Studio with the necessary env variables set. | ||
| 106 | file(WRITE ${CMAKE_BINARY_DIR}/kodi-sln.bat | ||
| 107 | "@echo off\n" | ||
| 108 | "set KODI_HOME=%~dp0\n" | ||
| 109 | "set PATH=%~dp0\\system\n" | ||
| 110 | "set PreferredToolArchitecture=x64\n" | ||
| 111 | "start %~dp0\\${PROJECT_NAME}.sln") | ||
| 112 | endif() | ||
diff --git a/cmake/scripts/windows/CFlagOverrides.cmake b/cmake/scripts/windows/CFlagOverrides.cmake new file mode 100644 index 0000000..b9d8948 --- /dev/null +++ b/cmake/scripts/windows/CFlagOverrides.cmake | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | if(MSVC) | ||
| 2 | set(CMAKE_C_FLAGS_INIT "/D_UNICODE /DUNICODE /DRPC_USE_NATIVE_WCHAR /MP /DWIN32 /D_WINDOWS /W3 /Zi /arch:SSE2") | ||
| 3 | set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0") | ||
| 4 | set(CMAKE_C_FLAGS_RELEASE_INIT "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG") | ||
| 5 | endif() | ||
diff --git a/cmake/scripts/windows/CXXFlagOverrides.cmake b/cmake/scripts/windows/CXXFlagOverrides.cmake new file mode 100644 index 0000000..c450a5c --- /dev/null +++ b/cmake/scripts/windows/CXXFlagOverrides.cmake | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | if(MSVC) | ||
| 2 | set(CMAKE_CXX_FLAGS_INIT "/D_UNICODE /DUNICODE /DRPC_USE_NATIVE_WCHAR /MP /DWIN32 /D_WINDOWS /W3 /GR /Zi /EHsc /arch:SSE2") | ||
| 3 | set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=0") | ||
| 4 | set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG") | ||
| 5 | 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 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | message(AUTHOR_WARNING "core_link_library is not compatible with windows.") | ||
| 3 | endfunction() | ||
| 4 | |||
| 5 | function(find_soname lib) | ||
| 6 | # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h. | ||
| 7 | # Therefore the output of this function is unused. | ||
| 8 | endfunction() | ||
| 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 | ||
| 23 | function(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() | ||
| 66 | 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 @@ | |||
| 1 | if(NOT prefix) | ||
| 2 | set(prefix ${CMAKE_INSTALL_PREFIX}) | ||
| 3 | else() | ||
| 4 | set(CMAKE_INSTALL_PREFIX ${prefix}) | ||
| 5 | endif() | ||
| 6 | if(NOT exec_prefix) | ||
| 7 | set(exec_prefix ${prefix}) | ||
| 8 | endif() | ||
| 9 | if(NOT libdir) | ||
| 10 | set(libdir ${prefix}/lib) | ||
| 11 | endif() | ||
| 12 | if(NOT bindir) | ||
| 13 | set(bindir ${prefix}/bin) | ||
| 14 | endif() | ||
| 15 | if(NOT includedir) | ||
| 16 | set(includedir ${prefix}/include) | ||
| 17 | endif() | ||
| 18 | if(NOT datarootdir) | ||
| 19 | set(datarootdir ${prefix}/share) | ||
| 20 | endif() | ||
| 21 | if(NOT datadir) | ||
| 22 | set(datadir ${datarootdir}) | ||
| 23 | endif() | ||
| 24 | |||
| 25 | list(APPEND final_message "-- PATH config --") | ||
| 26 | list(APPEND final_message "Prefix: ${prefix}") | ||
| 27 | list(APPEND final_message "Libdir: ${libdir}") | ||
| 28 | list(APPEND final_message "Bindir: ${bindir}") | ||
| 29 | list(APPEND final_message "Includedir: ${includedir}") | ||
| 30 | list(APPEND final_message "Datarootdir: ${datarootdir}") | ||
| 31 | list(APPEND final_message "Datadir: ${datadir}") | ||
| 32 | |||
| 33 | set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/${APP_NAME_LC}\" | ||
| 34 | -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..0ef2952 --- /dev/null +++ b/cmake/scripts/windows/tools/patch.cmake | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 2 | if(PATCH_FOUND) | ||
| 3 | message(STATUS "patch utility found at ${PATCH_FOUND}") | ||
| 4 | else() | ||
| 5 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-1") | ||
| 6 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") | ||
| 7 | set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") | ||
| 8 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) | ||
| 9 | |||
| 10 | # download the archive containing patch.exe | ||
| 11 | message(STATUS "Downloading patch utility from ${PATCH_URL}...") | ||
| 12 | file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) | ||
| 13 | list(GET PATCH_DL_STATUS 0 PATCH_RETCODE) | ||
| 14 | if(NOT PATCH_RETCODE EQUAL 0) | ||
| 15 | message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}") | ||
| 16 | endif() | ||
| 17 | |||
| 18 | # extract the archive containing patch.exe | ||
| 19 | execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD} | ||
| 20 | WORKING_DIRECTORY ${BUILD_DIR}) | ||
| 21 | |||
| 22 | # make sure the extraction worked and that patch.exe is there | ||
| 23 | set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME}) | ||
| 24 | set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe) | ||
| 25 | if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH}) | ||
| 26 | message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_PATH}") | ||
| 27 | endif() | ||
| 28 | |||
| 29 | # copy patch.exe into the output directory | ||
| 30 | file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin) | ||
| 31 | |||
| 32 | # make sure that cmake can find the copied patch.exe | ||
| 33 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 34 | if(NOT PATCH_FOUND) | ||
| 35 | message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin") | ||
| 36 | endif() | ||
| 37 | endif() | ||
