diff options
Diffstat (limited to '')
-rw-r--r-- | cmake/scripts/linux/ArchSetup.cmake | 207 | ||||
-rw-r--r-- | cmake/scripts/linux/CodeCoverage.cmake | 97 | ||||
-rw-r--r-- | cmake/scripts/linux/ExtraTargets.cmake | 32 | ||||
-rw-r--r-- | cmake/scripts/linux/Install.cmake | 329 | ||||
-rw-r--r-- | cmake/scripts/linux/Linkers.txt | 4 | ||||
-rw-r--r-- | cmake/scripts/linux/Macros.cmake | 95 | ||||
-rw-r--r-- | cmake/scripts/linux/PathSetup.cmake | 40 |
7 files changed, 804 insertions, 0 deletions
diff --git a/cmake/scripts/linux/ArchSetup.cmake b/cmake/scripts/linux/ArchSetup.cmake new file mode 100644 index 0000000..4083483 --- /dev/null +++ b/cmake/scripts/linux/ArchSetup.cmake @@ -0,0 +1,207 @@ +include(cmake/scripts/linux/Linkers.txt) + +# Main cpp +set(CORE_MAIN_SOURCE ${CMAKE_SOURCE_DIR}/xbmc/platform/posix/main.cpp) + +# we always want to use GNU features if available, so set _GNU_SOURCE +set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_LINUX -D_GNU_SOURCE) +set(SYSTEM_DEFINES -D__STDC_CONSTANT_MACROS -D_FILE_OFFSET_BITS=64) +set(PLATFORM_DIR platform/linux) +set(PLATFORMDEFS_DIR platform/posix) +set(CMAKE_SYSTEM_NAME Linux) +if(WITH_ARCH) + set(ARCH ${WITH_ARCH}) +else() + if(CPU STREQUAL x86_64) + set(ARCH x86_64-linux) + set(NEON False) + elseif(CPU MATCHES "i.86") + set(ARCH i486-linux) + set(NEON False) + add_options(CXX ALL_BUILDS "-msse") + elseif(CPU STREQUAL arm1176jzf-s) + set(ARCH arm) + set(NEON False) + set(NEON_FLAGS "-mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp") + elseif(CPU MATCHES "cortex-a7") + set(ARCH arm) + set(NEON True) + set(NEON_FLAGS "-fPIC -mcpu=cortex-a7") + elseif(CPU MATCHES "cortex-a53") + set(ARCH arm) + set(NEON True) + set(NEON_FLAGS "-fPIC -mcpu=cortex-a53") + elseif(CPU MATCHES arm) + set(ARCH arm) + set(NEON True) + elseif(CPU MATCHES aarch64 OR CPU MATCHES arm64) + set(ARCH aarch64) + set(NEON True) + elseif(CPU MATCHES riscv64) + set(ARCH riscv64) + set(NEON False) + elseif(CPU MATCHES ppc64le) + set(ARCH ppc64le) + set(NEON False) + elseif(CPU MATCHES loongarch64) + set(ARCH loongarch64) + set(NEON False) + else() + message(SEND_ERROR "Unknown CPU: ${CPU}") + endif() +endif() + +# disable the default gold linker when an alternative was enabled by the user +if(ENABLE_LLD OR ENABLE_MOLD) + set(ENABLE_GOLD OFF CACHE BOOL "" FORCE) +elseif(ENABLE_GOLD) + include(LDGOLD) +endif() +if(ENABLE_LLD) + set(ENABLE_MOLD OFF CACHE BOOL "" FORCE) + include(LLD) +elseif(ENABLE_MOLD) + set(ENABLE_LLD OFF CACHE BOOL "" FORCE) + include(MOLD) +endif() + + +if(CMAKE_BUILD_TYPE STREQUAL Release OR CMAKE_BUILD_TYPE STREQUAL MinSizeRel) + + # LTO Support, requires cmake >= 3.9 + if(CMAKE_VERSION VERSION_EQUAL 3.9.0 OR CMAKE_VERSION VERSION_GREATER 3.9.0) + option(USE_LTO "Enable link time optimization. Specify an int for number of parallel jobs" OFF) + if(USE_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT HAVE_LTO OUTPUT _output) + if(HAVE_LTO) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + + # override flags to enable parallel processing + set(NJOBS 2) + if(USE_LTO MATCHES "^[0-9]+$") + set(NJOBS ${USE_LTO}) + endif() + + if(CMAKE_COMPILER_IS_GNUCXX) + # GCC + # Make sure we strip binaries in Release build + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") + set(CMAKE_CXX_COMPILE_OPTIONS_IPO -flto=${NJOBS} -fno-fat-lto-objects) + set(CMAKE_C_COMPILE_OPTIONS_IPO -flto=${NJOBS} -fno-fat-lto-objects) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # CLANG + set(ENABLE_GOLD OFF CACHE BOOL "gold linker forced to off" FORCE) + + find_package(LLVM REQUIRED) + + if(NOT CLANG_LTO_CACHE) + set(CLANG_LTO_CACHE ${PROJECT_BINARY_DIR}/.clang-lto.cache) + endif() + if(USE_LTO STREQUAL "all") + set(NJOBS ${USE_LTO}) + endif() + + set(CMAKE_CXX_COMPILE_OPTIONS_IPO -flto=thin) + set(CMAKE_C_COMPILE_OPTIONS_IPO -flto=thin) + if(LLD_FOUND) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--thinlto-jobs=${NJOBS},--thinlto-cache-dir=${CLANG_LTO_CACHE}") + elseif(MOLD_FOUND) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--plugin-opt=jobs=${NJOBS},--plugin-opt=cache-dir=${CLANG_LTO_CACHE}") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + endif() + else() + message(WARNING "LTO optimization not supported: ${_output}") + unset(_output) + endif() + endif() + endif() +endif() + +if(KODI_DEPENDSBUILD) + # Binaries should be directly runnable from host, so include rpath to depends + set(CMAKE_INSTALL_RPATH "${DEPENDS_PATH}/lib") + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +endif() + +include(CheckIncludeFiles) +check_include_files("linux/udmabuf.h" HAVE_LINUX_UDMABUF) +if(HAVE_LINUX_UDMABUF) + list(APPEND ARCH_DEFINES "-DHAVE_LINUX_UDMABUF=1") +else() + message(STATUS "include/linux/udmabuf.h not found") +endif() + +check_include_files("linux/dma-heap.h" HAVE_LINUX_DMA_HEAP) +if(HAVE_LINUX_DMA_HEAP) + list(APPEND ARCH_DEFINES "-DHAVE_LINUX_DMA_HEAP=1") +else() + message(STATUS "include/linux/dma-heap.h not found") +endif() + +check_include_files("linux/dma-buf.h" HAVE_LINUX_DMA_BUF) +if(HAVE_LINUX_DMA_BUF) + list(APPEND ARCH_DEFINES "-DHAVE_LINUX_DMA_BUF=1") +else() + message(STATUS "include/linux/dma-buf.h not found") +endif() + +include(CheckSymbolExists) +set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") +check_symbol_exists("mkostemp" "stdlib.h" HAVE_MKOSTEMP) +set(CMAKE_REQUIRED_DEFINITIONS "") +if(HAVE_MKOSTEMP) + list(APPEND ARCH_DEFINES "-DHAVE_MKOSTEMP=1") +endif() + +set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") +check_symbol_exists("memfd_create" "sys/mman.h" HAVE_LINUX_MEMFD) +set(CMAKE_REQUIRED_DEFINITIONS "") +if(HAVE_LINUX_MEMFD) + list(APPEND ARCH_DEFINES "-DHAVE_LINUX_MEMFD=1") +else() + message(STATUS "memfd_create() not found") +endif() + +# Additional SYSTEM_DEFINES +list(APPEND SYSTEM_DEFINES -DHAS_POSIX_NETWORK -DHAS_LINUX_NETWORK) + +# Code Coverage +if(CMAKE_BUILD_TYPE STREQUAL Coverage) + set(COVERAGE_TEST_BINARY ${APP_NAME_LC}-test) + set(COVERAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + set(COVERAGE_DEPENDS "\${APP_NAME_LC}" "\${APP_NAME_LC}-test") + set(COVERAGE_EXCLUDES */test/* lib/* */lib/*) +endif() + +if(NOT "x11" IN_LIST CORE_PLATFORM_NAME_LC) + set(ENABLE_VDPAU OFF CACHE BOOL "Disabling VDPAU" FORCE) +endif() + +if("x11" IN_LIST CORE_PLATFORM_NAME_LC AND ENABLE_VDPAU) + set(ENABLE_GLX ON CACHE BOOL "Enabling GLX" FORCE) +endif() + +# Architecture endianness detector +include(TestBigEndian) +TEST_BIG_ENDIAN(ARCH_IS_BIGENDIAN) +if(ARCH_IS_BIGENDIAN) + message(STATUS "Host architecture is big-endian") + list(APPEND ARCH_DEFINES "-DWORDS_BIGENDIAN=1") +else() + message(STATUS "Host architecture is little-endian") +endif() + +# Build internal libs +if(NOT USE_INTERNAL_LIBS) + if(KODI_DEPENDSBUILD) + set(USE_INTERNAL_LIBS ON) + else() + set(USE_INTERNAL_LIBS OFF) + endif() +endif() + +# Atomic library +list(APPEND PLATFORM_REQUIRED_DEPS Atomic) diff --git a/cmake/scripts/linux/CodeCoverage.cmake b/cmake/scripts/linux/CodeCoverage.cmake new file mode 100644 index 0000000..f0a36fc --- /dev/null +++ b/cmake/scripts/linux/CodeCoverage.cmake @@ -0,0 +1,97 @@ +# - CodeCoverage +# Generate code coverage reports with LCOV and GCovr. +# +# Configuration: +# COVERAGE_SOURCE_DIR - Source root directory (default ${CMAKE_SOURCE_DIR}). +# COVERAGE_BINARY_DIR - Directory where the coverage reports (and intermediate files) +# are generated to. +# COVERAGE_EXCLUDES - List of exclude patterns (for example '*/tests/*'). +# +# The following targets will be generated: +# coverage - Builds an html report. Requires LCOV. +# coverage_xml - Builds an xml report (in Cobertura format for Jenkins). +# Requires Gcovr. +# +# Inspired by https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake + +# Compiler and linker setup +set(CMAKE_C_FLAGS_COVERAGE "-g -O0 --coverage" CACHE STRING + "Flags used by the C compiler during coverage builds." FORCE) +set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage" CACHE STRING + "Flags used by the C++ compiler during coverage builds." FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "--coverage" CACHE STRING + "Flags used for linking binaries during coverage builds." FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage" CACHE STRING + "Flags used by the shared libraries linker during coverage builds." FORCE) +mark_as_advanced( + CMAKE_C_FLAGS_COVERAGE CMAKE_CXX_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE CMAKE_STATIC_LINKER_FLAGS_COVERAGE +) + +find_program(LCOV_EXECUTABLE lcov) +find_program(GENINFO_EXECUTABLE geninfo) +find_program(GENHTML_EXECUTABLE genhtml) +find_program(GCOVR_EXECUTABLE gcovr) +mark_as_advanced(LCOV_EXECUTABLE GENINFO_EXECUTABLE GENHTML_EXECUTABLE GCOVR_EXECUTABLE) + +# Default options +if(NOT COVERAGE_SOURCE_DIR) + set(COVERAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) +endif() +if(NOT COVERAGE_BINARY_DIR) + set(COVERAGE_BINARY_DIR ${CMAKE_BINARY_DIR}/coverage) +endif() +if(NOT COVERAGE_EXCLUDES) + set(COVERAGE_EXCLUDES) +endif() + +# Allow variables in COVERAGE_DEPENDS that are not evaluated before this file is included. +string(CONFIGURE "${COVERAGE_DEPENDS}" COVERAGE_DEPENDS) + +# Add coverage target that generates an HTML report using LCOV +if(LCOV_EXECUTABLE AND GENINFO_EXECUTABLE AND GENHTML_EXECUTABLE) + file(MAKE_DIRECTORY ${COVERAGE_BINARY_DIR}) + add_custom_target(coverage + COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_BINARY_DIR} + COMMAND ${LCOV_EXECUTABLE} -z -q -d ${CMAKE_BINARY_DIR} + COMMAND ${LCOV_EXECUTABLE} -c -q -i -d ${CMAKE_BINARY_DIR} -b ${COVERAGE_SOURCE_DIR} + -o ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage_base.info + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target test || true + COMMAND ${LCOV_EXECUTABLE} -c -q -d ${CMAKE_BINARY_DIR} -b ${COVERAGE_SOURCE_DIR} + -o ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage_test.info + COMMAND ${LCOV_EXECUTABLE} -a ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage_base.info + -a ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage_test.info + -o ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage.info -q + COMMAND ${LCOV_EXECUTABLE} -q -r ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage.info + /usr/include/* ${CMAKE_BINARY_DIR}/* ${COVERAGE_EXCLUDES} + -o ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage.info + COMMAND ${GENHTML_EXECUTABLE} ${COVERAGE_BINARY_DIR}/${PROJECT_NAME}.coverage.info + -o ${COVERAGE_BINARY_DIR}/html -s --legend --highlight --demangle-cpp + COMMAND ${CMAKE_COMMAND} -E echo "Coverage report: file://${COVERAGE_BINARY_DIR}/html/index.html" + WORKING_DIRECTORY ${COVERAGE_BINARY_DIR} + VERBATIM + DEPENDS ${COVERAGE_DEPENDS} + COMMENT "Generate code coverage html report" + ) +else() + message(WARNING "Target coverage not available (lcov, geninfo and genhtml needed).") +endif() + +# Add coverage target that generates an XML report using Gcovr +if(GCOVR_EXECUTABLE) + file(MAKE_DIRECTORY ${COVERAGE_BINARY_DIR}) + string(REGEX REPLACE "([^;]+)" "--exclude=\"\\1\"" _gcovr_excludes "${COVERAGE_EXCLUDES}") + string(REPLACE "*" ".*" _gcovr_excludes "${_gcovr_excludes}") + add_custom_target(coverage_xml + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target test || true + COMMAND ${GCOVR_EXECUTABLE} -x -r ${COVERAGE_SOURCE_DIR} -o ${COVERAGE_BINARY_DIR}/coverage.xml + --object-directory ${CMAKE_BINARY_DIR} ${_gcovr_excludes} ${CMAKE_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E echo "Coverage report: file://${COVERAGE_BINARY_DIR}/coverage.xml" + WORKING_DIRECTORY ${COVERAGE_BINARY_DIR} + DEPENDS ${COVERAGE_DEPENDS} + COMMENT "Generate code coverage xml report" + ) + unset(_gcovr_excludes) +else() + message(WARNING "Target coverage_xml not available (gcovr needed).") +endif() diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake new file mode 100644 index 0000000..4f5078b --- /dev/null +++ b/cmake/scripts/linux/ExtraTargets.cmake @@ -0,0 +1,32 @@ +# xrandr +if(X_FOUND AND XRANDR_FOUND) + find_package(X QUIET) + find_package(XRandR QUIET) + add_executable(${APP_NAME_LC}-xrandr ${CMAKE_SOURCE_DIR}/xbmc-xrandr.c) + target_link_libraries(${APP_NAME_LC}-xrandr ${SYSTEM_LDFLAGS} ${X_LIBRARIES} m ${XRANDR_LIBRARIES}) +endif() + +# WiiRemote +if(ENABLE_EVENTCLIENTS AND BLUETOOTH_FOUND) + find_package(CWiid QUIET) + find_package(GLU QUIET) + if(CWIID_FOUND AND GLU_FOUND) + add_subdirectory(${CMAKE_SOURCE_DIR}/tools/EventClients/Clients/WiiRemote build/WiiRemote) + endif() +endif() + +if("wayland" IN_LIST CORE_PLATFORM_NAME_LC) + # This cannot go into wayland.cmake since it requires the Wayland dependencies + # to already be resolved + set(PROTOCOL_XMLS "${WAYLANDPP_PROTOCOLS_DIR}/presentation-time.xml" + "${WAYLANDPP_PROTOCOLS_DIR}/xdg-shell.xml" + "${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-shell/xdg-shell-unstable-v6.xml" + "${WAYLAND_PROTOCOLS_DIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml") + add_custom_command(OUTPUT "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp" + COMMAND "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp" + DEPENDS "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS} + COMMENT "Generating wayland-protocols C++ wrappers") + + # Dummy target for dependencies + add_custom_target(generate-wayland-extra-protocols DEPENDS wayland-extra-protocols.hpp) +endif() diff --git a/cmake/scripts/linux/Install.cmake b/cmake/scripts/linux/Install.cmake new file mode 100644 index 0000000..331722c --- /dev/null +++ b/cmake/scripts/linux/Install.cmake @@ -0,0 +1,329 @@ +if(X_FOUND) + set(USE_X11 1) +else() + set(USE_X11 0) +endif() +if(OPENGL_FOUND) + set(USE_OPENGL 1) +else() + set(USE_OPENGL 0) +endif() +if(OPENGLES_FOUND) + set(USE_OPENGLES 1) +else() + set(USE_OPENGLES 0) +endif() + +# CMake config +set(APP_BINARY ${APP_NAME_LC}${APP_BINARY_SUFFIX}) +set(APP_PREFIX ${prefix}) +set(APP_LIB_DIR ${libdir}/${APP_NAME_LC}) +set(APP_DATA_DIR ${datarootdir}/${APP_NAME_LC}) +set(APP_INCLUDE_DIR ${includedir}/${APP_NAME_LC}) + +# Set XBMC_STANDALONE_SH_PULSE so we can insert PulseAudio block into kodi-standalone +if(EXISTS ${CMAKE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.pulse) + if(ENABLE_PULSEAUDIO AND PULSEAUDIO_FOUND) + file(READ "${CMAKE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.pulse" pulse_content) + set(XBMC_STANDALONE_SH_PULSE ${pulse_content}) + endif() +endif() + +# Configure startup scripts +configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi.sh.in + ${CORE_BUILD_DIR}/scripts/${APP_NAME_LC} @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.in + ${CORE_BUILD_DIR}/scripts/${APP_NAME_LC}-standalone @ONLY) + +# Configure cmake files +configure_file(${CMAKE_SOURCE_DIR}/cmake/KodiConfig.cmake.in + ${CORE_BUILD_DIR}/scripts/${APP_NAME}Config.cmake @ONLY) + +# Configure xsession entry +configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi-xsession.desktop.in + ${CORE_BUILD_DIR}/${APP_NAME_LC}-xsession.desktop @ONLY) + +# Configure desktop entry +configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi.desktop.in + ${CORE_BUILD_DIR}/${APP_NAME_LC}.desktop @ONLY) + +# Configure metainfo +configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi.metainfo.xml.in + ${CORE_BUILD_DIR}/${APP_PACKAGE}.metainfo.xml @ONLY) + +# Install app +install(TARGETS ${APP_NAME_LC} + DESTINATION ${libdir}/${APP_NAME_LC} + COMPONENT kodi-bin) +if(X_FOUND AND XRANDR_FOUND) + install(TARGETS ${APP_NAME_LC}-xrandr + DESTINATION ${libdir}/${APP_NAME_LC} + COMPONENT kodi-bin) +endif() + +# Install scripts +install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME_LC} + ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME_LC}-standalone + DESTINATION ${bindir} + COMPONENT kodi-bin) + +# Install libraries +foreach(library ${LIBRARY_FILES}) + get_filename_component(dir ${library} DIRECTORY) + string(REPLACE "${CMAKE_BINARY_DIR}/" "" dir ${dir}) + install(PROGRAMS ${library} + DESTINATION ${libdir}/${APP_NAME_LC}/${dir} + COMPONENT kodi-bin) +endforeach() + +# Install add-ons, fonts, icons, keyboard maps, keymaps, etc +# (addons, media, system, userdata folders in share/kodi/) +foreach(file ${install_data}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${CMAKE_BINARY_DIR}/${file} + DESTINATION ${datarootdir}/${APP_NAME_LC}/${dir} + COMPONENT kodi) +endforeach() + +# Install xsession entry +install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${APP_NAME_LC}-xsession.desktop + RENAME ${APP_NAME_LC}.desktop + DESTINATION ${datarootdir}/xsessions + COMPONENT kodi) + +# Install desktop entry +install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${APP_NAME_LC}.desktop + DESTINATION ${datarootdir}/applications + COMPONENT kodi) + +# Install metainfo +install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${APP_PACKAGE}.metainfo.xml + DESTINATION ${datarootdir}/metainfo + COMPONENT kodi) + +# Install icons +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon16x16.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/16x16/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon22x22.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/22x22/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon24x24.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/24x24/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon32x32.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/32x32/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon48x48.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/48x48/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon64x64.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/64x64/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon128x128.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/128x128/apps + COMPONENT kodi) +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/packaging/media/icon256x256.png + RENAME ${APP_NAME_LC}.png + DESTINATION ${datarootdir}/icons/hicolor/256x256/apps + COMPONENT kodi) + +# Install firewalld service definitions +install(FILES ${CMAKE_SOURCE_DIR}/tools/Linux/firewalld-services/kodi-eventserver.xml + ${CMAKE_SOURCE_DIR}/tools/Linux/firewalld-services/kodi-http.xml + ${CMAKE_SOURCE_DIR}/tools/Linux/firewalld-services/kodi-jsonrpc.xml + DESTINATION ${prefix}/lib/firewalld/services + COMPONENT kodi) + +# Install docs +install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.md + ${CMAKE_SOURCE_DIR}/version.txt + ${CMAKE_SOURCE_DIR}/docs/README.Linux.md + DESTINATION ${docdir} + COMPONENT kodi) + +install(FILES ${CMAKE_SOURCE_DIR}/privacy-policy.txt + DESTINATION ${datarootdir}/${APP_NAME_LC} + COMPONENT kodi) + +# Install kodi-tools-texturepacker +if(INTERNAL_TEXTUREPACKER_INSTALLABLE) + install(PROGRAMS $<TARGET_FILE:TexturePacker::TexturePacker::Installable> + DESTINATION ${bindir} + RENAME "${APP_NAME_LC}-TexturePacker" + COMPONENT kodi-tools-texturepacker) +endif() + +# Install kodi-addon-dev headers +include(${CMAKE_SOURCE_DIR}/xbmc/addons/AddonBindings.cmake) +install(DIRECTORY ${CORE_ADDON_BINDINGS_DIRS}/ + DESTINATION ${includedir}/${APP_NAME_LC} + COMPONENT kodi-addon-dev + REGEX ".txt" EXCLUDE) + +install(FILES ${CORE_ADDON_BINDINGS_FILES} + DESTINATION ${includedir}/${APP_NAME_LC} + COMPONENT kodi-addon-dev) + +# Install kodi-addon-dev add-on bindings +install(FILES ${CMAKE_SOURCE_DIR}/cmake/scripts/common/AddonHelpers.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/AddOptions.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/ArchSetup.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/CheckCommits.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/CheckTargetPlatform.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/GenerateVersionedFiles.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/GeneratorSetup.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/HandleDepends.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/PrepareEnv.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/common/ProjectMacros.cmake + ${CMAKE_SOURCE_DIR}/cmake/scripts/linux/PathSetup.cmake + DESTINATION ${datarootdir}/${APP_NAME_LC}/cmake + COMPONENT kodi-addon-dev) +# ${APP_NAME}Config.cmake contains architecture-specific paths so it +# should be installed in ${libdir}/${APP_NAME_LC}/${dir} +install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME}Config.cmake + DESTINATION ${libdir}/${APP_NAME_LC}/cmake + COMPONENT kodi-addon-dev) + +if(ENABLE_EVENTCLIENTS) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=''))" + OUTPUT_VARIABLE PYTHON_LIB_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) + # Install kodi-eventclients-common BT python files + install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/bt/__init__.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/bt/bt.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/bt/hid.py + DESTINATION ${PYTHON_LIB_PATH}/${APP_NAME_LC}/bt + COMPONENT kodi-eventclients-common) + + # Install kodi-eventclients-common PS3 python files + install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/__init__.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/keymaps.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixaxis.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixpair.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/ps3/sixwatch.py + DESTINATION ${PYTHON_LIB_PATH}/${APP_NAME_LC}/ps3 + COMPONENT kodi-eventclients-common) + + # Install kodi-eventclients-common python files + file(WRITE ${CMAKE_BINARY_DIR}/packages/deb/defs.py ICON_PATH="/usr/share/pixmaps/${APP_NAME_LC}/") + install(PROGRAMS ${CMAKE_BINARY_DIR}/packages/deb/defs.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/__init__.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/Clients/PS3BDRemote/ps3_remote.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/xbmcclient.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/zeroconf.py + DESTINATION ${PYTHON_LIB_PATH}/${APP_NAME_LC} + COMPONENT kodi-eventclients-common) + + # Install kodi-eventclients-common icons + install(FILES ${CMAKE_SOURCE_DIR}/tools/EventClients/icons/bluetooth.png + ${CMAKE_SOURCE_DIR}/tools/EventClients/icons/phone.png + ${CMAKE_SOURCE_DIR}/tools/EventClients/icons/mail.png + ${CMAKE_SOURCE_DIR}/tools/EventClients/icons/mouse.png + DESTINATION ${datarootdir}/pixmaps/${APP_NAME_LC} + COMPONENT kodi-eventclients-common) + + # Install kodi-eventclients-dev headers + install(FILES ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/c++/xbmcclient.h + DESTINATION ${includedir}/${APP_NAME_LC} + COMPONENT kodi-eventclients-dev) + + # Install kodi-eventclients-dev C# examples + install(FILES "${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c#/XBMCDemoClient1.cs" + DESTINATION "${docdir}/${APP_NAME_LC}-eventclients-dev/examples/C#" + COMPONENT kodi-eventclients-dev) + + # Install kodi-eventclients-dev C++ examples + install(FILES ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c++/example_notification.cpp + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c++/example_log.cpp + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c++/example_button1.cpp + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c++/example_mouse.cpp + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/c++/example_button2.cpp + DESTINATION ${docdir}/${APP_NAME_LC}-eventclients-dev/examples/C++ + COMPONENT kodi-eventclients-dev) + + # Install kodi-eventclients-dev java examples + install(FILES ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/java/XBMCDemoClient1.java + DESTINATION ${docdir}/${APP_NAME_LC}-eventclients-dev/examples/java + COMPONENT kodi-eventclients-dev) + + # Install kodi-eventclients-dev python examples + install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_mouse.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_button1.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_notification.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_action.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_button2.py + ${CMAKE_SOURCE_DIR}/tools/EventClients/examples/python/example_simple.py + DESTINATION ${docdir}/${APP_NAME_LC}-eventclients-dev/examples/python + COMPONENT kodi-eventclients-dev) + + # Install kodi-eventclients-ps3 + install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/Clients/PS3BDRemote/ps3_remote.py + RENAME ${APP_NAME_LC}-ps3remote + DESTINATION ${bindir} + COMPONENT kodi-eventclients-ps3) + + if(BLUETOOTH_FOUND AND CWIID_FOUND AND GLU_FOUND) + # Install kodi-eventclients-wiiremote + install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/WiiRemote/${APP_NAME_LC}-wiiremote + DESTINATION ${bindir} + COMPONENT kodi-eventclients-wiiremote) + endif() + + # Install kodi-eventclients-kodi-send + install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/Clients/KodiSend/kodi-send.py + RENAME ${APP_NAME_LC}-send + DESTINATION ${bindir} + COMPONENT kodi-eventclients-kodi-send) +endif() + +# Install XBT skin files +foreach(texture ${XBT_FILES}) + string(REPLACE "${CMAKE_BINARY_DIR}/" "" dir ${texture}) + get_filename_component(dir ${dir} DIRECTORY) + install(FILES ${texture} + DESTINATION ${datarootdir}/${APP_NAME_LC}/${dir} + COMPONENT kodi) +endforeach() + +# Install extra stuff if it exists +if(EXISTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/extra-installs) + install(CODE "file(STRINGS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/extra-installs dirs) + foreach(dir \${dirs}) + file(GLOB_RECURSE FILES RELATIVE ${CMAKE_BINARY_DIR} \${dir}/*) + foreach(file \${FILES}) + get_filename_component(dir \${file} DIRECTORY) + file(INSTALL \${file} DESTINATION ${datarootdir}/${APP_NAME_LC}/\${dir}) + endforeach() + endforeach()") +endif() + +if(NOT "$ENV{DESTDIR}" STREQUAL "") + set(DESTDIR ${CMAKE_BINARY_DIR}/$ENV{DESTDIR}) +endif() +foreach(subdir ${build_dirs}) + if(NOT subdir MATCHES kodi-platform) + string(REPLACE " " ";" subdir ${subdir}) + list(GET subdir 0 id) + install(CODE "execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${id}/src/${id}-build install DESTDIR=${DESTDIR})") + endif() +endforeach() + +# generate packages? yes please, if everything checks out +if(CPACK_GENERATOR) + if(CPACK_GENERATOR STREQUAL DEB AND CORE_SYSTEM_NAME STREQUAL linux) + if(CMAKE_BUILD_TYPE STREQUAL Debug) + message(STATUS "DEB Generator: Build type is set to 'Debug'. Packaged binaries will be unstripped.") + endif() + include(${CMAKE_SOURCE_DIR}/cmake/cpack/CPackConfigDEB.cmake) + else() + message(FATAL_ERROR "DEB Generator: Can't configure CPack to generate Debian packages on non-linux systems.") + endif() +endif() diff --git a/cmake/scripts/linux/Linkers.txt b/cmake/scripts/linux/Linkers.txt new file mode 100644 index 0000000..c947ec4 --- /dev/null +++ b/cmake/scripts/linux/Linkers.txt @@ -0,0 +1,4 @@ +# Linkers +option(ENABLE_GOLD "Enable gnu gold linker?" ON) +option(ENABLE_LLD "Enable llvm lld linker?" OFF) +option(ENABLE_MOLD "Enable mold linker?" OFF) diff --git a/cmake/scripts/linux/Macros.cmake b/cmake/scripts/linux/Macros.cmake new file mode 100644 index 0000000..37243a7 --- /dev/null +++ b/cmake/scripts/linux/Macros.cmake @@ -0,0 +1,95 @@ +function(core_link_library lib wraplib) + set(export -Wl,--unresolved-symbols=ignore-all + `cat ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def` + ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) + set(check_arg "") + if(TARGET ${lib}) + set(target ${lib}) + set(link_lib $<TARGET_FILE:${lib}>) + set(check_arg ${ARGV2}) + set(data_arg ${ARGV3}) + else() + set(target ${ARGV2}) + set(link_lib ${lib}) + set(check_arg ${ARGV3}) + set(data_arg ${ARGV4}) + endif() + + # wrapper has to be adapted in order to support coverage. + if(CMAKE_BUILD_TYPE STREQUAL Coverage) + set(export "") + endif() + + if(check_arg STREQUAL export) + set(export ${export} + -Wl,--version-script=${ARGV3}) + elseif(check_arg STREQUAL extras) + foreach(arg ${data_arg}) + list(APPEND export ${arg}) + endforeach() + elseif(check_arg STREQUAL archives) + set(extra_libs ${data_arg}) + endif() + + string(REGEX REPLACE "[ ]+" ";" _flags "${CMAKE_SHARED_LINKER_FLAGS}") + get_filename_component(dir ${wraplib} DIRECTORY) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} + COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} + COMMAND ${CMAKE_C_COMPILER} + ARGS ${_flags} -Wl,--whole-archive + "${link_lib}" ${extra_libs} + -Wl,--no-whole-archive -lm + -Wl,-soname,${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} + -shared -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} + ${export} + DEPENDS ${target} wrapper.def wrapper) + + get_filename_component(libname ${wraplib} NAME_WE) + add_custom_target(wrap_${libname} ALL DEPENDS ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) + set_target_properties(wrap_${libname} PROPERTIES FOLDER lib/wrapped) + add_dependencies(${APP_NAME_LC}-libraries wrap_${libname}) + + set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} CACHE STRING "" FORCE) +endfunction() + +function(find_soname lib) + cmake_parse_arguments(arg "REQUIRED" "" "" ${ARGN}) + + string(TOLOWER ${lib} liblow) + if(${lib}_LDFLAGS) + set(link_lib "${${lib}_LDFLAGS}") + else() + if(IS_ABSOLUTE "${${lib}_LIBRARIES}") + set(link_lib "${${lib}_LIBRARIES}") + else() + set(link_lib -l${${lib}_LIBRARIES}) + endif() + endif() + execute_process(COMMAND ${CMAKE_C_COMPILER} -nostdlib -o /dev/null -Wl,-M ${link_lib} + COMMAND grep LOAD.*${liblow} + ERROR_QUIET + OUTPUT_VARIABLE ${lib}_FILENAME) + string(REPLACE "LOAD " "" ${lib}_FILENAME "${${lib}_FILENAME}") + string(STRIP "${${lib}_FILENAME}" ${lib}_FILENAME) + if(NOT ${lib}_FILENAME) + execute_process(COMMAND ${CMAKE_C_COMPILER} -nostdlib -o /dev/null -Wl,-t ${link_lib} + OUTPUT_QUIET + ERROR_VARIABLE _TMP_FILENAME) + string(REGEX MATCH ".*lib${liblow}.so" ${lib}_FILENAME ${_TMP_FILENAME}) + endif() + if(${lib}_FILENAME) + execute_process(COMMAND ${CMAKE_OBJDUMP} -p ${${lib}_FILENAME} + COMMAND grep SONAME.*${liblow} + ERROR_QUIET + OUTPUT_VARIABLE ${lib}_SONAME) + string(REPLACE "SONAME " "" ${lib}_SONAME ${${lib}_SONAME}) + string(STRIP ${${lib}_SONAME} ${lib}_SONAME) + if(VERBOSE) + message(STATUS "${lib} soname: ${${lib}_SONAME}") + endif() + set(${lib}_SONAME ${${lib}_SONAME} PARENT_SCOPE) + endif() + if(arg_REQUIRED AND NOT ${lib}_SONAME) + message(FATAL_ERROR "Could not find dynamically loadable library ${lib}") + endif() +endfunction() diff --git a/cmake/scripts/linux/PathSetup.cmake b/cmake/scripts/linux/PathSetup.cmake new file mode 100644 index 0000000..f9f78ba --- /dev/null +++ b/cmake/scripts/linux/PathSetup.cmake @@ -0,0 +1,40 @@ +include(GNUInstallDirs) + +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 ${CMAKE_INSTALL_FULL_LIBDIR}) +endif() +if(NOT bindir) + set(bindir ${CMAKE_INSTALL_FULL_BINDIR}) +endif() +if(NOT includedir) + set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) +endif() +if(NOT datarootdir) + set(datarootdir ${CMAKE_INSTALL_FULL_DATAROOTDIR}) +endif() +if(NOT datadir) + set(datadir ${CMAKE_INSTALL_FULL_DATADIR}) +endif() +if(NOT docdir) + set(docdir ${CMAKE_INSTALL_FULL_DOCDIR}) +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}") +list(APPEND final_message "Docdir: ${docdir}") + +set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/${APP_NAME_LC}\" + -DINSTALL_PATH=\"${datarootdir}/${APP_NAME_LC}\") |