aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-12 15:44:47 +1000
committerfuzzard <fuzzard@kodi.tv>2024-06-22 13:17:14 +1000
commit0611695a346598dd1eddbef0520c94ad337d7235 (patch)
tree3ccd382f8dc1606f6d7a7bca640fadf1d19be405 /cmake
parent48abdb5a32b610bcaa148295951252d69b8e0280 (diff)
[cmake][modules] FindX cleanup and use core_target_link_libraries
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindX.cmake37
-rw-r--r--cmake/scripts/linux/ExtraTargets.cmake4
-rw-r--r--cmake/scripts/linux/Install.cmake4
3 files changed, 20 insertions, 25 deletions
diff --git a/cmake/modules/FindX.cmake b/cmake/modules/FindX.cmake
index 0dd69405f4..cec4700837 100644
--- a/cmake/modules/FindX.cmake
+++ b/cmake/modules/FindX.cmake
@@ -5,24 +5,21 @@
#
# This will define the following targets:
#
-# X::X - The X11 library
-# X::Xext - The X11 extension library
+# ${APP_NAME_LC}::X - The X11 library
+# ${APP_NAME_LC}::Xext - The X11 extension library
-if(NOT TARGET X::X)
+if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_X x11 xext QUIET)
endif()
find_path(X_INCLUDE_DIR NAMES X11/Xlib.h
- HINTS ${PC_X_x11_INCLUDEDIR}
- NO_CACHE)
+ HINTS ${PC_X_x11_INCLUDEDIR})
find_library(X_LIBRARY NAMES X11
- HINTS ${PC_X_x11_LIBDIR}
- NO_CACHE)
+ HINTS ${PC_X_x11_LIBDIR})
find_library(X_EXT_LIBRARY NAMES Xext
- HINTS ${PC_X_xext_LIBDIR}
- NO_CACHE)
+ HINTS ${PC_X_xext_LIBDIR})
set(X_VERSION ${PC_X_x11_VERSION})
@@ -32,17 +29,15 @@ if(NOT TARGET X::X)
VERSION_VAR X_VERSION)
if(X_FOUND)
- add_library(X::Xext UNKNOWN IMPORTED)
- set_target_properties(X::Xext PROPERTIES
- IMPORTED_LOCATION "${X_EXT_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}")
- add_library(X::X UNKNOWN IMPORTED)
- set_target_properties(X::X PROPERTIES
- IMPORTED_LOCATION "${X_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}"
- INTERFACE_COMPILE_DEFINITIONS HAVE_X11=1
- INTERFACE_LINK_LIBRARIES X::Xext)
-
- set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP X::X)
+ add_library(${APP_NAME_LC}::Xext UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::Xext PROPERTIES
+ IMPORTED_LOCATION "${X_EXT_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}")
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
+ IMPORTED_LOCATION "${X_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}"
+ INTERFACE_COMPILE_DEFINITIONS HAVE_X11
+ INTERFACE_LINK_LIBRARIES ${APP_NAME_LC}::Xext)
endif()
endif()
diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake
index d3b3f1807c..947c89301b 100644
--- a/cmake/scripts/linux/ExtraTargets.cmake
+++ b/cmake/scripts/linux/ExtraTargets.cmake
@@ -1,9 +1,9 @@
# xrandr
-if(TARGET X::X AND TARGET XRandR::XRandR)
+if(TARGET ${APP_NAME_LC}::X AND TARGET XRandR::XRandR)
find_package(X QUIET)
find_package(XRandR QUIET)
add_executable(${APP_NAME_LC}-xrandr ${CMAKE_SOURCE_DIR}/xbmc-xrandr.c)
- target_link_libraries(${APP_NAME_LC}-xrandr ${SYSTEM_LDFLAGS} X::X m XRandR::XRandR)
+ target_link_libraries(${APP_NAME_LC}-xrandr ${SYSTEM_LDFLAGS} ${APP_NAME_LC}::X m XRandR::XRandR)
endif()
# WiiRemote
diff --git a/cmake/scripts/linux/Install.cmake b/cmake/scripts/linux/Install.cmake
index efe7674b74..c23983c68b 100644
--- a/cmake/scripts/linux/Install.cmake
+++ b/cmake/scripts/linux/Install.cmake
@@ -1,4 +1,4 @@
-if(X_FOUND)
+if(TARGET ${APP_NAME_LC}::X)
set(USE_X11 1)
else()
set(USE_X11 0)
@@ -49,7 +49,7 @@ configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi.metainfo.xml.in
install(TARGETS ${APP_NAME_LC}
DESTINATION ${libdir}/${APP_NAME_LC}
COMPONENT kodi-bin)
-if(TARGET X::X AND TARGET XRandR::XRandR)
+if(TARGET ${APP_NAME_LC}::X AND TARGET XRandR::XRandR)
install(TARGETS ${APP_NAME_LC}-xrandr
DESTINATION ${libdir}/${APP_NAME_LC}
COMPONENT kodi-bin)