diff options
author | fuzzard <fuzzard@kodi.tv> | 2022-02-12 19:12:53 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2022-03-21 17:42:23 +1000 |
commit | f32595fdf791be6bd765ebc7792770d06a9e2c80 (patch) | |
tree | 363b7c16a7fff6e1df794ccd4c40b89557e40072 /cmake | |
parent | dbcf8ec99e3e497246c61eaee3f13fbc2b25db51 (diff) |
[cmake] update + build crossguid all platforms
crossguid hasnt been updated in a long time (~2015 was our previous hash)
crossguid now natively uses cmake, so remove our cmakelists file
first patch is to get around a failure due to unused function on apple platforms.
a second patch is introduced due to a build failure with the default -Werror used
Build crossguid in core cmake project for all platforms by default.
Remove from windows the bundled download of crossguid lib
rework usage of debug_postfix in SETUP_BUILD_VARS macro
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindCrossGUID.cmake | 77 | ||||
-rw-r--r-- | cmake/modules/FindPatch.cmake | 60 |
2 files changed, 121 insertions, 16 deletions
diff --git a/cmake/modules/FindCrossGUID.cmake b/cmake/modules/FindCrossGUID.cmake index 3a21bc26ca..c10275c3cd 100644 --- a/cmake/modules/FindCrossGUID.cmake +++ b/cmake/modules/FindCrossGUID.cmake @@ -1,43 +1,85 @@ +# FindCrossGUID +# ------- +# Finds the CrossGUID library +# +# This will define the following variables:: +# +# CROSSGUID_FOUND_FOUND - system has CrossGUID +# CROSSGUID_INCLUDE_DIRS - the CrossGUID include directory +# CROSSGUID_LIBRARIES - the CrossGUID libraries +# CROSSGUID_DEFINITIONS - cmake definitions required +# +# and the following imported targets:: +# +# crossguid - The CrossGUID library + if(ENABLE_INTERNAL_CROSSGUID) include(cmake/scripts/common/ModuleHelpers.cmake) set(MODULE_LC crossguid) + # Temp: We force CMAKE_BUILD_TYPE to release, and makefile builds respect this + # Multi config generators (eg VS, Xcode) dont, so handle debug postfix build/link for them only + if(NOT CMAKE_GENERATOR STREQUAL "Unix Makefiles") + set(CROSSGUID_DEBUG_POSTFIX "-dgb") + endif() + SETUP_BUILD_VARS() - if(APPLE) - set(EXTRA_ARGS "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}") + set(CROSSGUID_VERSION ${${MODULE}_VER}) + set(CROSSGUID_DEFINITIONS -DHAVE_NEW_CROSSGUID) + + if(ANDROID) + list(APPEND CROSSGUID_DEFINITIONS -DGUID_ANDROID) endif() + # Use custom findpatch to handle windows patch binary if not available + include(cmake/modules/FindPatch.cmake) + + set(PATCH_COMMAND ${PATCH_EXECUTABLE} -p1 -i ${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/001-fix-unused-function.patch + COMMAND ${PATCH_EXECUTABLE} -p1 -i ${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/002-disable-Wall-error.patch) + + # Force release build type. crossguid forces a debug postfix -dgb. may want to patch this + # if we enable adaptive build type for the library. set(CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} - -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} - "${EXTRA_ARGS}") - set(PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/CMakeLists.txt - <SOURCE_DIR>) + -DCROSSGUID_TESTS=OFF + -DDISABLE_WALL=ON + -DCMAKE_BUILD_TYPE=Release) BUILD_DEP_TARGET() + else() - find_path(CROSSGUID_INCLUDE_DIR NAMES guid.hpp guid.h) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_CROSSGUID crossguid REQUIRED QUIET) + set(CROSSGUID_VERSION ${PC_CROSSGUID_VERSION}) + endif() - find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid) - find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd) + find_path(CROSSGUID_INCLUDE_DIR NAMES crossguid/guid.hpp guid.h + PATHS ${PC_CROSSGUID_INCLUDEDIR}) + + find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid + PATHS ${PC_CROSSGUID_LIBDIR}) + find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd crossguid-dgb + PATHS ${PC_CROSSGUID_LIBDIR}) - include(SelectLibraryConfigurations) - select_library_configurations(CROSSGUID) endif() +# Select relevant lib build type (ie CROSSGUID_LIBRARY_RELEASE or CROSSGUID_LIBRARY_DEBUG) +include(SelectLibraryConfigurations) +select_library_configurations(CROSSGUID) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CrossGUID REQUIRED_VARS CROSSGUID_LIBRARY CROSSGUID_INCLUDE_DIR - VERSION_VAR CROSSGUID_VER) + VERSION_VAR CROSSGUID_VERSION) if(CROSSGUID_FOUND) set(CROSSGUID_LIBRARIES ${CROSSGUID_LIBRARY}) set(CROSSGUID_INCLUDE_DIRS ${CROSSGUID_INCLUDE_DIR}) - if(EXISTS "${CROSSGUID_INCLUDE_DIR}/guid.hpp") - set(CROSSGUID_DEFINITIONS -DHAVE_NEW_CROSSGUID) + # NEW_CROSSGUID >= 0.2.0 release + if(EXISTS "${CROSSGUID_INCLUDE_DIR}/crossguid/guid.hpp") + list(APPEND CROSSGUID_DEFINITIONS -DHAVE_NEW_CROSSGUID) endif() if(NOT TARGET crossguid) @@ -47,8 +89,11 @@ if(CROSSGUID_FOUND) INTERFACE_INCLUDE_DIRECTORIES "${CROSSGUID_INCLUDE_DIR}") endif() - if(NOT WIN32 AND NOT APPLE) + if(UNIX AND NOT (APPLE OR ANDROID)) + # Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html + set(FPHSA_NAME_MISMATCHED 1) find_package(UUID REQUIRED) + unset(FPHSA_NAME_MISMATCHED) list(APPEND CROSSGUID_INCLUDE_DIRS ${UUID_INCLUDE_DIRS}) list(APPEND CROSSGUID_LIBRARIES ${UUID_LIBRARIES}) endif() diff --git a/cmake/modules/FindPatch.cmake b/cmake/modules/FindPatch.cmake new file mode 100644 index 0000000000..3f6afd7c1b --- /dev/null +++ b/cmake/modules/FindPatch.cmake @@ -0,0 +1,60 @@ +#.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 + +find_program(PATCH_EXECUTABLE NAMES patch patch.exe) +if(NOT PATCH_EXECUTABLE) + if(WIN32 OR WINDOWSSTORE) + # 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_EXECUTABLE NAMES patch.exe HINTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/bin REQUIRED) + else() + message(FATAL_ERROR "ERROR - No patch executable found") + endif() +endif() |