[cosmetic] separate c-lang format commit
[xbmc.git] / cmake / modules / FindIconv.cmake
blob9f8ff74a42ac5610d8fb5400d9903117fe9203a5
1 #.rst:
2 # FindIconv
3 # --------
4 # Finds the ICONV library
6 # This will define the following targets:
8 #   ${APP_NAME_LC}::Iconv - An alias of the Iconv::Iconv target
9 #   Iconv::Iconv - The ICONV library
11 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
13   # We do this dance to utilise cmake system FindIconv. Saves us dealing with it
14   set(_temp_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
15   unset(CMAKE_MODULE_PATH)
17   if(Iconv_FIND_REQUIRED)
18     set(ICONV_REQUIRED "REQUIRED")
19   endif()
21   find_package(Iconv ${ICONV_REQUIRED})
23   # Back to our normal module paths
24   set(CMAKE_MODULE_PATH ${_temp_CMAKE_MODULE_PATH})
26   if(ICONV_FOUND)
27     # We still want to Alias its "standard" target to our APP_NAME_LC based target
28     # for integration into our core dep packaging
29     add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS Iconv::Iconv)
30   else()
31     if(Iconv_FIND_REQUIRED)
32       message(FATAL_ERROR "Iconv libraries were not found.")
33     endif()
34   endif()
35 endif()