Merge pull request #25883 from CrystalP/fix-slowscan
[xbmc.git] / cmake / modules / FindShairplay.cmake
blobfd916ca6485245a369b2fc7f2eb7807db9a9033c
1 #.rst:
2 # FindShairplay
3 # -------------
4 # Finds the Shairplay library
6 # This will define the following target:
8 #   Shairplay::Shairplay - The Shairplay library
10 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
12   find_path(SHAIRPLAY_INCLUDE_DIR shairplay/raop.h)
13   find_library(SHAIRPLAY_LIBRARY NAMES shairplay libshairplay)
15   include(FindPackageHandleStandardArgs)
16   find_package_handle_standard_args(Shairplay
17                                     REQUIRED_VARS SHAIRPLAY_LIBRARY SHAIRPLAY_INCLUDE_DIR)
19   if(SHAIRPLAY_FOUND)
20     include(CheckCSourceCompiles)
21     set(CMAKE_REQUIRED_INCLUDES ${SHAIRPLAY_INCLUDE_DIR})
22     set(CMAKE_REQUIRED_LIBRARIES ${SHAIRPLAY_LIBRARIES})
23     check_c_source_compiles("#include <shairplay/raop.h>
25                              int main()
26                              {
27                                struct raop_callbacks_s foo;
28                                foo.cls;
29                                return 0;
30                              }
31                             " HAVE_SHAIRPLAY_CALLBACK_CLS)
32     unset(CMAKE_REQUIRED_INCLUDES)
33     unset(CMAKE_REQUIRED_LIBRARIES)
35     if(HAVE_SHAIRPLAY_CALLBACK_CLS)
36       add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
37       set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
38                                                                        IMPORTED_LOCATION "${SHAIRPLAY_LIBRARY}"
39                                                                        INTERFACE_INCLUDE_DIRECTORIES "${SHAIRPLAY_INCLUDE_DIR}"
40                                                                        INTERFACE_COMPILE_DEFINITIONS HAS_AIRTUNES)
41     endif()
42   endif()
43 endif()