aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-16 20:00:05 +1000
committerfuzzard <fuzzard@kodi.tv>2024-06-22 14:06:06 +1000
commit4f66b90d077f723c833e00fc6708167647185ac2 (patch)
treefb134c3ce6994ef75f01918e9d7f00a9d92b3456 /cmake
parent8611aef2a092c0027d7bb22a93721cc11bfcc76b (diff)
[cmake][modules] FindWaylandpp update to target usage
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindWaylandpp.cmake174
-rw-r--r--cmake/scripts/linux/ExtraTargets.cmake5
-rw-r--r--cmake/scripts/webos/ExtraTargets.cmake5
3 files changed, 97 insertions, 87 deletions
diff --git a/cmake/modules/FindWaylandpp.cmake b/cmake/modules/FindWaylandpp.cmake
index 7b28892a04..cc9d0827fc 100644
--- a/cmake/modules/FindWaylandpp.cmake
+++ b/cmake/modules/FindWaylandpp.cmake
@@ -2,98 +2,106 @@
# -------------
# Finds the waylandpp library
#
-# This will define the following variables::
+# This will define the following target:
#
-# WAYLANDPP_FOUND - the system has waylandpp
-# WAYLANDPP_INCLUDE_DIRS - the waylandpp include directory
-# WAYLANDPP_LIBRARIES - the waylandpp libraries
-# WAYLANDPP_DEFINITIONS - the waylandpp definitions
-# WAYLANDPP_SCANNER - path to wayland-scanner++
-
-find_package(PkgConfig)
-pkg_check_modules(PC_WAYLANDPP wayland-client++ wayland-egl++ wayland-cursor++ QUIET)
-
-if(PC_WAYLANDPP_FOUND)
- pkg_get_variable(PC_WAYLANDPP_PKGDATADIR wayland-client++ pkgdatadir)
-else()
- message(SEND_ERROR "wayland-client++ not found via pkg-config")
-endif()
+# ${APP_NAME_LC}::Waylandpp - The waylandpp library
-pkg_check_modules(PC_WAYLANDPP_SCANNER wayland-scanner++ QUIET)
+if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
+ find_package(PkgConfig)
+ pkg_check_modules(PC_WAYLANDPP wayland-client++ wayland-egl++ wayland-cursor++ QUIET)
-if(PC_WAYLANDPP_SCANNER_FOUND)
- pkg_get_variable(PC_WAYLANDPP_SCANNER wayland-scanner++ wayland_scannerpp)
-else()
- message(SEND_ERROR "wayland-scanner++ not found via pkg-config")
-endif()
+ if(PC_WAYLANDPP_FOUND)
+ pkg_get_variable(PC_WAYLANDPP_PKGDATADIR wayland-client++ pkgdatadir)
+ else()
+ message(SEND_ERROR "wayland-client++ not found via pkg-config")
+ endif()
-find_path(WAYLANDPP_INCLUDE_DIR wayland-client.hpp HINTS ${PC_WAYLANDPP_INCLUDEDIR})
+ find_path(WAYLANDPP_INCLUDE_DIR wayland-client.hpp HINTS ${PC_WAYLANDPP_INCLUDEDIR})
+
+ find_library(WAYLANDPP_CLIENT_LIBRARY NAMES wayland-client++
+ HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+
+ find_library(WAYLANDPP_CURSOR_LIBRARY NAMES wayland-cursor++
+ HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+
+ find_library(WAYLANDPP_EGL_LIBRARY NAMES wayland-egl++
+ HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+
+ if(KODI_DEPENDSBUILD)
+ pkg_check_modules(PC_WAYLANDC wayland-client wayland-egl wayland-cursor QUIET)
+
+ if(PREFER_TOOLCHAIN_PATH)
+ set(WAYLAND_SEARCH_PATH ${PREFER_TOOLCHAIN_PATH}
+ NO_DEFAULT_PATH
+ PATH_SUFFIXES usr/lib)
+ else()
+ set(WAYLAND_SEARCH_PATH ${PC_WAYLANDC_LIBRARY_DIRS})
+ endif()
+
+ find_library(WAYLANDC_CLIENT_LIBRARY NAMES wayland-client
+ HINTS ${WAYLAND_SEARCH_PATH}
+ REQUIRED)
+ find_library(WAYLANDC_CURSOR_LIBRARY NAMES wayland-cursor
+ HINTS ${WAYLAND_SEARCH_PATH}
+ REQUIRED)
+ find_library(WAYLANDC_EGL_LIBRARY NAMES wayland-egl
+ HINTS ${WAYLAND_SEARCH_PATH}
+ REQUIRED)
+
+ set(WAYLANDPP_STATIC_DEPS ${WAYLANDC_CLIENT_LIBRARY}
+ ${WAYLANDC_CURSOR_LIBRARY}
+ ${WAYLANDC_EGL_LIBRARY})
+ endif()
-find_library(WAYLANDPP_CLIENT_LIBRARY NAMES wayland-client++
- HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+ # Promote to cache variables so all code can access it
+ set(WAYLANDPP_PROTOCOLS_DIR "${PC_WAYLANDPP_PKGDATADIR}/protocols" CACHE INTERNAL "")
-find_library(WAYLANDPP_CURSOR_LIBRARY NAMES wayland-cursor++
- HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+ include (FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Waylandpp
+ REQUIRED_VARS WAYLANDPP_INCLUDE_DIR
+ WAYLANDPP_CLIENT_LIBRARY
+ WAYLANDPP_CURSOR_LIBRARY
+ WAYLANDPP_EGL_LIBRARY
+ VERSION_VAR WAYLANDPP_wayland-client++_VERSION)
-find_library(WAYLANDPP_EGL_LIBRARY NAMES wayland-egl++
- HINTS ${PC_WAYLANDPP_LIBRARY_DIRS})
+ if(WAYLANDPP_FOUND)
-if(KODI_DEPENDSBUILD)
- pkg_check_modules(PC_WAYLANDC wayland-client wayland-egl wayland-cursor QUIET)
+ find_package(WaylandPPScanner REQUIRED)
- if(PREFER_TOOLCHAIN_PATH)
- set(WAYLAND_SEARCH_PATH ${PREFER_TOOLCHAIN_PATH}
- NO_DEFAULT_PATH
- PATH_SUFFIXES usr/lib)
- else()
- set(WAYLAND_SEARCH_PATH ${PC_WAYLANDC_LIBRARY_DIRS})
- endif()
+ set(WAYLANDPP_INCLUDE_DIRS ${WAYLANDPP_INCLUDE_DIR})
+ set(WAYLANDPP_LIBRARIES
+ ${WAYLANDPP_STATIC_DEPS})
- find_library(WAYLANDC_CLIENT_LIBRARY NAMES wayland-client
- HINTS ${WAYLAND_SEARCH_PATH}
- REQUIRED)
- find_library(WAYLANDC_CURSOR_LIBRARY NAMES wayland-cursor
- HINTS ${WAYLAND_SEARCH_PATH}
- REQUIRED)
- find_library(WAYLANDC_EGL_LIBRARY NAMES wayland-egl
- HINTS ${WAYLAND_SEARCH_PATH}
- REQUIRED)
-
- set(WAYLANDPP_STATIC_DEPS ${WAYLANDC_CLIENT_LIBRARY}
- ${WAYLANDC_CURSOR_LIBRARY}
- ${WAYLANDC_EGL_LIBRARY})
-endif()
+ if(KODI_DEPENDSBUILD)
+ add_library(${APP_NAME_LC}::waylandc-egl UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::waylandc-egl PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDC_EGL_LIBRARY}")
-# Promote to cache variables so all code can access it
-set(WAYLANDPP_PROTOCOLS_DIR "${PC_WAYLANDPP_PKGDATADIR}/protocols" CACHE INTERNAL "")
-
-# wayland-scanner++ is from native/host system in case of cross-compilation, so
-# it's ok if we don't find it with pkgconfig
-find_program(WAYLANDPP_SCANNER wayland-scanner++ HINTS ${PC_WAYLANDPP_SCANNER})
-
-include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Waylandpp
- REQUIRED_VARS WAYLANDPP_INCLUDE_DIR
- WAYLANDPP_CLIENT_LIBRARY
- WAYLANDPP_CURSOR_LIBRARY
- WAYLANDPP_EGL_LIBRARY
- WAYLANDPP_SCANNER
- VERSION_VAR WAYLANDPP_wayland-client++_VERSION)
-
-if(WAYLANDPP_FOUND)
- set(WAYLANDPP_INCLUDE_DIRS ${WAYLANDPP_INCLUDE_DIR})
- set(WAYLANDPP_LIBRARIES ${WAYLANDPP_CLIENT_LIBRARY}
- ${WAYLANDPP_CURSOR_LIBRARY}
- ${WAYLANDPP_EGL_LIBRARY}
- ${WAYLANDPP_STATIC_DEPS})
- set(WAYLANDPP_DEFINITIONS -DHAVE_WAYLAND=1)
-endif()
+ add_library(${APP_NAME_LC}::waylandc-cursor UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::waylandc-cursor PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDC_CURSOR_LIBRARY}")
+
+ add_library(${APP_NAME_LC}::waylandc-client UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::waylandc-client PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDC_CLIENT_LIBRARY}")
+ endif()
+
+ add_library(${APP_NAME_LC}::waylandpp-egl UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::waylandpp-egl PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDPP_EGL_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${WAYLANDPP_INCLUDE_DIR}")
+
+ add_library(${APP_NAME_LC}::waylandpp-cursor UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::waylandpp-cursor PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDPP_CURSOR_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${WAYLANDPP_INCLUDE_DIR}")
-mark_as_advanced(WAYLANDPP_INCLUDE_DIR
- WAYLANDPP_CLIENT_LIBRARY
- WAYLANDC_CLIENT_LIBRARY
- WAYLANDPP_CURSOR_LIBRARY
- WAYLANDC_CURSOR_LIBRARY
- WAYLANDPP_EGL_LIBRARY
- WAYLANDC_EGL_LIBRARY
- WAYLANDPP_SCANNER)
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
+ IMPORTED_LOCATION "${WAYLANDPP_CLIENT_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${WAYLANDPP_INCLUDE_DIR}"
+ INTERFACE_COMPILE_DEFINITIONS HAVE_WAYLAND
+ INTERFACE_LINK_LIBRARIES "${APP_NAME_LC}::waylandpp-cursor;${APP_NAME_LC}::waylandpp-egl;$<TARGET_NAME_IF_EXISTS:${APP_NAME_LC}::waylandc-egl>;$<TARGET_NAME_IF_EXISTS:${APP_NAME_LC}::waylandc-cursor>;$<TARGET_NAME_IF_EXISTS:${APP_NAME_LC}::waylandc-client>")
+
+ endif()
+endif()
diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake
index f402f7c491..37156923b9 100644
--- a/cmake/scripts/linux/ExtraTargets.cmake
+++ b/cmake/scripts/linux/ExtraTargets.cmake
@@ -24,8 +24,9 @@ if("wayland" IN_LIST CORE_PLATFORM_NAME_LC)
"${WAYLAND_PROTOCOLS_DIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml")
add_custom_command(OUTPUT "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp"
- COMMAND "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp"
- DEPENDS "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS}
+ COMMAND wayland::waylandppscanner
+ ARGS ${PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp"
+ DEPENDS wayland::waylandppscanner ${PROTOCOL_XMLS}
COMMENT "Generating wayland-protocols C++ wrappers")
if("webos" IN_LIST CORE_PLATFORM_NAME_LC)
diff --git a/cmake/scripts/webos/ExtraTargets.cmake b/cmake/scripts/webos/ExtraTargets.cmake
index 3380c6a3be..46c78edf62 100644
--- a/cmake/scripts/webos/ExtraTargets.cmake
+++ b/cmake/scripts/webos/ExtraTargets.cmake
@@ -3,8 +3,9 @@ set(WEBOS_PROTOCOL_XMLS "${WAYLANDPROTOCOLSWEBOS_PROTOCOLSDIR}/webos-shell.xml"
"${WAYLANDPROTOCOLSWEBOS_PROTOCOLSDIR}/webos-foreign.xml"
)
add_custom_command(OUTPUT "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp"
- COMMAND "${WAYLANDPP_SCANNER}" ${WEBOS_PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp"
- DEPENDS "${WAYLANDPP_SCANNER}" ${WEBOS_PROTOCOL_XMLS}
+ COMMAND wayland::waylandppscanner
+ ARGS ${WEBOS_PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp"
+ DEPENDS wayland::waylandppscanner ${WEBOS_PROTOCOL_XMLS}
COMMENT "Generating wayland-webos C++ wrappers")
add_custom_target(generate-wayland-webos-protocols DEPENDS wayland-webos-protocols.hpp)
# ToDo: turn this into a TARGET OBJECT. For now, a custum target doesnt play nice with