diff options
| author | manuel <manuel@mausz.at> | 2016-03-08 21:02:53 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2016-03-08 21:02:53 +0100 |
| commit | 9fc8b732737f139d3e466510d75668ab45578960 (patch) | |
| tree | 76db9bf5cb8cc869be908a5ed3d6f4cca3e3608a /project/cmake/scripts/windows | |
| parent | b75e2659df11c23aa921d2eed83c23adc282ed27 (diff) | |
| download | kodi-pvr-build-9fc8b732737f139d3e466510d75668ab45578960.tar.gz kodi-pvr-build-9fc8b732737f139d3e466510d75668ab45578960.tar.bz2 kodi-pvr-build-9fc8b732737f139d3e466510d75668ab45578960.zip | |
sync with upstream
Diffstat (limited to 'project/cmake/scripts/windows')
| -rw-r--r-- | project/cmake/scripts/windows/archsetup.cmake | 91 | ||||
| -rw-r--r-- | project/cmake/scripts/windows/install.cmake | 0 | ||||
| -rw-r--r-- | project/cmake/scripts/windows/macros.cmake | 143 | ||||
| -rw-r--r-- | project/cmake/scripts/windows/pathsetup.cmake | 34 |
4 files changed, 268 insertions, 0 deletions
diff --git a/project/cmake/scripts/windows/archsetup.cmake b/project/cmake/scripts/windows/archsetup.cmake new file mode 100644 index 0000000..baa3624 --- /dev/null +++ b/project/cmake/scripts/windows/archsetup.cmake | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | # -------- Architecture settings --------- | ||
| 2 | |||
| 3 | set(ARCH win32) | ||
| 4 | |||
| 5 | |||
| 6 | # -------- Paths (mainly for find_package) --------- | ||
| 7 | |||
| 8 | set(PLATFORM_DIR win32) | ||
| 9 | |||
| 10 | # Precompiled headers fail with per target output directory. (needs CMake 3.1) | ||
| 11 | set(PRECOMPILEDHEADER_DIR ${PROJECT_BINARY_DIR}/${CORE_BUILD_CONFIG}/objs) | ||
| 12 | |||
| 13 | set(CMAKE_SYSTEM_NAME Windows) | ||
| 14 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32) | ||
| 15 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg) | ||
| 16 | list(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg/bin) | ||
| 17 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../BuildDependencies) | ||
| 18 | set(CONFIGURATION_LIBDIR lib/${CORE_BUILD_CONFIG}-vc120) | ||
| 19 | set(CONFIGURATION_LIBDIR_RELEASE lib/Release-vc120) | ||
| 20 | set(CONFIGURATION_LIBDIR_DEBUG lib/Debug-vc120) | ||
| 21 | |||
| 22 | set(JPEG_NAMES ${JPEG_NAMES} jpeg-static) | ||
| 23 | set(PYTHON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../BuildDependencies/include/python) | ||
| 24 | |||
| 25 | |||
| 26 | # -------- Compiler options --------- | ||
| 27 | |||
| 28 | add_options(CXX ALL_BUILDS "/wd\"4996\"") | ||
| 29 | set(ARCH_DEFINES -D_WINDOWS -DTARGET_WINDOWS) | ||
| 30 | set(SYSTEM_DEFINES -DNOMINMAX -D_USE_32BIT_TIME_T -DHAS_DX -D__STDC_CONSTANT_MACROS | ||
| 31 | -DTAGLIB_STATIC -DNPT_CONFIG_ENABLE_LOGGING | ||
| 32 | -DPLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 33 | -DPLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 34 | -DBUILDING_WITH_CMAKE | ||
| 35 | $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO -D_SECURE_SCL=0 -D_HAS_ITERATOR_DEBUGGING=0>) | ||
| 36 | |||
| 37 | # Compile with /MT (to be compatible with the dependent libraries) | ||
| 38 | foreach(CompilerFlag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE | ||
| 39 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) | ||
| 40 | string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") | ||
| 41 | endforeach() | ||
| 42 | |||
| 43 | # Make sure /FS is set for Visual Studio in order to prevent simultanious access to pdb files. | ||
| 44 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 45 | set(CMAKE_CXX_FLAGS "/MP /FS ${CMAKE_CXX_FLAGS}") | ||
| 46 | endif() | ||
| 47 | |||
| 48 | |||
| 49 | # -------- Linker options --------- | ||
| 50 | |||
| 51 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") | ||
| 52 | |||
| 53 | # For #pragma comment(lib X) | ||
| 54 | # TODO: It would certainly be better to handle these libraries via CMake modules. | ||
| 55 | link_directories(${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg/bin | ||
| 56 | ${PROJECT_SOURCE_DIR}/../BuildDependencies/lib | ||
| 57 | ${PROJECT_SOURCE_DIR}/../BuildDependencies/${CONFIGURATION_LIBDIR}) | ||
| 58 | |||
| 59 | # Additional libraries | ||
| 60 | list(APPEND DEPLIBS d3d11.lib DInput8.lib DSound.lib winmm.lib Mpr.lib Iphlpapi.lib | ||
| 61 | PowrProf.lib setupapi.lib dwmapi.lib yajl.lib dxguid.lib DelayImp.lib) | ||
| 62 | |||
| 63 | # NODEFAULTLIB option | ||
| 64 | set(_nodefaultlibs_RELEASE libc msvcrt libci msvcprt) | ||
| 65 | set(_nodefaultlibs_DEBUG libcpmt libc msvcrt libcmt msvcrtd msvcprtd) | ||
| 66 | foreach(_lib ${_nodefaultlibs_RELEASE}) | ||
| 67 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:\"${_lib}\"") | ||
| 68 | endforeach() | ||
| 69 | foreach(_lib ${_nodefaultlibs_DEBUG}) | ||
| 70 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:\"${_lib}\"") | ||
| 71 | endforeach() | ||
| 72 | |||
| 73 | # DELAYLOAD option | ||
| 74 | set(_delayloadlibs libxslt.dll dnssd.dll dwmapi.dll ssh.dll sqlite3.dll | ||
| 75 | avcodec-56.dll avfilter-5.dll avformat-56.dll avutil-54.dll | ||
| 76 | postproc-53.dll swresample-1.dll swscale-3.dll d3dcompiler_47.dll) | ||
| 77 | foreach(_lib ${_delayloadlibs}) | ||
| 78 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:\"${_lib}\"") | ||
| 79 | endforeach() | ||
| 80 | |||
| 81 | # Make the Release version create a PDB | ||
| 82 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") | ||
| 83 | # Minimize the size or the resulting DLLs | ||
| 84 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF") | ||
| 85 | |||
| 86 | |||
| 87 | # -------- Visual Studio options --------- | ||
| 88 | |||
| 89 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 90 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
| 91 | endif() | ||
diff --git a/project/cmake/scripts/windows/install.cmake b/project/cmake/scripts/windows/install.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/cmake/scripts/windows/install.cmake | |||
diff --git a/project/cmake/scripts/windows/macros.cmake b/project/cmake/scripts/windows/macros.cmake new file mode 100644 index 0000000..6aabf7d --- /dev/null +++ b/project/cmake/scripts/windows/macros.cmake | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | # set(export -Wl,--unresolved-symbols=ignore-all | ||
| 3 | # `cat ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def` | ||
| 4 | # ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) | ||
| 5 | # set(check_arg "") | ||
| 6 | # if(TARGET ${lib}) | ||
| 7 | # set(target ${lib}) | ||
| 8 | # set(link_lib ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${lib}/${lib}.a) | ||
| 9 | # set(check_arg ${ARGV2}) | ||
| 10 | # set(data_arg ${ARGV3}) | ||
| 11 | # else() | ||
| 12 | # set(target ${ARGV2}) | ||
| 13 | # set(link_lib ${lib}) | ||
| 14 | # set(check_arg ${ARGV3}) | ||
| 15 | # set(data_arg ${ARGV4}) | ||
| 16 | # endif() | ||
| 17 | # if(check_arg STREQUAL "export") | ||
| 18 | # set(export ${export} | ||
| 19 | # -Wl,--version-script=${ARGV3}) | ||
| 20 | # elseif(check_arg STREQUAL "nowrap") | ||
| 21 | # set(export ${data_arg}) | ||
| 22 | # elseif(check_arg STREQUAL "extras") | ||
| 23 | # foreach(arg ${data_arg}) | ||
| 24 | # list(APPEND export ${arg}) | ||
| 25 | # endforeach() | ||
| 26 | # endif() | ||
| 27 | # get_filename_component(dir ${wraplib} PATH) | ||
| 28 | # add_custom_command(OUTPUT ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 29 | # COMMAND cmake -E make_directory ${dir} | ||
| 30 | # COMMAND ${CMAKE_C_COMPILER} | ||
| 31 | # ARGS -Wl,--whole-archive | ||
| 32 | # ${link_lib} | ||
| 33 | # -Wl,--no-whole-archive -lm | ||
| 34 | # -shared -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 35 | # ${export} | ||
| 36 | # DEPENDS ${target} wrapper.def wrapper) | ||
| 37 | # list(APPEND WRAP_FILES ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 38 | # set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE) | ||
| 39 | endfunction() | ||
| 40 | |||
| 41 | function(find_soname lib) | ||
| 42 | # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h. | ||
| 43 | # Therefore the output of this function is unused. | ||
| 44 | endfunction() | ||
| 45 | |||
| 46 | # Add precompiled header to target | ||
| 47 | # Arguments: | ||
| 48 | # target existing target that will be set up to compile with a precompiled header | ||
| 49 | # pch_header the precompiled header file | ||
| 50 | # pch_source the precompiled header source file | ||
| 51 | # Optional Arguments: | ||
| 52 | # PCH_TARGET build precompiled header as separate target with the given name | ||
| 53 | # so that the same precompiled header can be used for multiple libraries | ||
| 54 | # EXCLUDE_SOURCES if not all target sources shall use the precompiled header, | ||
| 55 | # the relevant files can be listed here | ||
| 56 | # On return: | ||
| 57 | # Compiles the pch_source into a precompiled header and adds the header to | ||
| 58 | # the given target | ||
| 59 | function(add_precompiled_header target pch_header pch_source) | ||
| 60 | cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN}) | ||
| 61 | |||
| 62 | if(PCH_PCH_TARGET) | ||
| 63 | set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch) | ||
| 64 | else() | ||
| 65 | set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch) | ||
| 66 | endif() | ||
| 67 | |||
| 68 | # Set compile options and dependency for sources | ||
| 69 | get_target_property(sources ${target} SOURCES) | ||
| 70 | list(REMOVE_ITEM sources ${pch_source}) | ||
| 71 | foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES) | ||
| 72 | list(REMOVE_ITEM sources ${exclude_source}) | ||
| 73 | endforeach() | ||
| 74 | set_source_files_properties(${sources} | ||
| 75 | PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\"" | ||
| 76 | OBJECT_DEPENDS "${pch_binary}") | ||
| 77 | |||
| 78 | # Set compile options for precompiled header | ||
| 79 | if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch) | ||
| 80 | set_source_files_properties(${pch_source} | ||
| 81 | PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\"" | ||
| 82 | OBJECT_OUTPUTS "${pch_binary}") | ||
| 83 | endif() | ||
| 84 | |||
| 85 | # Compile precompiled header | ||
| 86 | if(PCH_PCH_TARGET) | ||
| 87 | # As own target for usage in multiple libraries | ||
| 88 | if(NOT TARGET ${PCH_PCH_TARGET}_pch) | ||
| 89 | add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source}) | ||
| 90 | set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}) | ||
| 91 | endif() | ||
| 92 | # From VS2012 onwards, precompiled headers have to be linked against (LNK2011). | ||
| 93 | target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch) | ||
| 94 | set_target_properties(${target} PROPERTIES COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}) | ||
| 95 | else() | ||
| 96 | # As part of the target | ||
| 97 | target_sources(${target} PRIVATE ${pch_source}) | ||
| 98 | endif() | ||
| 99 | endfunction() | ||
| 100 | |||
| 101 | # Adds an FX-compiled shader to a target | ||
| 102 | # Creates a custom command that FX-compiles the given shader and adds the | ||
| 103 | # generated header file to the given target. | ||
| 104 | # Arguments: | ||
| 105 | # target Target to add the FX-compiled shader to | ||
| 106 | # hlsl HLSL shader input file | ||
| 107 | # profile HLSL profile that specifies the shader model | ||
| 108 | # entrypoint Shader entry point | ||
| 109 | # On return: | ||
| 110 | # FXC_FILE is set to the name of the generated header file. | ||
| 111 | function(add_shader_dx target hlsl profile entrypoint) | ||
| 112 | get_filename_component(file ${hlsl} NAME_WE) | ||
| 113 | add_custom_command(OUTPUT ${file}.h | ||
| 114 | COMMAND ${FXC} /Fh ${file}.h | ||
| 115 | /E ${entrypoint} | ||
| 116 | /T ${profile} | ||
| 117 | /Vn ${file} | ||
| 118 | /Qstrip_reflect | ||
| 119 | ${hlsl} | ||
| 120 | DEPENDS ${hlsl} | ||
| 121 | COMMENT "FX compile ${hlsl}" | ||
| 122 | VERBATIM) | ||
| 123 | target_sources(${target} PRIVATE ${file}.h) | ||
| 124 | target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
| 125 | endfunction() | ||
| 126 | |||
| 127 | # Copies the main dlls to the root of the buildtree | ||
| 128 | # On return: | ||
| 129 | # files added to ${install_data}, mirror in build tree | ||
| 130 | function(copy_main_dlls_to_buildtree) | ||
| 131 | set(dir ${PROJECT_SOURCE_DIR}/../Win32BuildSetup/dependencies) | ||
| 132 | file(GLOB_RECURSE files ${dir}/*) | ||
| 133 | foreach(file ${files}) | ||
| 134 | copy_file_to_buildtree(${file} ${dir}) | ||
| 135 | endforeach() | ||
| 136 | |||
| 137 | if(D3DCOMPILER_DLL) | ||
| 138 | get_filename_component(d3dcompiler_dir ${D3DCOMPILER_DLL} DIRECTORY) | ||
| 139 | copy_file_to_buildtree(${D3DCOMPILER_DLL} ${d3dcompiler_dir}) | ||
| 140 | endif() | ||
| 141 | |||
| 142 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 143 | endfunction() | ||
diff --git a/project/cmake/scripts/windows/pathsetup.cmake b/project/cmake/scripts/windows/pathsetup.cmake new file mode 100644 index 0000000..940fb62 --- /dev/null +++ b/project/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}/xbmc\" | ||
| 34 | -DINSTALL_PATH=\"${datarootdir}/xbmc\") | ||
