forked from patacrep/patagui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
macos-config.cmake
107 lines (94 loc) · 4.84 KB
/
macos-config.cmake
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
set( PROGNAME Songbook-Client )
set( MACOSX_BUNDLE_ICON_FILE livre.icns )
set( CPACK_BUNDLE_NAME Sonbook Client With Space)
#versions
set( MACOSX_BUNDLE_VERSION 0.5.1 )
set( MACOSX_BUNDLE_SHORT_VERSION_STRING 0.5.1 )
set( MACOSX_BUNDLE_LONG_VERSION_STRING "Version 0.5.1" )
#name of the preference file, usefull if we need to keep the same preference file
#upgrade after upgrade without loosing preferences
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.patacrep.songbook-client)
# need to copy the icns (icon) file in the buils dir
# also copy the icons for the .sg and .sb files
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/sb_icon.icns
${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/sg_icon.icns
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
#set( CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64"
#set( CMAKE_OSX_ARCHITECTURES "ppc;i386"
# CACHE STRING "Build architectures for OSX" FORCE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/livre.icns
${CMAKE_CURRENT_BINARY_DIR}/livre.icns COPYONLY)
IF(EXISTS "/Library/Frameworks/Sparkle.framework")
message(STATUS "Looking for Sparkle Framwork - found")
#need to check a few things for autoupdate
# this will set the UPPERCASE Variable to the right path
# for soft/Hard linknig of the framwork.
# OPTION( VARIABLE "Description" Initial state)
OPTION( USE_SPARKLE "Enable Sparkle Framwork on mac" ON )
find_library(SPARKLE_FRAMEWORK Sparkle)
find_library(APPKIT_FRAMEWORK AppKit)
# we need to copy the public key to check the updates
set(PUBLIC_KEY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/dsa_pub_songbookclient.pem")
IF(EXISTS ${PUBLIC_KEY_PATH})
message(STATUS "Looking for Public Key - found")
SET_SOURCE_FILES_PROPERTIES(
${PUBLIC_KEY_PATH}
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set(PUBLIC_KEY ${PUBLIC_KEY_PATH})
ELSE(EXISTS ${PUBLIC_KEY_PATH})
message(WARNING "Looking for Public Key - not found")
message(WARNING "${PUBLIC_KEY_PATH} not found Sparkle Framwork will NOT work and may event prevent application from launching. Please consider Disabling Sparkle Framwork, creating a pair of key for testing purposes")
ENDIF(EXISTS ${PUBLIC_KEY_PATH})
LIST(
APPEND SONGBOOK_CLIENT_QT_HEADER
macos_specific/sparkle/src/AutoUpdater.h
macos_specific/sparkle/src/CocoaInitializer.h
macos_specific/sparkle/src/SparkleAutoUpdater.h
)
LIST(
APPEND SONGBOOK_CLIENT_SOURCES
macos_specific/sparkle/src/AutoUpdater.cpp
macos_specific/sparkle/src/CocoaInitializer.mm
macos_specific/sparkle/src/SparkleAutoUpdater.mm
)
# Hack Custom command to copy sparkle framwork
set(CCS1 mkdir ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Frameworks)
set(CCS2 cp -R ${SPARKLE_FRAMEWORK} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Frameworks/Sparkle.framework)
set(CCS3 echo "Note : Having the message : ERROR: no file at '/usr/lib/@loader_path@loader_path' is normal")
set(CCS4 echo "It is due to Qt encountering references to Sparkle Framwork.")
ELSE(EXISTS "/Library/Frameworks/Sparkle.framework")
message(STATUS "Looking for Sparkle Framwork - not found")
set(CCS1 echo "The application has been compiled without support for auto-updating, you will have to check for it manually")
ENDIF(EXISTS "/Library/Frameworks/Sparkle.framework")
add_executable( ${PROGNAME} MACOSX_BUNDLE ${SONGBOOK_CLIENT_SOURCES}
${SONGBOOK_CLIENT_MOCS} ${SONGBOOK_CLIENT_RESSOURCES} ${COMPILED_TRANSLATIONS}
${qtpropertyeditor_SRCS} ${qtpropertyeditor_MOC} ${qtpropertyeditor_RESOURCES}
${PUBLIC_KEY}
${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/sb_icon.icns
${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/sg_icon.icns
)
add_custom_command( TARGET ${PROGNAME} POST_BUILD
COMMAND mkdir ARGS ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources/lang
COMMAND cp ARGS ${MACOSX_BUNDLE_ICON_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources
COMMAND cp ARGS ../lang/*.qm ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources/lang
# this for command are set if sparkle is activated and are ment to copy the framwork inside the bundle
# and warn the user about some error message that might be printed afterward
COMMAND ${CCS1}
COMMAND ${CCS2}
COMMAND ${CCS3}
COMMAND ${CCS4}
COMMAND macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app
)
if(USE_SPARKLE)
# we need to add SPARKLE and APPKIT as '-framework' at link time
target_link_libraries(${PROGNAME} ${APPKIT_FRAMEWORK})
target_link_libraries(${PROGNAME} ${SPARKLE_FRAMEWORK})
endif(USE_SPARKLE)
# genération d'une plist custom pour sparkle from a plist.in where @VARAIBLE@ are replaces by the content of VARAIBLE
# we need this for having the default url to check updates
set_target_properties( ${PROGNAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macos_specific/Info.plist.in )