aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@users.noreply.github.com>2024-05-09 18:32:26 +1000
committerGitHub <noreply@github.com>2024-05-09 18:32:26 +1000
commitdad1445ba04d5a3d4709b61af5fdd9dbe5c9db8c (patch)
tree24c4e225eafeff32de279e7e2adcc73269a521aa
parent82ad57894af481f81698627ca893cf22e29fbec4 (diff)
parent1db5346567cd0f47af64b872a674b69f8d8607c8 (diff)
downloadxbmc-dad1445ba04d5a3d4709b61af5fdd9dbe5c9db8c.tar.xz
Merge pull request #24064 from fuzzard/cmake_findbluray
[cmake] FindBluray migrate to full TARGET usage
-rw-r--r--cmake/modules/FindBluray.cmake110
1 files changed, 56 insertions, 54 deletions
diff --git a/cmake/modules/FindBluray.cmake b/cmake/modules/FindBluray.cmake
index 6f1d5dc6ad..1c4f12c89d 100644
--- a/cmake/modules/FindBluray.cmake
+++ b/cmake/modules/FindBluray.cmake
@@ -3,74 +3,76 @@
# ----------
# Finds the libbluray library
#
-# This will define the following variables::
-#
-# BLURAY_FOUND - system has libbluray
-# BLURAY_INCLUDE_DIRS - the libbluray include directory
-# BLURAY_LIBRARIES - the libbluray libraries
-# BLURAY_DEFINITIONS - the libbluray compile definitions
-#
-# and the following imported targets::
+# This will define the following target:
#
# Bluray::Bluray - The libbluray library
-if(Bluray_FIND_VERSION)
- if(Bluray_FIND_VERSION_EXACT)
- set(Bluray_FIND_SPEC "=${Bluray_FIND_VERSION_COMPLETE}")
- else()
- set(Bluray_FIND_SPEC ">=${Bluray_FIND_VERSION_COMPLETE}")
- endif()
-endif()
-
-find_package(PkgConfig)
+if(NOT TARGET Bluray::Bluray)
-if(PKG_CONFIG_FOUND)
- pkg_check_modules(PC_BLURAY libbluray${Bluray_FIND_SPEC} QUIET)
- set(BLURAY_VERSION ${PC_BLURAY_VERSION})
-endif()
-
-find_path(BLURAY_INCLUDE_DIR libbluray/bluray.h
- HINTS ${PC_BLURAY_INCLUDEDIR})
-
-if(NOT BLURAY_VERSION AND EXISTS ${BLURAY_INCLUDE_DIR}/libbluray/bluray-version.h)
- file(STRINGS ${BLURAY_INCLUDE_DIR}/libbluray/bluray-version.h _bluray_version_str
- REGEX "#define[ \t]BLURAY_VERSION_STRING[ \t][\"]?[0-9.]+[\"]?")
- string(REGEX REPLACE "^.*BLURAY_VERSION_STRING[ \t][\"]?([0-9.]+).*$" "\\1" BLURAY_VERSION ${_bluray_version_str})
- unset(_bluray_version_str)
-endif()
+ find_package(PkgConfig)
-find_library(BLURAY_LIBRARY NAMES bluray libbluray
- HINTS ${PC_BLURAY_LIBDIR})
+ # We only rely on pkgconfig for non windows platforms
+ if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE))
+ if(Bluray_FIND_VERSION_EXACT)
+ set(Bluray_FIND_SPEC "=${Bluray_FIND_VERSION_COMPLETE}")
+ else()
+ set(Bluray_FIND_SPEC ">=${Bluray_FIND_VERSION_COMPLETE}")
+ endif()
+ pkg_check_modules(BLURAY libbluray${Bluray_FIND_SPEC} QUIET)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Bluray
- REQUIRED_VARS BLURAY_LIBRARY BLURAY_INCLUDE_DIR BLURAY_VERSION
- VERSION_VAR BLURAY_VERSION)
+ # First item is the full path of the library file found
+ # pkg_check_modules does not populate a variable of the found library explicitly
+ list(GET BLURAY_LINK_LIBRARIES 0 BLURAY_LIBRARY)
+ else()
+ # todo: for windows use find_package CONFIG call potentially
-if(BLURAY_FOUND)
- set(BLURAY_LIBRARIES ${BLURAY_LIBRARY})
- set(BLURAY_INCLUDE_DIRS ${BLURAY_INCLUDE_DIR})
- set(BLURAY_DEFINITIONS -DHAVE_LIBBLURAY=1)
+ find_path(BLURAY_INCLUDEDIR NAMES libbluray/bluray.h
+ HINTS ${DEPENDS_PATH}/include
+ ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
+ NO_CACHE)
- # todo: improve syntax
- if (NOT CORE_PLATFORM_NAME_LC STREQUAL windowsstore)
- list(APPEND BLURAY_DEFINITIONS -DHAVE_LIBBLURAY_BDJ=1)
+ find_library(BLURAY_LIBRARY NAMES bluray libbluray
+ HINTS ${DEPENDS_PATH}/lib
+ ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
+ NO_CACHE)
endif()
- if(${BLURAY_LIBRARY} MATCHES ".+\.a$" AND PC_BLURAY_STATIC_LIBRARIES)
- list(APPEND BLURAY_LIBRARIES ${PC_BLURAY_STATIC_LIBRARIES})
+ if(NOT BLURAY_VERSION AND EXISTS ${BLURAY_INCLUDEDIR}/libbluray/bluray-version.h)
+ file(STRINGS ${BLURAY_INCLUDEDIR}/libbluray/bluray-version.h _bluray_version_str
+ REGEX "#define[ \t]BLURAY_VERSION_STRING[ \t][\"]?[0-9.]+[\"]?")
+ string(REGEX REPLACE "^.*BLURAY_VERSION_STRING[ \t][\"]?([0-9.]+).*$" "\\1" BLURAY_VERSION ${_bluray_version_str})
+ unset(_bluray_version_str)
endif()
- if(NOT TARGET Bluray::Bluray)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Bluray
+ REQUIRED_VARS BLURAY_LIBRARY BLURAY_INCLUDEDIR BLURAY_VERSION
+ VERSION_VAR BLURAY_VERSION)
+
+ if(BLURAY_FOUND)
add_library(Bluray::Bluray UNKNOWN IMPORTED)
- if(BLURAY_LIBRARY)
+ set_target_properties(Bluray::Bluray PROPERTIES
+ IMPORTED_LOCATION "${BLURAY_LIBRARY}"
+ INTERFACE_COMPILE_DEFINITIONS "HAVE_LIBBLURAY=1"
+ INTERFACE_INCLUDE_DIRECTORIES "${BLURAY_INCLUDEDIR}")
+
+ # Add link libraries for static lib usage
+ if(${BLURAY_LIBRARY} MATCHES ".+\.a$" AND BLURAY_LINK_LIBRARIES)
+ # Remove duplicates
+ list(REMOVE_DUPLICATES BLURAY_LINK_LIBRARIES)
+
+ # Remove own library - eg libbluray.a
+ list(FILTER BLURAY_LINK_LIBRARIES EXCLUDE REGEX ".*bluray.*\.a$")
+
set_target_properties(Bluray::Bluray PROPERTIES
- IMPORTED_LOCATION "${BLURAY_LIBRARY}")
+ INTERFACE_LINK_LIBRARIES "${BLURAY_LINK_LIBRARIES}")
endif()
- set_target_properties(Bluray::Bluray PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${BLURAY_INCLUDE_DIR}"
- INTERFACE_COMPILE_DEFINITIONS HAVE_LIBBLURAY=1)
+
+ if(NOT CORE_PLATFORM_NAME_LC STREQUAL windowsstore)
+ set_target_properties(Bluray::Bluray PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "HAVE_LIBBLURAY_BDJ=1")
+ endif()
+
+ set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Bluray::Bluray)
endif()
endif()
-
-mark_as_advanced(BLURAY_INCLUDE_DIR BLURAY_LIBRARY)