aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-11 22:33:12 +1000
committerfuzzard <fuzzard@kodi.tv>2024-05-18 11:27:12 +1000
commit362c21e1b0c4e139e5857eb3cef17068b290abd9 (patch)
tree4ab1dc31a4776477be1ff7dcfbaf2b515ed02340
parente5a31c284bfc47098db5ca40b540fa9ceaaf297f (diff)
[cmake][modules] FindIconv cleanup and use core_target_link_libraries
-rw-r--r--cmake/modules/FindIconv.cmake24
1 files changed, 13 insertions, 11 deletions
diff --git a/cmake/modules/FindIconv.cmake b/cmake/modules/FindIconv.cmake
index 1e9b54fd5a..3acd96ea63 100644
--- a/cmake/modules/FindIconv.cmake
+++ b/cmake/modules/FindIconv.cmake
@@ -5,16 +5,14 @@
#
# This will define the following target:
#
-# ICONV::ICONV - The ICONV library
+# ${APP_NAME_LC}::ICONV - The ICONV library
-if(NOT TARGET ICONV::ICONV)
+if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
find_path(ICONV_INCLUDE_DIR NAMES iconv.h
- HINTS ${DEPENDS_PATH}/include
- NO_CACHE)
+ HINTS ${DEPENDS_PATH}/include)
find_library(ICONV_LIBRARY NAMES iconv libiconv c
- HINTS ${DEPENDS_PATH}/lib
- NO_CACHE)
+ HINTS ${DEPENDS_PATH}/lib)
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
check_function_exists(iconv HAVE_ICONV_FUNCTION)
@@ -23,6 +21,7 @@ if(NOT TARGET ICONV::ICONV)
set(HAVE_ICONV_FUNCTION ${HAVE_LIBICONV_FUNCTION2})
unset(HAVE_LIBICONV_FUNCTION2)
endif()
+ unset(CMAKE_REQUIRED_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Iconv
@@ -32,11 +31,14 @@ if(NOT TARGET ICONV::ICONV)
# Libc causes grief for linux, so search if found library is libc.* and only
# create imported TARGET if its not
if(NOT ${ICONV_LIBRARY} MATCHES ".*libc\..*")
- add_library(ICONV::ICONV UNKNOWN IMPORTED)
- set_target_properties(ICONV::ICONV PROPERTIES
- IMPORTED_LOCATION "${ICONV_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIR}")
- set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP ICONV::ICONV)
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
+ IMPORTED_LOCATION "${ICONV_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIR}")
+ endif()
+ else()
+ if(Iconv_FIND_REQUIRED)
+ message(FATAL_ERROR "Iconv libraries were not found.")
endif()
endif()
endif()