diff options
Diffstat (limited to 'cmake/modules/FindShairplay.cmake')
| -rw-r--r-- | cmake/modules/FindShairplay.cmake | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/cmake/modules/FindShairplay.cmake b/cmake/modules/FindShairplay.cmake new file mode 100644 index 0000000..87d3107 --- /dev/null +++ b/cmake/modules/FindShairplay.cmake | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | #.rst: | ||
| 2 | # FindShairplay | ||
| 3 | # ------------- | ||
| 4 | # Finds the Shairplay library | ||
| 5 | # | ||
| 6 | # This will will define the following variables:: | ||
| 7 | # | ||
| 8 | # SHAIRPLAY_FOUND - system has Shairplay | ||
| 9 | # SHAIRPLAY_INCLUDE_DIRS - the Shairplay include directory | ||
| 10 | # SHAIRPLAY_LIBRARIES - the Shairplay libraries | ||
| 11 | # SHAIRPLAY_DEFINITIONS - the Shairplay compile definitions | ||
| 12 | # | ||
| 13 | # and the following imported targets:: | ||
| 14 | # | ||
| 15 | # Shairplay::Shairplay - The Shairplay library | ||
| 16 | |||
| 17 | find_path(SHAIRPLAY_INCLUDE_DIR shairplay/raop.h) | ||
| 18 | |||
| 19 | include(FindPackageHandleStandardArgs) | ||
| 20 | if(NOT WIN32) | ||
| 21 | find_library(SHAIRPLAY_LIBRARY NAMES shairplay) | ||
| 22 | |||
| 23 | if(SHAIRPLAY_INCLUDE_DIR AND SHAIRPLAY_LIBRARY) | ||
| 24 | include(CheckCSourceCompiles) | ||
| 25 | set(CMAKE_REQUIRED_INCLUDES ${SHAIRPLAY_INCLUDE_DIRS}) | ||
| 26 | set(CMAKE_REQUIRED_LIBRARIES ${SHAIRPLAY_LIBRARIES}) | ||
| 27 | check_c_source_compiles("#include <shairplay/raop.h> | ||
| 28 | |||
| 29 | int main() | ||
| 30 | { | ||
| 31 | struct raop_callbacks_s foo; | ||
| 32 | foo.cls; | ||
| 33 | return 0; | ||
| 34 | } | ||
| 35 | " HAVE_SHAIRPLAY_CALLBACK_CLS) | ||
| 36 | endif() | ||
| 37 | |||
| 38 | find_package_handle_standard_args(Shairplay | ||
| 39 | REQUIRED_VARS SHAIRPLAY_LIBRARY SHAIRPLAY_INCLUDE_DIR HAVE_SHAIRPLAY_CALLBACK_CLS) | ||
| 40 | else() | ||
| 41 | # Dynamically loaded DLL | ||
| 42 | find_package_handle_standard_args(Shairplay | ||
| 43 | REQUIRED_VARS SHAIRPLAY_INCLUDE_DIR) | ||
| 44 | endif() | ||
| 45 | |||
| 46 | if(SHAIRPLAY_FOUND) | ||
| 47 | set(SHAIRPLAY_LIBRARIES ${SHAIRPLAY_LIBRARY}) | ||
| 48 | set(SHAIRPLAY_INCLUDE_DIRS ${SHAIRPLAY_INCLUDE_DIR}) | ||
| 49 | set(SHAIRPLAY_DEFINITIONS -DHAVE_LIBSHAIRPLAY=1) | ||
| 50 | |||
| 51 | if(NOT TARGET Shairplay::Shairplay) | ||
| 52 | add_library(Shairplay::Shairplay UNKNOWN IMPORTED) | ||
| 53 | if(SHAIRPLAY_LIBRARY) | ||
| 54 | set_target_properties(Shairplay::Shairplay PROPERTIES | ||
| 55 | IMPORTED_LOCATION "${SHAIRPLAY_LIBRARY}") | ||
| 56 | endif() | ||
| 57 | set_target_properties(Shairplay::Shairplay PROPERTIES | ||
| 58 | INTERFACE_INCLUDE_DIRECTORIES "${SHAIRPLAY_INCLUDE_DIR}" | ||
| 59 | INTERFACE_COMPILE_DEFINITIONS HAVE_LIBSHAIRPLAY=1) | ||
| 60 | endif() | ||
| 61 | endif() | ||
| 62 | |||
| 63 | mark_as_advanced(SHAIRPLAY_INCLUDE_DIR SHAIRPLAY_LIBRARY) | ||
