aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-07-09 16:43:40 +1000
committerfuzzard <fuzzard@kodi.tv>2024-07-09 20:56:40 +1000
commitcd09120d2801f1f5bb5d67d7874503a35a636fbb (patch)
treed4b1141033259e7eb7a6cec9e12b06ed55fe8755 /cmake
parent3311a4874c08cadf80ef476c8e8324750e62b756 (diff)
[cmake][modules] Rework libdvd* modules
Streamline, remove some redundancies, actually be a shared library target
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindLibDvd.cmake41
-rw-r--r--cmake/modules/FindLibDvdCSS.cmake45
-rw-r--r--cmake/modules/FindLibDvdNav.cmake49
-rw-r--r--cmake/modules/FindLibDvdRead.cmake50
4 files changed, 78 insertions, 107 deletions
diff --git a/cmake/modules/FindLibDvd.cmake b/cmake/modules/FindLibDvd.cmake
index 48947165d6..dce52d9bca 100644
--- a/cmake/modules/FindLibDvd.cmake
+++ b/cmake/modules/FindLibDvd.cmake
@@ -1,23 +1,26 @@
+#.rst:
+# FindLibDvd
+# ----------
+#
+# This will define the following target:
+#
+# ${APP_NAME_LC}::Dvd - Wrapper target to generate/build libdvdnav shared library
-# Check for existing LIBDVDREAD.
-# Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html
-set(FPHSA_NAME_MISMATCHED 1)
-find_package(LibDvdNav MODULE REQUIRED)
-unset(FPHSA_NAME_MISMATCHED)
+if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
+ find_package(LibDvdNav MODULE REQUIRED)
-set(_dvdlibs LibDvdNav::LibDvdNav
- $<$<TARGET_EXISTS:LibDvdCSS::LibDvdCSS>:LibDvdCSS::LibDvdCSS>>)
+ set(_dvdlibs LibDvdNav::LibDvdNav
+ $<$<TARGET_EXISTS:LibDvdCSS::LibDvdCSS>:LibDvdCSS::LibDvdCSS>>)
-if(NOT CORE_SYSTEM_NAME MATCHES windows)
- # link a shared dvdnav library that includes the whole archives of dvdread and dvdcss as well
- # the quotes around _dvdlibs are on purpose, since we want to pass a list to the function that will be unpacked automatically
- core_link_library(LibDvdNav::LibDvdNav system/players/VideoPlayer/libdvdnav libdvdnav archives "${_dvdlibs}")
-else()
- set(LIBDVD_TARGET_DIR .)
- copy_file_to_buildtree(${DEPENDS_PATH}/bin/libdvdnav.dll DIRECTORY ${LIBDVD_TARGET_DIR})
-endif()
+ if(CORE_SYSTEM_NAME MATCHES windows)
+ set(LIBDVD_TARGET_DIR .)
+ copy_file_to_buildtree($<TARGET_FILE:LibDvdNav::LibDvdNav> DIRECTORY ${LIBDVD_TARGET_DIR})
+ else()
+ # link a shared dvdnav library that includes the whole archives of dvdread and dvdcss as well
+ # the quotes around _dvdlibs are on purpose, since we want to pass a list to the function that will be unpacked automatically
+ core_link_library(LibDvdNav::LibDvdNav system/players/VideoPlayer/libdvdnav libdvdnav archives "${_dvdlibs}")
+ endif()
-add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED)
-set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
- INTERFACE_LINK_LIBRARIES "LibDvdNav::LibDvdNav")
-add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} LibDvdNav::LibDvdNav)
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} INTERFACE IMPORTED)
+ add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} LibDvdNav::LibDvdNav)
+endif()
diff --git a/cmake/modules/FindLibDvdCSS.cmake b/cmake/modules/FindLibDvdCSS.cmake
index ea8d92c407..deed2de5ac 100644
--- a/cmake/modules/FindLibDvdCSS.cmake
+++ b/cmake/modules/FindLibDvdCSS.cmake
@@ -7,7 +7,7 @@
#
# LibDvdCSS::LibDvdCSS - The LibDvdCSS library
-if(ENABLE_DVDCSS)
+if(NOT TARGET LibDvdCSS::LibDvdCSS)
include(cmake/scripts/common/ModuleHelpers.cmake)
set(MODULE_LC libdvdcss)
@@ -34,12 +34,10 @@ if(ENABLE_DVDCSS)
if(CORE_SYSTEM_NAME STREQUAL android)
if(ARCH STREQUAL arm)
set(HOST_ARCH arm-linux-androideabi)
- elseif(ARCH STREQUAL aarch64)
- set(HOST_ARCH aarch64-linux-android)
elseif(ARCH STREQUAL i486-linux)
set(HOST_ARCH i686-linux-android)
- elseif(ARCH STREQUAL x86_64)
- set(HOST_ARCH x86_64-linux-android)
+ elseif()
+ set(HOST_ARCH ${ARCH}-linux-android)
endif()
elseif(CORE_SYSTEM_NAME STREQUAL windowsstore)
set(LIBDVD_ADDITIONAL_ARGS "-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}")
@@ -83,28 +81,21 @@ if(ENABLE_DVDCSS)
BUILD_DEP_TARGET()
-endif()
-
-include(SelectLibraryConfigurations)
-select_library_configurations(LibDvdCSS)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LibDvdCSS
- REQUIRED_VARS LIBDVDCSS_LIBRARY LIBDVDCSS_INCLUDE_DIR
- VERSION_VAR LIBDVDCSS_VERSION)
-
-if(LIBDVDCSS_FOUND)
- add_library(LibDvdCSS::LibDvdCSS UNKNOWN IMPORTED)
- set_target_properties(LibDvdCSS::LibDvdCSS PROPERTIES
- IMPORTED_LOCATION "${LIBDVDCSS_LIBRARY}"
- INTERFACE_COMPILE_DEFINITIONS "HAVE_DVDCSS_DVDCSS_H"
- INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDCSS_INCLUDE_DIR}")
-
- if(TARGET libdvdcss)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibDvdCSS
+ REQUIRED_VARS LIBDVDCSS_LIBRARY LIBDVDCSS_INCLUDE_DIR
+ VERSION_VAR LIBDVDCSS_VERSION)
+
+ if(LibDvdCSS_FOUND)
+ add_library(LibDvdCSS::LibDvdCSS STATIC IMPORTED)
+ set_target_properties(LibDvdCSS::LibDvdCSS PROPERTIES
+ IMPORTED_LOCATION "${LIBDVDCSS_LIBRARY}"
+ INTERFACE_COMPILE_DEFINITIONS "HAVE_DVDCSS_DVDCSS_H"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDCSS_INCLUDE_DIR}")
add_dependencies(LibDvdCSS::LibDvdCSS libdvdcss)
- endif()
-else()
- if(LibDvdCSS_FIND_REQUIRED)
- message(FATAL_ERROR "Libdvdcss not found. Possibly remove ENABLE_DVDCSS.")
+ else()
+ if(LibDvdCSS_FIND_REQUIRED)
+ message(FATAL_ERROR "Libdvdcss not found. Possibly remove ENABLE_DVDCSS.")
+ endif()
endif()
endif()
diff --git a/cmake/modules/FindLibDvdNav.cmake b/cmake/modules/FindLibDvdNav.cmake
index fe319be03e..503f559e10 100644
--- a/cmake/modules/FindLibDvdNav.cmake
+++ b/cmake/modules/FindLibDvdNav.cmake
@@ -9,11 +9,7 @@
if(NOT TARGET LibDvdNav::LibDvdNav)
- # Check for existing LibDvdRead.
- # Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html
- set(FPHSA_NAME_MISMATCHED 1)
find_package(LibDvdRead MODULE REQUIRED)
- unset(FPHSA_NAME_MISMATCHED)
include(cmake/scripts/common/ModuleHelpers.cmake)
@@ -41,12 +37,10 @@ if(NOT TARGET LibDvdNav::LibDvdNav)
if(CORE_SYSTEM_NAME STREQUAL android)
if(ARCH STREQUAL arm)
set(HOST_ARCH arm-linux-androideabi)
- elseif(ARCH STREQUAL aarch64)
- set(HOST_ARCH aarch64-linux-android)
elseif(ARCH STREQUAL i486-linux)
set(HOST_ARCH i686-linux-android)
- elseif(ARCH STREQUAL x86_64)
- set(HOST_ARCH x86_64-linux-android)
+ elseif()
+ set(HOST_ARCH ${ARCH}-linux-android)
endif()
elseif(CORE_SYSTEM_NAME STREQUAL windowsstore)
set(LIBDVD_ADDITIONAL_ARGS "-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}")
@@ -105,33 +99,24 @@ if(NOT TARGET LibDvdNav::LibDvdNav)
BUILD_DEP_TARGET()
- if(TARGET LibDvdRead::LibDvdRead)
- add_dependencies(libdvdnav LibDvdRead::LibDvdRead)
- endif()
-endif()
+ add_dependencies(libdvdnav LibDvdRead::LibDvdRead)
-include(SelectLibraryConfigurations)
-select_library_configurations(LibDvdNav)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibDvdNav
+ REQUIRED_VARS LIBDVDNAV_LIBRARY LIBDVDNAV_INCLUDE_DIR
+ VERSION_VAR LIBDVDNAV_VERSION)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LibDvdNav
- REQUIRED_VARS LIBDVDNAV_LIBRARY LIBDVDNAV_INCLUDE_DIR
- VERSION_VAR LIBDVDNAV_VERSION)
+ if(LibDvdNav_FOUND)
+ add_library(LibDvdNav::LibDvdNav UNKNOWN IMPORTED)
+ set_target_properties(LibDvdNav::LibDvdNav PROPERTIES
+ IMPORTED_LOCATION "${LIBDVDNAV_LIBRARY}"
+ INTERFACE_LINK_LIBRARIES LibDvdRead::LibDvdRead
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDNAV_INCLUDE_DIR}")
-if(LIBDVDNAV_FOUND)
- add_library(LibDvdNav::LibDvdNav UNKNOWN IMPORTED)
- set_target_properties(LibDvdNav::LibDvdNav PROPERTIES
- IMPORTED_LOCATION "${LIBDVDNAV_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDNAV_INCLUDE_DIR}")
-
- if(TARGET libdvdnav)
add_dependencies(LibDvdNav::LibDvdNav libdvdnav)
- endif()
- if(TARGET LibDvdRead::LibDvdRead)
- target_link_libraries(LibDvdNav::LibDvdNav INTERFACE LibDvdRead::LibDvdRead)
- endif()
-else()
- if(LibDvdNav_FIND_REQUIRED)
- message(FATAL_ERROR "Libdvdnav not found")
+ else()
+ if(LibDvdNav_FIND_REQUIRED)
+ message(FATAL_ERROR "Libdvdnav not found")
+ endif()
endif()
endif()
diff --git a/cmake/modules/FindLibDvdRead.cmake b/cmake/modules/FindLibDvdRead.cmake
index 9f590343af..4dead2d137 100644
--- a/cmake/modules/FindLibDvdRead.cmake
+++ b/cmake/modules/FindLibDvdRead.cmake
@@ -10,11 +10,7 @@
if(NOT TARGET LibDvdRead::LibDvdRead)
if(ENABLE_DVDCSS)
- # Check for existing LIBDVDCSS.
- # Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html
- set(FPHSA_NAME_MISMATCHED 1)
find_package(LibDvdCSS MODULE REQUIRED)
- unset(FPHSA_NAME_MISMATCHED)
endif()
include(cmake/scripts/common/ModuleHelpers.cmake)
@@ -43,12 +39,10 @@ if(NOT TARGET LibDvdRead::LibDvdRead)
if(CORE_SYSTEM_NAME STREQUAL android)
if(ARCH STREQUAL arm)
set(HOST_ARCH arm-linux-androideabi)
- elseif(ARCH STREQUAL aarch64)
- set(HOST_ARCH aarch64-linux-android)
elseif(ARCH STREQUAL i486-linux)
set(HOST_ARCH i686-linux-android)
- elseif(ARCH STREQUAL x86_64)
- set(HOST_ARCH x86_64-linux-android)
+ else()
+ set(HOST_ARCH ${ARCH}-linux-android)
endif()
elseif(CORE_SYSTEM_NAME STREQUAL windowsstore)
set(LIBDVD_ADDITIONAL_ARGS "-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}" "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}")
@@ -71,7 +65,7 @@ if(NOT TARGET LibDvdRead::LibDvdRead)
if(TARGET LibDvdCSS::LibDvdCSS)
string(APPEND LIBDVDREAD_CFLAGS " -I$<TARGET_PROPERTY:LibDvdCSS::LibDvdCSS,INTERFACE_INCLUDE_DIRECTORIES> $<$<TARGET_EXISTS:LibDvdCSS::LibDvdCSS>:-D$<TARGET_PROPERTY:LibDvdCSS::LibDvdCSS,INTERFACE_COMPILE_DEFINITIONS>>")
- string(APPEND with-css "--with-libdvdcss")
+ set(with-css "--with-libdvdcss")
endif()
find_program(AUTORECONF autoreconf REQUIRED)
@@ -105,30 +99,28 @@ if(NOT TARGET LibDvdRead::LibDvdRead)
if(TARGET LibDvdCSS::LibDvdCSS)
add_dependencies(libdvdread LibDvdCSS::LibDvdCSS)
endif()
-endif()
-include(SelectLibraryConfigurations)
-select_library_configurations(LibDvdRead)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibDvdRead
+ REQUIRED_VARS LIBDVDREAD_LIBRARY LIBDVDREAD_INCLUDE_DIR
+ VERSION_VAR LIBDVDREAD_VERSION)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LibDvdRead
- REQUIRED_VARS LIBDVDREAD_LIBRARY LIBDVDREAD_INCLUDE_DIR
- VERSION_VAR LIBDVDREAD_VERSION)
+ if(LibDvdRead_FOUND)
+ add_library(LibDvdRead::LibDvdRead STATIC IMPORTED)
+ set_target_properties(LibDvdRead::LibDvdRead PROPERTIES
+ IMPORTED_LOCATION "${LIBDVDREAD_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDREAD_INCLUDE_DIR}")
-if(LIBDVDREAD_FOUND)
- add_library(LibDvdRead::LibDvdRead UNKNOWN IMPORTED)
- set_target_properties(LibDvdRead::LibDvdRead PROPERTIES
- IMPORTED_LOCATION "${LIBDVDREAD_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${LIBDVDREAD_INCLUDE_DIR}")
+ if(TARGET LibDvdCSS::LibDvdCSS)
+ set_target_properties(LibDvdRead::LibDvdRead PROPERTIES
+ INTERFACE_LINK_LIBRARIES LibDvdCSS::LibDvdCSS)
+ add_dependencies(LibDvdRead::LibDvdRead LibDvdCSS::LibDvdCSS)
+ endif()
- if(TARGET libdvdread)
add_dependencies(LibDvdRead::LibDvdRead libdvdread)
- endif()
- if(TARGET LibDvdCSS::LibDvdCSS)
- target_link_libraries(LibDvdRead::LibDvdRead INTERFACE LibDvdCSS::LibDvdCSS)
- endif()
-else()
- if(LibDvdRead_FIND_REQUIRED)
- message(FATAL_ERROR "Libdvdread not found")
+ else()
+ if(LibDvdRead_FIND_REQUIRED)
+ message(FATAL_ERROR "Libdvdread not found")
+ endif()
endif()
endif()