diff options
author | fuzzard <fuzzard@kodi.tv> | 2024-05-12 18:22:01 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2024-06-22 13:17:14 +1000 |
commit | 7658b607954ac3e6734ba54b1d50c78f41154ae9 (patch) | |
tree | 74fb113d858e6616b7fea5e1bda3abd186a566a4 /cmake | |
parent | 15cd71aff10b3949100b2fad7286de61b99b6487 (diff) |
[cmake][modules] FindCdio update to target usage
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindCdio.cmake | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/cmake/modules/FindCdio.cmake b/cmake/modules/FindCdio.cmake index 16a7aef9c6..5f8b33c8d1 100644 --- a/cmake/modules/FindCdio.cmake +++ b/cmake/modules/FindCdio.cmake @@ -3,42 +3,56 @@ # -------- # Finds the cdio library # -# This will define the following variables:: +# This will define the following target: +# +# ${APP_NAME_LC}::Cdio - The LibCap library # -# CDIO_FOUND - system has cdio -# CDIO_INCLUDE_DIRS - the cdio include directory -# CDIO_LIBRARIES - the cdio libraries - -find_package(PkgConfig) - -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_CDIO libcdio>=0.80 QUIET) - pkg_check_modules(PC_CDIOPP libcdio++>=2.1.0 QUIET) -endif() - -find_path(CDIO_INCLUDE_DIR NAMES cdio/cdio.h - HINTS ${PC_CDIO_INCLUDEDIR}) - -find_library(CDIO_LIBRARY NAMES cdio libcdio - HINTS ${PC_CDIO_LIBDIR}) - -if(DEFINED PC_CDIO_VERSION AND DEFINED PC_CDIOPP_VERSION AND NOT "${PC_CDIO_VERSION}" VERSION_EQUAL "${PC_CDIOPP_VERSION}") - message(WARNING "Detected libcdio (${PC_CDIO_VERSION}) and libcdio++ (${PC_CDIOPP_VERSION}) version mismatch. libcdio++ will not be used.") -else() - find_path(CDIOPP_INCLUDE_DIR NAMES cdio++/cdio.hpp - HINTS ${PC_CDIOPP_INCLUDEDIR} ${CDIO_INCLUDE_DIR}) - - set(CDIO_VERSION ${PC_CDIO_VERSION}) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Cdio - REQUIRED_VARS CDIO_LIBRARY CDIO_INCLUDE_DIR - VERSION_VAR CDIO_VERSION) -if(CDIO_FOUND) - set(CDIO_LIBRARIES ${CDIO_LIBRARY}) - set(CDIO_INCLUDE_DIRS ${CDIO_INCLUDE_DIR}) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) + find_package(PkgConfig) + + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_CDIO libcdio>=0.80 QUIET) + pkg_check_modules(PC_CDIOPP libcdio++>=2.1.0 QUIET) + endif() + + find_path(CDIO_INCLUDE_DIR NAMES cdio/cdio.h + HINTS ${PC_CDIO_INCLUDEDIR}) + + find_library(CDIO_LIBRARY NAMES cdio libcdio + HINTS ${PC_CDIO_LIBDIR}) + + if(DEFINED PC_CDIO_VERSION AND DEFINED PC_CDIOPP_VERSION AND NOT "${PC_CDIO_VERSION}" VERSION_EQUAL "${PC_CDIOPP_VERSION}") + message(WARNING "Detected libcdio (${PC_CDIO_VERSION}) and libcdio++ (${PC_CDIOPP_VERSION}) version mismatch. libcdio++ will not be used.") + else() + find_path(CDIOPP_INCLUDE_DIR NAMES cdio++/cdio.hpp + HINTS ${PC_CDIOPP_INCLUDEDIR} ${CDIO_INCLUDE_DIR}) + + set(CDIO_VERSION ${PC_CDIO_VERSION}) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Cdio + REQUIRED_VARS CDIO_LIBRARY CDIO_INCLUDE_DIR + VERSION_VAR CDIO_VERSION) + + if(CDIO_FOUND) + + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${CDIO_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CDIO_INCLUDE_DIR}") + + if(CDIOPP_INCLUDE_DIR) + add_library(${APP_NAME_LC}::CdioPP INTERFACE IMPORTED) + set_target_properties(${APP_NAME_LC}::CdioPP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CDIOPP_INCLUDE_DIR}") + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "${APP_NAME_LC}::CdioPP") + endif() + else() + if(Cdio_FIND_REQUIRED) + message(FATAL_ERROR "cdio library not found.") + endif() + endif() endif() - -mark_as_advanced(CDIO_INCLUDE_DIR CDIOPP_INCLUDE_DIR CDIO_LIBRARY) |