summaryrefslogtreecommitdiffstats
path: root/cmake/modules/buildtools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /cmake/modules/buildtools
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/modules/buildtools')
-rw-r--r--cmake/modules/buildtools/FindCCache.cmake38
-rw-r--r--cmake/modules/buildtools/FindClangFormat.cmake19
-rw-r--r--cmake/modules/buildtools/FindClangTidy.cmake29
-rw-r--r--cmake/modules/buildtools/FindCppcheck.cmake32
-rw-r--r--cmake/modules/buildtools/FindFlatC.cmake99
-rw-r--r--cmake/modules/buildtools/FindGtest.cmake71
-rw-r--r--cmake/modules/buildtools/FindIncludeWhatYouUse.cmake26
-rw-r--r--cmake/modules/buildtools/FindJsonSchemaBuilder.cmake53
-rw-r--r--cmake/modules/buildtools/FindNASM.cmake30
-rw-r--r--cmake/modules/buildtools/FindPatch.cmake84
-rw-r--r--cmake/modules/buildtools/FindSWIG.cmake29
-rw-r--r--cmake/modules/buildtools/FindTexturePacker.cmake93
-rw-r--r--cmake/modules/buildtools/LDGOLD.cmake42
-rw-r--r--cmake/modules/buildtools/LLD.cmake22
-rw-r--r--cmake/modules/buildtools/MOLD.cmake77
15 files changed, 744 insertions, 0 deletions
diff --git a/cmake/modules/buildtools/FindCCache.cmake b/cmake/modules/buildtools/FindCCache.cmake
new file mode 100644
index 0000000..34238dc
--- /dev/null
+++ b/cmake/modules/buildtools/FindCCache.cmake
@@ -0,0 +1,38 @@
+#.rst:
+# FindCCache
+# ----------
+# Finds ccache and sets it up as compiler wrapper.
+# This should ideally be called before the call to project().
+#
+# See: https://crascit.com/2016/04/09/using-ccache-with-cmake/
+
+find_program(CCACHE_PROGRAM ccache)
+
+if(CCACHE_PROGRAM)
+ execute_process(COMMAND "${CCACHE_PROGRAM}" --version
+ OUTPUT_VARIABLE CCACHE_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]* version [^\n]*" CCACHE_VERSION "${CCACHE_VERSION}")
+ string(REGEX REPLACE ".* version (.*)" "\\1" CCACHE_VERSION "${CCACHE_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(CCache REQUIRED_VARS CCACHE_PROGRAM
+ VERSION_VAR CCACHE_VERSION)
+
+if(CCACHE_FOUND)
+ # Supports Unix Makefiles, Ninja and Xcode
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE)
+ set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE)
+
+ file(WRITE "${CMAKE_BINARY_DIR}/launch-c" "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_C_COMPILER}\" \"$@\"\n")
+ file(WRITE "${CMAKE_BINARY_DIR}/launch-cxx" "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_CXX_COMPILER}\" \"$@\"\n")
+ execute_process(COMMAND chmod +x "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx")
+
+ set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c" PARENT_SCOPE)
+ set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx" PARENT_SCOPE)
+ set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c" PARENT_SCOPE)
+ set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(CCACHE_PROGRAM)
diff --git a/cmake/modules/buildtools/FindClangFormat.cmake b/cmake/modules/buildtools/FindClangFormat.cmake
new file mode 100644
index 0000000..ff052a1
--- /dev/null
+++ b/cmake/modules/buildtools/FindClangFormat.cmake
@@ -0,0 +1,19 @@
+#.rst:
+# FindClangFormat
+# ----------
+# Finds clang-format
+
+find_program(CLANG_FORMAT_EXECUTABLE clang-format)
+
+if(CLANG_FORMAT_EXECUTABLE)
+ execute_process(COMMAND "${CLANG_FORMAT_EXECUTABLE}" --version
+ OUTPUT_VARIABLE CLANG_FORMAT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX REPLACE ".* version (.*)" "\\1" CLANG_FORMAT_VERSION "${CLANG_FORMAT_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ClangFormat REQUIRED_VARS CLANG_FORMAT_EXECUTABLE
+ VERSION_VAR CLANG_FORMAT_VERSION)
+
+mark_as_advanced(CLANG_FORMAT_EXECUTABLE)
diff --git a/cmake/modules/buildtools/FindClangTidy.cmake b/cmake/modules/buildtools/FindClangTidy.cmake
new file mode 100644
index 0000000..c133175
--- /dev/null
+++ b/cmake/modules/buildtools/FindClangTidy.cmake
@@ -0,0 +1,29 @@
+#.rst:
+# FindClangTidy
+# -------------
+# Finds clang-tidy and sets it up to run along with the compiler for C and CXX.
+
+find_program(CLANG_TIDY_EXECUTABLE clang-tidy)
+
+if(CLANG_TIDY_EXECUTABLE)
+ execute_process(COMMAND "${CLANG_TIDY_EXECUTABLE}" --version
+ OUTPUT_VARIABLE CLANG_TIDY_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]* version [^\n]*" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
+ string(REGEX REPLACE ".* version (.*)" "\\1" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ClangTidy REQUIRED_VARS CLANG_TIDY_EXECUTABLE
+ VERSION_VAR CLANG_TIDY_VERSION)
+
+if(CLANGTIDY_FOUND)
+ if(CORE_SYSTEM_NAME STREQUAL android)
+ set(CLANG_TIDY_EXECUTABLE ${CLANG_TIDY_EXECUTABLE};--extra-arg-before=--target=${HOST})
+ endif()
+ # Supports Unix Makefiles and Ninja
+ set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
+ set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(CLANG_TIDY_EXECUTABLE)
diff --git a/cmake/modules/buildtools/FindCppcheck.cmake b/cmake/modules/buildtools/FindCppcheck.cmake
new file mode 100644
index 0000000..27e2675
--- /dev/null
+++ b/cmake/modules/buildtools/FindCppcheck.cmake
@@ -0,0 +1,32 @@
+#.rst:
+# FindCppcheck
+# ------------
+# Finds cppcheck and sets it up to run along with the compiler for C and CXX.
+
+find_program(CPPCHECK_EXECUTABLE cppcheck)
+
+if(CPPCHECK_EXECUTABLE)
+ execute_process(COMMAND "${CPPCHECK_EXECUTABLE}" --version
+ OUTPUT_VARIABLE CPPCHECK_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX REPLACE "Cppcheck (.*)" "\\1" CPPCHECK_VERSION "${CPPCHECK_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Cppcheck REQUIRED_VARS CPPCHECK_EXECUTABLE
+ VERSION_VAR CPPCHECK_VERSION)
+
+if(CPPCHECK_FOUND)
+ # CMake < 3.16 treats Objective-C (OBJC) files as C files and Objective-C++ (OBJCXX) files as C++ files,
+ # but cppcheck doesn't support Objective-C and Objective-C++.
+ # CMake >= 3.16 added support for Objective-C and Objective-C++ language,
+ # but doesn't support OBJC and OBJCXX for <LANG>_CLANG_TIDY.
+ file(WRITE "${CMAKE_BINARY_DIR}/cppcheck" "case \"$@\" in *.m|*.mm) exit 0; esac\nexec \"${CPPCHECK_EXECUTABLE}\" --enable=performance --quiet --relative-paths=\"${CMAKE_SOURCE_DIR}\" \"$@\"\n")
+ execute_process(COMMAND chmod +x "${CMAKE_BINARY_DIR}/cppcheck")
+
+ # Supports Unix Makefiles and Ninja
+ set(CMAKE_C_CPPCHECK "${CMAKE_BINARY_DIR}/cppcheck" PARENT_SCOPE)
+ set(CMAKE_CXX_CPPCHECK "${CMAKE_BINARY_DIR}/cppcheck" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(CPPCHECK_EXECUTABLE)
diff --git a/cmake/modules/buildtools/FindFlatC.cmake b/cmake/modules/buildtools/FindFlatC.cmake
new file mode 100644
index 0000000..bca17e8
--- /dev/null
+++ b/cmake/modules/buildtools/FindFlatC.cmake
@@ -0,0 +1,99 @@
+# FindFlatC
+# --------
+# Find the FlatBuffers schema compiler
+#
+# This will define the following variables:
+#
+# FLATBUFFERS_FLATC_EXECUTABLE_FOUND - system has FlatBuffers compiler
+# FLATBUFFERS_FLATC_EXECUTABLE - the flatc compiler executable
+# FLATBUFFERS_FLATC_VERSION - the flatc compiler version
+#
+# and the following imported targets:
+#
+# flatbuffers::flatc - The FlatC compiler
+
+if(NOT TARGET flatbuffers::flatc)
+ include(cmake/scripts/common/ModuleHelpers.cmake)
+
+ # Check for existing FLATC.
+ find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc
+ HINTS ${NATIVEPREFIX}/bin)
+
+ if(FLATBUFFERS_FLATC_EXECUTABLE)
+ execute_process(COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" --version
+ OUTPUT_VARIABLE FLATBUFFERS_FLATC_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]* version [^\n]*" FLATBUFFERS_FLATC_VERSION "${FLATBUFFERS_FLATC_VERSION}")
+ string(REGEX REPLACE ".* version (.*)" "\\1" FLATBUFFERS_FLATC_VERSION "${FLATBUFFERS_FLATC_VERSION}")
+ endif()
+
+ set(MODULE_LC flatbuffers)
+ # Duplicate URL may exist from FindFlatbuffers.cmake
+ # unset otherwise it thinks we are providing a local file location and incorrect concatenation happens
+ unset(FLATBUFFERS_URL)
+ SETUP_BUILD_VARS()
+
+ if(NOT FLATBUFFERS_FLATC_EXECUTABLE OR (ENABLE_INTERNAL_FLATBUFFERS AND NOT "${FLATBUFFERS_FLATC_VERSION}" VERSION_EQUAL "${FLATBUFFERS_VER}"))
+
+ # Override build type detection and always build as release
+ set(FLATBUFFERS_BUILD_TYPE Release)
+
+ if(NATIVEPREFIX)
+ set(INSTALL_DIR "${NATIVEPREFIX}/bin")
+ set(FLATBUFFERS_INSTALL_PREFIX ${NATIVEPREFIX})
+ else()
+ set(INSTALL_DIR "${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/bin")
+ set(FLATBUFFERS_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR})
+ endif()
+
+ set(CMAKE_ARGS -DFLATBUFFERS_CODE_COVERAGE=OFF
+ -DFLATBUFFERS_BUILD_TESTS=OFF
+ -DFLATBUFFERS_INSTALL=ON
+ -DFLATBUFFERS_BUILD_FLATLIB=OFF
+ -DFLATBUFFERS_BUILD_FLATC=ON
+ -DFLATBUFFERS_BUILD_FLATHASH=OFF
+ -DFLATBUFFERS_BUILD_GRPCTEST=OFF
+ -DFLATBUFFERS_BUILD_SHAREDLIB=OFF)
+
+ # Set host build info for buildtool
+ if(EXISTS "${NATIVEPREFIX}/share/Toolchain-Native.cmake")
+ set(FLATBUFFERS_TOOLCHAIN_FILE "${NATIVEPREFIX}/share/Toolchain-Native.cmake")
+ endif()
+
+ if(WIN32 OR WINDOWS_STORE)
+ # Make sure we generate for host arch, not target
+ set(FLATBUFFERS_GENERATOR_PLATFORM CMAKE_GENERATOR_PLATFORM ${HOSTTOOLSET})
+ set(WIN_DISABLE_PROJECT_FLAGS 1)
+ endif()
+
+ set(FLATBUFFERS_FLATC_EXECUTABLE ${INSTALL_DIR}/flatc CACHE INTERNAL "FlatBuffer compiler")
+
+ set(BUILD_NAME flatc)
+ set(BUILD_BYPRODUCTS ${FLATBUFFERS_FLATC_EXECUTABLE})
+ set(FLATBUFFERS_FLATC_VERSION ${FLATBUFFERS_VER})
+
+ BUILD_DEP_TARGET()
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(FlatC
+ REQUIRED_VARS FLATBUFFERS_FLATC_EXECUTABLE
+ VERSION_VAR FLATBUFFERS_FLATC_VERSION)
+
+ if(FLATC_FOUND)
+
+ add_library(flatbuffers::flatc UNKNOWN IMPORTED)
+ set_target_properties(flatbuffers::flatc PROPERTIES
+ FOLDER "External Projects")
+
+ if(TARGET flatc)
+ add_dependencies(flatbuffers::flatc flatc)
+ endif()
+ else()
+ if(FLATC_FIND_REQUIRED)
+ message(FATAL_ERROR "Flatc compiler not found.")
+ endif()
+ endif()
+
+ mark_as_advanced(FLATBUFFERS_FLATC_EXECUTABLE)
+endif()
diff --git a/cmake/modules/buildtools/FindGtest.cmake b/cmake/modules/buildtools/FindGtest.cmake
new file mode 100644
index 0000000..eba6adc
--- /dev/null
+++ b/cmake/modules/buildtools/FindGtest.cmake
@@ -0,0 +1,71 @@
+#.rst:
+# FindGtest
+# --------
+# Finds the gtest library
+#
+# This will define the following variables::
+#
+# GTEST_FOUND - system has gtest
+# GTEST_INCLUDE_DIRS - the gtest include directories
+# GTEST_LIBRARIES - the gtest libraries
+#
+# and the following imported targets:
+#
+# Gtest::Gtest - The gtest library
+
+if(ENABLE_INTERNAL_GTEST)
+ include(cmake/scripts/common/ModuleHelpers.cmake)
+
+ set(MODULE_LC gtest)
+
+ SETUP_BUILD_VARS()
+
+ set(GTEST_VERSION ${${MODULE}_VER})
+
+ # Override build type detection and always build as release
+ set(GTEST_BUILD_TYPE Release)
+
+ set(CMAKE_ARGS -DBUILD_GMOCK=OFF
+ -DINSTALL_GTEST=ON
+ -DBUILD_SHARED_LIBS=OFF
+ -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>)
+
+ BUILD_DEP_TARGET()
+else()
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_GTEST gtest>=1.10.0 QUIET)
+ set(GTEST_VERSION ${PC_GTEST_VERSION})
+ elseif(WIN32)
+ set(GTEST_VERSION 1.10.0)
+ endif()
+
+ find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h
+ PATHS ${PC_GTEST_INCLUDEDIR})
+
+ find_library(GTEST_LIBRARY_RELEASE NAMES gtest
+ PATHS ${PC_GTEST_LIBDIR})
+ find_library(GTEST_LIBRARY_DEBUG NAMES gtestd
+ PATHS ${PC_GTEST_LIBDIR})
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(GTEST)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Gtest
+ REQUIRED_VARS GTEST_LIBRARY GTEST_INCLUDE_DIR
+ VERSION_VAR GTEST_VERSION)
+
+if(GTEST_FOUND)
+ set(GTEST_LIBRARIES ${GTEST_LIBRARY})
+ set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
+endif()
+
+if(NOT TARGET Gtest::Gtest)
+ add_library(Gtest::Gtest UNKNOWN IMPORTED)
+ set_target_properties(Gtest::Gtest PROPERTIES
+ IMPORTED_LOCATION "${GTEST_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
+endif()
+
+mark_as_advanced(GTEST_INCLUDE_DIR GTEST_LIBRARY)
diff --git a/cmake/modules/buildtools/FindIncludeWhatYouUse.cmake b/cmake/modules/buildtools/FindIncludeWhatYouUse.cmake
new file mode 100644
index 0000000..b22225a
--- /dev/null
+++ b/cmake/modules/buildtools/FindIncludeWhatYouUse.cmake
@@ -0,0 +1,26 @@
+#.rst:
+# FindIncludeWhatYouUse
+# ---------------------
+# Finds include-what-you-use and sets it up to run along with the compiler for C and CXX.
+
+find_program(IWYU_EXECUTABLE NAMES include-what-you-use iwyu)
+
+if(IWYU_EXECUTABLE)
+ execute_process(COMMAND "${IWYU_EXECUTABLE}" --version
+ OUTPUT_VARIABLE IWYU_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]*include-what-you-use [^\n]*" IWYU_VERSION "${IWYU_VERSION}")
+ string(REGEX REPLACE "include-what-you-use ([^ \n\r\t]+).*" "\\1" IWYU_VERSION "${IWYU_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(IncludeWhatYouUse REQUIRED_VARS IWYU_EXECUTABLE
+ VERSION_VAR IWYU_VERSION)
+
+if(INCLUDEWHATYOUUSE_FOUND)
+ # Supports Unix Makefiles and Ninja
+ set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE}" PARENT_SCOPE)
+ set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE}" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(IWYU_EXECUTABLE)
diff --git a/cmake/modules/buildtools/FindJsonSchemaBuilder.cmake b/cmake/modules/buildtools/FindJsonSchemaBuilder.cmake
new file mode 100644
index 0000000..6f75328
--- /dev/null
+++ b/cmake/modules/buildtools/FindJsonSchemaBuilder.cmake
@@ -0,0 +1,53 @@
+#.rst:
+# FindJsonSchemaBuilder
+# ---------------------
+# Finds the JsonSchemaBuilder
+#
+# If WITH_JSONSCHEMABUILDER is defined and points to a directory,
+# this path will be used to search for the JsonSchemaBuilder binary
+#
+#
+# This will define the following (imported) targets::
+#
+# JsonSchemaBuilder::JsonSchemaBuilder - The JsonSchemaBuilder executable
+
+if(NOT TARGET JsonSchemaBuilder::JsonSchemaBuilder)
+ if(KODI_DEPENDSBUILD)
+ get_filename_component(_jsbpath "${NATIVEPREFIX}/bin" ABSOLUTE)
+ find_program(JSONSCHEMABUILDER_EXECUTABLE NAMES "${APP_NAME_LC}-JsonSchemaBuilder" JsonSchemaBuilder
+ HINTS ${_jsbpath})
+
+ add_executable(JsonSchemaBuilder::JsonSchemaBuilder IMPORTED GLOBAL)
+ set_target_properties(JsonSchemaBuilder::JsonSchemaBuilder PROPERTIES
+ IMPORTED_LOCATION "${JSONSCHEMABUILDER_EXECUTABLE}")
+ elseif(CORE_SYSTEM_NAME STREQUAL windowsstore)
+ get_filename_component(_jsbpath "${DEPENDS_PATH}/bin/json-rpc" ABSOLUTE)
+ find_program(JSONSCHEMABUILDER_EXECUTABLE NAMES "${APP_NAME_LC}-JsonSchemaBuilder" JsonSchemaBuilder
+ HINTS ${_jsbpath})
+
+ add_executable(JsonSchemaBuilder::JsonSchemaBuilder IMPORTED GLOBAL)
+ set_target_properties(JsonSchemaBuilder::JsonSchemaBuilder PROPERTIES
+ IMPORTED_LOCATION "${JSONSCHEMABUILDER_EXECUTABLE}")
+ else()
+ if(WITH_JSONSCHEMABUILDER)
+ get_filename_component(_jsbpath ${WITH_JSONSCHEMABUILDER} ABSOLUTE)
+ get_filename_component(_jsbpath ${_jsbpath} DIRECTORY)
+ find_program(JSONSCHEMABUILDER_EXECUTABLE NAMES "${APP_NAME_LC}-JsonSchemaBuilder" JsonSchemaBuilder
+ HINTS ${_jsbpath})
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(JsonSchemaBuilder "Could not find '${APP_NAME_LC}-JsonSchemaBuilder' or 'JsonSchemaBuilder' executable in ${_jsbpath} supplied by -DWITH_JSONSCHEMABUILDER. Make sure the executable file name matches these names!"
+ JSONSCHEMABUILDER_EXECUTABLE)
+ if(JSONSCHEMABUILDER_FOUND)
+ add_executable(JsonSchemaBuilder::JsonSchemaBuilder IMPORTED GLOBAL)
+ set_target_properties(JsonSchemaBuilder::JsonSchemaBuilder PROPERTIES
+ IMPORTED_LOCATION "${JSONSCHEMABUILDER_EXECUTABLE}")
+ endif()
+ mark_as_advanced(JSONSCHEMABUILDER)
+ else()
+ add_subdirectory(${CMAKE_SOURCE_DIR}/tools/depends/native/JsonSchemaBuilder build/jsonschemabuilder)
+ add_executable(JsonSchemaBuilder::JsonSchemaBuilder ALIAS JsonSchemaBuilder)
+ set_target_properties(JsonSchemaBuilder PROPERTIES FOLDER Tools)
+ endif()
+ endif()
+endif()
diff --git a/cmake/modules/buildtools/FindNASM.cmake b/cmake/modules/buildtools/FindNASM.cmake
new file mode 100644
index 0000000..fc9daa0
--- /dev/null
+++ b/cmake/modules/buildtools/FindNASM.cmake
@@ -0,0 +1,30 @@
+#.rst:
+# FindNASM
+# ----------
+# Finds nasm executable
+#
+# This will define the following variables::
+#
+# NASM_EXECUTABLE - nasm executable
+
+include(FindPackageHandleStandardArgs)
+
+find_program(NASM_EXECUTABLE nasm)
+
+if(NASM_EXECUTABLE)
+ execute_process(COMMAND ${NASM_EXECUTABLE} -version
+ OUTPUT_VARIABLE nasm_version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(nasm_version MATCHES "^NASM version ([0-9\\.]*)")
+ set(NASM_VERSION_STRING "${CMAKE_MATCH_1}")
+ endif()
+endif()
+
+# Provide standardized success/failure messages
+find_package_handle_standard_args(NASM
+ REQUIRED_VARS NASM_EXECUTABLE
+ VERSION_VAR NASM_VERSION_STRING)
+
+mark_as_advanced(NASM_EXECUTABLE)
diff --git a/cmake/modules/buildtools/FindPatch.cmake b/cmake/modules/buildtools/FindPatch.cmake
new file mode 100644
index 0000000..669b4d2
--- /dev/null
+++ b/cmake/modules/buildtools/FindPatch.cmake
@@ -0,0 +1,84 @@
+#.rst:
+# FindPatch
+# ----------
+# Finds patch executable
+# Windows platforms will download patch zip from mirrors if not found.
+#
+# This will define the following variables::
+#
+# PATCH_EXECUTABLE - patch executable
+
+if(CMAKE_HOST_WIN32)
+
+ find_package(Git)
+ if(Git_FOUND)
+ get_filename_component(GIT_DIR ${GIT_EXECUTABLE} DIRECTORY)
+ endif()
+
+ find_program(PATCH_EXE NAMES patch.exe HINTS "${GIT_DIR}/.." PATH_SUFFIXES usr/bin)
+else()
+ # Freebsd patch is insufficient (too old) look for gnu patch first
+ find_program(PATCH_EXE NAMES gpatch patch)
+endif()
+
+if(CMAKE_HOST_WIN32 AND NOT PATCH_EXE)
+ # Set mirror for potential patch binary download
+ if(NOT KODI_MIRROR)
+ set(KODI_MIRROR "http://mirrors.kodi.tv")
+ endif()
+
+ 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 ${TARBALL_DIR}/${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()
+
+ # CORE_BUILD_DIR may not exist as yet, so create just in case
+ if(NOT EXISTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR})
+ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR})
+ endif()
+
+ # extract the archive containing patch.exe
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR})
+
+ # make sure the extraction worked and that patch.exe is there
+ set(PATCH_PATH ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${PATCH_ARCHIVE_NAME})
+ if(NOT EXISTS "${PATCH_PATH}/bin/patch.exe")
+ message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_PATH}")
+ endif()
+
+ # copy patch.exe into the output directory
+ file(INSTALL "${PATCH_PATH}/bin/patch.exe" DESTINATION ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/bin)
+ # copy patch depends
+ file(GLOB PATCH_BINARIES ${PATCH_PATH}/bin/*.dll)
+ if(NOT "${PATCH_BINARIES}" STREQUAL "")
+ file(INSTALL ${PATCH_BINARIES} DESTINATION ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/bin)
+ endif()
+
+ # make sure that cmake can find the copied patch.exe
+ find_program(PATCH_EXE NAMES patch.exe HINTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/bin REQUIRED)
+endif()
+
+if(PATCH_EXE)
+ execute_process(COMMAND "${PATCH_EXE}" --version
+ OUTPUT_VARIABLE PATCH_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]*patch [^\n]*" PATCH_VERSION "${PATCH_VERSION}")
+ string(REGEX REPLACE ".*patch (.*)" "\\1" PATCH_VERSION "${PATCH_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Patch REQUIRED_VARS PATCH_EXE VERSION_VAR PATCH_VERSION)
+
+if(PATCH_FOUND)
+ set(PATCH_EXECUTABLE "${PATCH_EXE}")
+ mark_as_advanced(PATCH_EXE)
+endif()
diff --git a/cmake/modules/buildtools/FindSWIG.cmake b/cmake/modules/buildtools/FindSWIG.cmake
new file mode 100644
index 0000000..fba544b
--- /dev/null
+++ b/cmake/modules/buildtools/FindSWIG.cmake
@@ -0,0 +1,29 @@
+#.rst:
+# FindSWIG
+# --------
+# Finds the SWIG executable
+#
+# This will define the following variables::
+#
+# SWIG_FOUND - system has SWIG
+# SWIG_EXECUTABLE - the SWIG executable
+
+find_program(SWIG_EXECUTABLE NAMES swig4.0 swig3.0 swig2.0 swig
+ PATH_SUFFIXES swig)
+if(SWIG_EXECUTABLE)
+ execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
+ OUTPUT_VARIABLE SWIG_DIR
+ ERROR_VARIABLE SWIG_swiglib_error
+ RESULT_VARIABLE SWIG_swiglib_result)
+ execute_process(COMMAND ${SWIG_EXECUTABLE} -version
+ OUTPUT_VARIABLE SWIG_version_output
+ ERROR_VARIABLE SWIG_version_output
+ RESULT_VARIABLE SWIG_version_result)
+ string(REGEX REPLACE ".*SWIG Version[^0-9.]*\([0-9.]+\).*" "\\1"
+ SWIG_VERSION "${SWIG_version_output}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SWIG
+ REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
+ VERSION_VAR SWIG_VERSION)
diff --git a/cmake/modules/buildtools/FindTexturePacker.cmake b/cmake/modules/buildtools/FindTexturePacker.cmake
new file mode 100644
index 0000000..4817d15
--- /dev/null
+++ b/cmake/modules/buildtools/FindTexturePacker.cmake
@@ -0,0 +1,93 @@
+#.rst:
+# FindTexturePacker
+# -----------------
+# Finds the TexturePacker
+#
+# If WITH_TEXTUREPACKER is defined and points to a directory,
+# this path will be used to search for the Texturepacker binary
+#
+#
+# This will define the following (imported) targets::
+#
+# TexturePacker::TexturePacker::Executable - The TexturePacker executable participating in build
+# TexturePacker::TexturePacker::Installable - The TexturePacker executable shipped in the Kodi package
+
+if(NOT TARGET TexturePacker::TexturePacker::Executable)
+ if(KODI_DEPENDSBUILD)
+ get_filename_component(_tppath "${NATIVEPREFIX}/bin" ABSOLUTE)
+ find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
+ HINTS ${_tppath})
+
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "External TexturePacker for KODI_DEPENDSBUILD will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
+ elseif(WIN32)
+ get_filename_component(_tppath "${DEPENDS_PATH}/tools/TexturePacker" ABSOLUTE)
+ find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker.exe" TexturePacker.exe
+ HINTS ${_tppath})
+
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "External TexturePacker for WIN32 will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
+ else()
+ if(WITH_TEXTUREPACKER)
+ get_filename_component(_tppath ${WITH_TEXTUREPACKER} ABSOLUTE)
+ get_filename_component(_tppath ${_tppath} DIRECTORY)
+ find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
+ HINTS ${_tppath})
+
+ # Use external TexturePacker executable if found
+ if(TEXTUREPACKER_EXECUTABLE)
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "Found external TexturePacker: ${TEXTUREPACKER_EXECUTABLE}")
+ else()
+ # Warn about external TexturePacker supplied but not fail fatally
+ # because we might have internal TexturePacker executable built
+ # and unset TEXTUREPACKER_EXECUTABLE variable
+ message(WARNING "Could not find '${APP_NAME_LC}-TexturePacker' or 'TexturePacker' executable in ${_tppath} supplied by -DWITH_TEXTUREPACKER. Make sure the executable file name matches these names!")
+ endif()
+ endif()
+
+ # Ship TexturePacker only on Linux and FreeBSD
+ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # But skip shipping it if build architecture can be executed on host
+ # and TEXTUREPACKER_EXECUTABLE is found
+ if(NOT (HOST_CAN_EXECUTE_TARGET AND TEXTUREPACKER_EXECUTABLE))
+ set(INTERNAL_TEXTUREPACKER_INSTALLABLE TRUE CACHE BOOL "" FORCE)
+ endif()
+ endif()
+
+ # Use it during build if build architecture can be executed on host
+ # and TEXTUREPACKER_EXECUTABLE is not found
+ if(HOST_CAN_EXECUTE_TARGET AND NOT TEXTUREPACKER_EXECUTABLE)
+ set(INTERNAL_TEXTUREPACKER_EXECUTABLE TRUE)
+ endif()
+
+ # Build and install internal TexturePacker if needed
+ if (INTERNAL_TEXTUREPACKER_EXECUTABLE OR INTERNAL_TEXTUREPACKER_INSTALLABLE)
+ add_subdirectory(${CMAKE_SOURCE_DIR}/tools/depends/native/TexturePacker build/texturepacker)
+ message(STATUS "Building internal TexturePacker")
+ endif()
+
+ if(INTERNAL_TEXTUREPACKER_INSTALLABLE)
+ add_executable(TexturePacker::TexturePacker::Installable ALIAS TexturePacker)
+ message(STATUS "Shipping internal TexturePacker")
+ endif()
+
+ if(INTERNAL_TEXTUREPACKER_EXECUTABLE)
+ add_executable(TexturePacker::TexturePacker::Executable ALIAS TexturePacker)
+ message(STATUS "Internal TexturePacker will be executed during build")
+ else()
+ message(STATUS "External TexturePacker will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(TexturePacker DEFAULT_MSG TEXTUREPACKER_EXECUTABLE)
+ endif()
+
+ mark_as_advanced(INTERNAL_TEXTUREPACKER_EXECUTABLE INTERNAL_TEXTUREPACKER_INSTALLABLE TEXTUREPACKER)
+ endif()
+endif()
diff --git a/cmake/modules/buildtools/LDGOLD.cmake b/cmake/modules/buildtools/LDGOLD.cmake
new file mode 100644
index 0000000..cdf71bf
--- /dev/null
+++ b/cmake/modules/buildtools/LDGOLD.cmake
@@ -0,0 +1,42 @@
+if(ENABLE_GOLD)
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+ if(LD_VERSION MATCHES "GNU gold")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(LDGOLD_FOUND TRUE)
+ message(STATUS "Linker: GNU gold")
+ else()
+ message(WARNING "GNU gold linker is not available, falling back to default system linker")
+ endif()
+else()
+ message(STATUS "Linker: Default system linker")
+endif()
+
+set(DEFAULT_ENABLE_DEBUGFISSION FALSE)
+if(CMAKE_BUILD_TYPE STREQUAL Debug OR
+ CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo AND
+ LDGOLD_FOUND)
+ set(DEFAULT_ENABLE_DEBUGFISSION TRUE)
+endif()
+
+include(CMakeDependentOption)
+cmake_dependent_option(ENABLE_DEBUGFISSION "Enable Debug Fission support" ON
+ "DEFAULT_ENABLE_DEBUGFISSION" OFF)
+
+set(DEBUGFISSION_FOUND FALSE)
+if(ENABLE_DEBUGFISSION)
+ include(TestCXXAcceptsFlag)
+ check_cxx_accepts_flag(-gsplit-dwarf CXX_ACCEPTS_GSPLIT_DWARF)
+ if(CXX_ACCEPTS_GSPLIT_DWARF)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(DEBUGFISSION_FOUND TRUE)
+ message(STATUS "Debug Fission enabled")
+ else()
+ message(WARNING "Debug Fission is not available")
+ endif()
+endif()
diff --git a/cmake/modules/buildtools/LLD.cmake b/cmake/modules/buildtools/LLD.cmake
new file mode 100644
index 0000000..e77009e
--- /dev/null
+++ b/cmake/modules/buildtools/LLD.cmake
@@ -0,0 +1,22 @@
+if(ENABLE_LLD)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+ if(LD_VERSION MATCHES "LLD")
+ include(FindPackageHandleStandardArgs)
+ find_program(LLD_EXECUTABLE lld)
+ find_package_handle_standard_args(LLD REQUIRED_VARS LLD_EXECUTABLE)
+
+ if(LLD_FOUND)
+ set(CMAKE_LINKER ${LLD_EXECUTABLE})
+ set(CMAKE_CXX_LINK_FLAGS -fuse-ld=lld)
+ set(CMAKE_C_LINK_FLAGS -fuse-ld=lld)
+ set(CMAKE_EXE_LINKER_FLAGS "${LD_FLAGS} -fuse-ld=lld")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ message(STATUS "Linker: LLVM lld")
+ endif()
+ mark_as_advanced(LLD_EXECUTABLE CMAKE_LINKER)
+
+ else()
+ message(FATAL_ERROR "LLVM lld linker not found")
+ endif()
+endif()
diff --git a/cmake/modules/buildtools/MOLD.cmake b/cmake/modules/buildtools/MOLD.cmake
new file mode 100644
index 0000000..cb29ed1
--- /dev/null
+++ b/cmake/modules/buildtools/MOLD.cmake
@@ -0,0 +1,77 @@
+if(ENABLE_MOLD)
+ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)
+ # GCC < 12 doesn't support -fuse-ld=mold, so we have to use tools prefix path
+ # if mold is installed in a non-standard dir, users can set -DMOLD_PREFIX=/path/to/mold_install_prefix
+ find_path(MOLD_PREFIX_DIR NAMES ld
+ NO_DEFAULT_PATH # this is needed, otherwise we find /usr/bin/ld
+ PATH_SUFFIXES libexec/mold
+ PATHS ${MOLD_PREFIX} /usr /usr/local)
+ if(MOLD_PREFIX_DIR)
+ set(COMPILER_ARGS "-B${MOLD_PREFIX_DIR}")
+ else()
+ message(WARNING "Mold LD path not found, you might need to set -DMOLD_PREFIX=/path/to/mold_install_prefix")
+ endif()
+ else()
+ set(COMPILER_ARGS "-fuse-ld=mold")
+ endif()
+
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${COMPILER_ARGS} -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+
+ set(DEFAULT_ENABLE_DEBUGFISSION FALSE)
+ if(CMAKE_BUILD_TYPE STREQUAL Debug OR
+ CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
+ set(DEFAULT_ENABLE_DEBUGFISSION TRUE)
+ endif()
+
+ include(CMakeDependentOption)
+ cmake_dependent_option(ENABLE_DEBUGFISSION "Enable Debug Fission support" ON
+ "DEFAULT_ENABLE_DEBUGFISSION" OFF)
+
+ if(ENABLE_DEBUGFISSION)
+ include(TestCXXAcceptsFlag)
+ check_cxx_accepts_flag(-gsplit-dwarf CXX_ACCEPTS_GSPLIT_DWARF)
+
+ # extract mold version
+ set(LD_VERSION_LIST ${LD_VERSION})
+ separate_arguments(LD_VERSION_LIST)
+ list(GET LD_VERSION_LIST 1 MOLD_VERSION)
+
+ set(DEBUGFISSION_AVAILABLE FALSE)
+ if(CXX_ACCEPTS_GSPLIT_DWARF)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")
+ if(${MOLD_VERSION} VERSION_GREATER_EQUAL "1.2.0")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
+ set(DEBUGFISSION_AVAILABLE TRUE)
+ endif()
+ endif()
+
+ if(DEBUGFISSION_AVAILABLE)
+ message(STATUS "Debug Fission enabled")
+ else()
+ message(WARNING "Debug Fission is not available")
+ endif()
+ endif()
+
+ if(LD_VERSION MATCHES "mold")
+ include(FindPackageHandleStandardArgs)
+ find_program(MOLD_EXECUTABLE mold)
+ find_package_handle_standard_args(MOLD REQUIRED_VARS MOLD_EXECUTABLE)
+
+ if(MOLD_FOUND)
+ set(CMAKE_LINKER ${MOLD_EXECUTABLE})
+ set(CMAKE_CXX_LINK_FLAGS ${COMPILER_ARGS})
+ set(CMAKE_C_LINK_FLAGS ${COMPILER_ARGS})
+ set(CMAKE_EXE_LINKER_FLAGS "${LD_FLAGS} ${COMPILER_ARGS} ${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ message(STATUS "Linker: mold")
+ endif()
+ mark_as_advanced(MOLD_EXECUTABLE CMAKE_LINKER)
+
+ else()
+ message(FATAL_ERROR "Mold linker not found")
+ endif()
+endif()