summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindSparkle.cmake
blob: 1969c02d15d52f231f92e3caf5d7ed6b5ebf13ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# Find the Sparkle framework
#
# This defines the following:
#  SPARKLE_FOUND        - True if we found Sparkle
#  SPARKLE_INCLUDE_DIRS - Path to Sparkle.h, empty if not found
#  SPARKLE_LIBRARIES    - Path to Sparkle.framework, empty if not found
#  SPARKLE_VERSION      - Sparkle framework bundle version

include(FindPackageHandleStandardArgs)

file(GLOB USR_LOCAL_HINT "/usr/local/Sparkle-[2-9]*/")
file(GLOB HOMEBREW_HINT "/usr/local/Caskroom/sparkle/[2-9]*/")

find_path(SPARKLE_INCLUDE_DIR Sparkle.h
  HINTS ${USR_LOCAL_HINT} ${HOMEBREW_HINT}
)
find_library(SPARKLE_LIBRARY NAMES Sparkle
  HINTS ${USR_LOCAL_HINT} ${HOMEBREW_HINT}
)

# Sparkle doesn't appear to provide a version macro, and its Info.plist versions
# are all over the place. Check for SPUStandardUpdaterController.h, which was
# added in version 2.
set(SPARKLE_VERSION 1)

find_file(_spustandardupdatercontroller_h SPUStandardUpdaterController.h
  ${SPARKLE_LIBRARY}/Headers
  NO_DEFAULT_PATH
)

if(_spustandardupdatercontroller_h)
  set(SPARKLE_VERSION 2)
endif()

unset(_spustandardupdatercontroller_h CACHE)

find_package_handle_standard_args(Sparkle
  REQUIRED_VARS SPARKLE_INCLUDE_DIR SPARKLE_LIBRARY
  VERSION_VAR SPARKLE_VERSION
)

if(SPARKLE_FOUND)
  set(SPARKLE_LIBRARIES ${SPARKLE_LIBRARY} )
  set(SPARKLE_INCLUDE_DIRS ${SPARKLE_INCLUDE_DIR} )
else(SPARKLE_FOUND)
  set(SPARKLE_LIBRARIES )
  set(SPARKLE_INCLUDE_DIRS )
endif(SPARKLE_FOUND)

mark_as_advanced(SPARKLE_INCLUDE_DIR SPARKLE_LIBRARY)