CMakeLists.txt 13.7 KB
Newer Older
Alexandre Lision's avatar
Alexandre Lision committed
1 2 3 4 5 6
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

IF(POLICY CMP0022)
  CMAKE_POLICY(SET CMP0022 NEW)
ENDIF(POLICY CMP0022)

7
SET(PROJ_NAME Ring)
8 9 10 11 12 13 14 15

# To build nighlies we need to update RING_VERSION with an optional command line arg
IF("${RING_VERSION}" STREQUAL "")
   SET(RING_VERSION "0.4.0")
ENDIF("${RING_VERSION}" STREQUAL "")

MESSAGE("Building Ring version - " ${RING_VERSION})

16
SET(RING_VERSION_NAME "Samuel de Champlain (${RING_VERSION})")
17

18
MESSAGE(${RING_VERSION_NAME})
19
SET(PROJ_COPYRIGHT " © 2015 Savoir-faire Linux \n GPLv3 https://www.gnu.org/copyleft/gpl.html")
20

21
ADD_DEFINITIONS("-std=c++11 -fobjc-arc")
Alexandre Lision's avatar
Alexandre Lision committed
22

Alexandre Lision's avatar
Alexandre Lision committed
23
PROJECT(${PROJ_NAME})
Alexandre Lision's avatar
Alexandre Lision committed
24 25

FIND_PACKAGE(Qt5Core REQUIRED)
26
FIND_PACKAGE(Qt5MacExtras REQUIRED)
Alexandre Lision's avatar
Alexandre Lision committed
27 28 29
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(LibRingClient REQUIRED)

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
IF(NOT (${ENABLE_SPARKLE} MATCHES false))
   MESSAGE("Sparkle auto-update enabled")

   # find_library searches in /Library/Frameworks by default
   # We add an hint to our custom location

   FIND_LIBRARY(SPARKLE_FRAMEWORK
                NAMES Sparkle
                HINTS ${CMAKE_CURRENT_SOURCE_DIR}/sparkle)
   IF(EXISTS ${SPARKLE_FRAMEWORK})
      SET(ENABLE_SPARKLE 1 CACHE BOOLEAN "Enable Sparkle")
      ADD_DEFINITIONS(-DENABLE_SPARKLE=1)
      MESSAGE("Sparkle is here:" ${SPARKLE_FRAMEWORK})
      FIND_PATH(SPARKLE_INCLUDE_DIR Sparkle.h HINTS ${SPARKLE_FRAMEWORK}/Headers)
      MESSAGE("INCLUDE " ${SPARKLE_INCLUDE_DIR})
      # we need to copy the public key to check the updates
      SET(PUBLIC_KEY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/sparkle/dsa_pub.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 Framework will NOT work and may even prevent application from launching. Please consider disabling Sparkle Framework, creating a keypair for testing purposes")
      ENDIF(EXISTS ${PUBLIC_KEY_PATH})
   ELSE()
      MESSAGE(FATAL_ERROR "Sparkle framework not found, build it (see README) or disable Sparkle (-DENABLE_SPARKLE=false)")
   ENDIF(EXISTS ${SPARKLE_FRAMEWORK})
ENDIF(NOT (${ENABLE_SPARKLE} MATCHES false))

Alexandre Lision's avatar
Alexandre Lision committed
60
INCLUDE_DIRECTORIES(SYSTEM ${Qt5Core_INCLUDE_DIRS})
61
INCLUDE_DIRECTORIES(SYSTEM ${Qt5MacExtras_INCLUDE_DIRS})
Alexandre Lision's avatar
Alexandre Lision committed
62 63 64 65
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${LIB_RING_CLIENT_INCLUDE_DIR})

66
MESSAGE("LRC is here:" ${LIB_RING_CLIENT_INCLUDE_DIR})
Alexandre Lision's avatar
Alexandre Lision committed
67 68 69
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")

#Files to compile
70
SET(ringclient_CONTROLLERS
71
   src/QNSTreeController.mm
72 73 74 75 76 77 78 79 80 81 82 83
   src/QNSTreeController.h
   src/CurrentCallVC.mm
   src/CurrentCallVC.h
   src/GeneralPrefsVC.mm
   src/RingWizardWC.mm
   src/RingWizardWC.h
   src/RingWindowController.mm
   src/RingWindowController.h
   src/ConversationsVC.mm
   src/ConversationsVC.h
   src/PreferencesVC.mm
   src/PreferencesVC.h
84
   src/AccGeneralVC.mm
85
   src/AccGeneralVC.h
86
   src/AccVideoVC.mm
87 88 89
   src/AccVideoVC.h
   src/AccAudioVC.mm
   src/AccAudioVC.h
90
   src/AccRingVC.mm
91
   src/AccRingVC.h
92
   src/AccAdvancedVC.mm
93
   src/AccAdvancedVC.h
94
   src/AccSecurityVC.mm
95
   src/AccSecurityVC.h
96 97
   src/CertificateWC.mm
   src/CertificateWC.h
98
   src/AudioPrefsVC.mm
99 100 101
   src/AudioPrefsVC.h
   src/AccountsVC.mm
   src/AccountsVC.h
102
   src/VideoPrefsVC.mm
103 104 105 106
   src/VideoPrefsVC.h
   src/GeneralPrefsVC.h
   src/HistoryVC.mm
   src/HistoryVC.h
107
   src/PersonsVC.mm
Alexandre Lision's avatar
Alexandre Lision committed
108
   src/PersonsVC.h
109 110
   src/BitrateVC.mm
   src/BitrateVC.h
Alexandre Lision's avatar
Alexandre Lision committed
111
   src/ChatVC.mm
112 113 114
   src/ChatVC.h
   src/PersonLinkerVC.mm
   src/PersonLinkerVC.h)
Alexandre Lision's avatar
Alexandre Lision committed
115

116 117
SET(ringclient_BACKENDS
   src/backends/AddressBookBackend.mm
Alexandre Lision's avatar
Alexandre Lision committed
118
   src/backends/AddressBookBackend.h)
119

120
SET(ringclient_VIEWS
Alexandre Lision's avatar
Alexandre Lision committed
121
   src/views/CallView.mm
122
   src/views/CallView.h
123 124
   src/views/ITProgressIndicator.mm
   src/views/ITProgressIndicator.h
125
   src/views/PersonCell.mm
126 127
   src/views/PersonCell.h
   src/views/RingOutlineView.mm
128 129 130
   src/views/RingOutlineView.h
   src/views/RingIDField.mm
   src/views/RingIDField.h)
131 132 133 134 135 136 137

SET(ringclient_OTHERS
   src/main.mm
   src/AppDelegate.mm
   src/AppDelegate.h
   src/delegates/ImageManipulationDelegate.mm
   src/delegates/ImageManipulationDelegate.h)
Alexandre Lision's avatar
Alexandre Lision committed
138

Alexandre Lision's avatar
Alexandre Lision committed
139

140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
SET(ringclient_XIBS
   MainMenu
   RingWindow
   CurrentCall
   GeneralPrefs
   Accounts
   AccGeneral
   AccAudio
   AccVideo
   AccRing
   AccAdvanced
   AccSecurity
   AudioPrefs
   VideoPrefs
   PreferencesScreen
155
   RingWizard
156 157
   CertificateWindow
   PersonLinker)
Alexandre Lision's avatar
Alexandre Lision committed
158 159

# Icons
160
# This part tells CMake where to find and install the file itself
Alexandre Lision's avatar
Alexandre Lision committed
161 162 163 164
SET(myApp_ICON ${CMAKE_CURRENT_SOURCE_DIR}/data/appicon.icns)
SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES
       MACOSX_PACKAGE_LOCATION "Resources")

165 166 167
SET(ring_ICONS
${CMAKE_CURRENT_SOURCE_DIR}/data/symbol_name.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_accept.png
Alexandre Lision's avatar
Alexandre Lision committed
168 169
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_call.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_cancel.png
170 171 172 173 174 175
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_hangup.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_hold.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_holdoff.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_mute_video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_mute_audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_chat.png
Alexandre Lision's avatar
Alexandre Lision committed
176
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_search.png
177
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_quality.png
Alexandre Lision's avatar
Alexandre Lision committed
178 179
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ancrage.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png
180
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_person_add.png
Alexandre Lision's avatar
Alexandre Lision committed
181 182
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/general.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/video.png
Alexandre Lision's avatar
Alexandre Lision committed
183
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png)
184

Alexandre Lision's avatar
Alexandre Lision committed
185
SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES
Alexandre Lision's avatar
Alexandre Lision committed
186
       MACOSX_PACKAGE_LOCATION Resources)
187 188
SET_SOURCE_FILES_PROPERTIES(Credits.rtf PROPERTIES
       MACOSX_PACKAGE_LOCATION Resources)
Alexandre Lision's avatar
Alexandre Lision committed
189

Alexandre Lision's avatar
Alexandre Lision committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203

# Check which translations are found for LRC
SET(LRC_TRANSLATIONS_PATH ${CMAKE_INSTALL_PREFIX}/share/libringclient/translations)
FILE(GLOB QM_LIST ${LRC_TRANSLATIONS_PATH}/*.qm)

FOREACH(QM_FILE ${QM_LIST})
    # Extract country code from filename
    GET_FILENAME_COMPONENT(FILENAME ${QM_FILE} NAME_WE)
    STRING(REGEX REPLACE "^lrc_" "" LANG ${FILENAME})

    SET_SOURCE_FILES_PROPERTIES(${LRC_TRANSLATIONS_PATH}/lrc_${LANG}.qm
                PROPERTIES MACOSX_PACKAGE_LOCATION Resources/QtTranslations)
    SET(LOCALIZED_${LANG} ${LOCALIZED_${LANG}}
                "${LRC_TRANSLATIONS_PATH}/lrc_${LANG}.qm")
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
ENDFOREACH()

# Check which translations are found for the client
FILE(GLOB LPROJ_LIST ui/*.lproj)

FOREACH(LPROJ ${LPROJ_LIST})
    # Extract country code from <lang>.lproj folder name
    GET_FILENAME_COMPONENT(LANG ${LPROJ} NAME_WE)
    IF(EXISTS "${LPROJ}/Localizable.strings")
        MESSAGE("Localizable:" ${LANG})
        SET_SOURCE_FILES_PROPERTIES(${LPROJ}/Localizable.strings
                        PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${LANG}.lproj/)

        SET(LOCALIZED_${LANG} ${LOCALIZED_${LANG}}
                        ${LPROJ}/Localizable.strings)
    ENDIF()
    FOREACH(xib ${ringclient_XIBS})
       IF(EXISTS "${LPROJ}/${xib}.strings")
            SET_SOURCE_FILES_PROPERTIES(${LPROJ}/${xib}.strings
                        PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${LANG}.lproj/)

        SET(LOCALIZED_${LANG} ${LOCALIZED_${LANG}}
                        ${LPROJ}/${xib}.strings)
        ENDIF()
    ENDFOREACH()
Alexandre Lision's avatar
Alexandre Lision committed
229 230 231 232 233 234 235 236

    # Regroup those files under a .lproj folder
    SOURCE_GROUP("Resources\\${LANG}.lproj" FILES
                                    ${LOCALIZED_${LANG}})
    # Add them to the list of files to package
    SET(LOCALIZABLE_FILES ${LOCALIZABLE_FILES} ${LOCALIZED_${LANG}})
ENDFOREACH()

237 238
# append '.xib' extension before linking xib files in executable
FOREACH(xib ${ringclient_XIBS})
239
  SET(ringclient_XIBS_FOR_EXECUTABLE ${ringclient_XIBS_FOR_EXECUTABLE} ui/Base.lproj/${xib}.xib)
240 241
ENDFOREACH()

Alexandre Lision's avatar
Alexandre Lision committed
242
SET(TO_ADD
243 244 245 246
   ${ringclient_CONTROLLERS}
   ${ringclient_BACKENDS}
   ${ringclient_VIEWS}
   ${ringclient_OTHERS}
247
   ${ringclient_XIBS_FOR_EXECUTABLE}
Alexandre Lision's avatar
Alexandre Lision committed
248
   ${LOCALIZABLE_FILES}
Alexandre Lision's avatar
Alexandre Lision committed
249
   ${myApp_ICON}
250
   Credits.rtf
Alexandre Lision's avatar
Alexandre Lision committed
251 252
   ${ring_ICONS})

253 254 255 256 257 258
IF(ENABLE_SPARKLE)
   SET( TO_ADD ${TO_ADD} ${PUBLIC_KEY} ${SPARKLE_FRAMEWORK})
ENDIF(ENABLE_SPARKLE)

ADD_EXECUTABLE(${PROJ_NAME} MACOSX_BUNDLE ${TO_ADD})

259 260 261 262 263
# Follow Xcode hierarchy principles
SOURCE_GROUP("Controllers" FILES ${ringclient_CONTROLLERS})
SOURCE_GROUP("Backends" FILES ${ringclient_BACKENDS})
SOURCE_GROUP("CustomViews" FILES ${ringclient_VIEWS})
SOURCE_GROUP("Classes" FILES ${ringclient_OTHERS})
Alexandre Lision's avatar
Alexandre Lision committed
264 265
SOURCE_GROUP("Resources\\Interface Builder" FILES
                                    ${ringclient_XIBS_FOR_EXECUTABLE})
266

267 268 269
IF(ENABLE_SPARKLE)
    SOURCE_GROUP("Frameworks" FILES ${SPARKLE_FRAMEWORK})
ENDIF(ENABLE_SPARKLE)
270

271
TARGET_LINK_LIBRARIES( ${PROJ_NAME}
Alexandre Lision's avatar
Alexandre Lision committed
272
   ${LIB_RING_CLIENT_LIBRARY}
Alexandre Lision's avatar
Alexandre Lision committed
273
   ${Qt5Core_LIBRARIES}
274
   ${Qt5MacExtras_LIBRARIES}
Alexandre Lision's avatar
Alexandre Lision committed
275 276 277
   ${Qt5Widgets_LIBRARIES}
)

278 279 280 281
IF(ENABLE_SPARKLE)
   TARGET_LINK_LIBRARIES(${PROJ_NAME} ${SPARKLE_FRAMEWORK})
ENDIF(ENABLE_SPARKLE)

282 283 284 285 286 287 288
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Quartz")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AVFoundation")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AddressBook")

# These variables are specific to our plist and are NOT standard CMake variables
289 290
SET(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu")
SET(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
Alexandre Lision's avatar
Alexandre Lision committed
291

292 293 294
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES
        MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in
        MACOSX_BUNDLE_GUI_IDENTIFIER "cx.ring"
295 296 297
        MACOSX_BUNDLE_SHORT_VERSION_STRING "${RING_VERSION_NAME}"
        MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJ_NAME} ${RING_VERSION_NAME} Nightly"
        MACOSX_BUNDLE_BUNDLE_VERSION ${RING_VERSION}
298
        MACOSX_BUNDLE_COPYRIGHT "${PROJ_COPYRIGHT}"
299 300 301 302
        MACOSX_BUNDLE_INFO_STRING "Nightly build of ${PROJ_NAME} ${RING_VERSION} for testing and development"
        MACOSX_BUNDLE_BUNDLE_NAME ${PROJ_NAME}
        MACOSX_BUNDLE_ICON_FILE "appicon.icns"
    )
303 304 305 306 307 308 309 310 311 312 313 314 315

# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
FIND_PROGRAM(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
IF(${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
  MESSAGE(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with
                    the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()

# Compile the .xib files using the 'ibtool' program with the destination being the app package
FOREACH(xib ${ringclient_XIBS})
  ADD_CUSTOM_COMMAND(TARGET ${PROJ_NAME} POST_BUILD
                      COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
316 317 318
                              --compile ${CMAKE_CURRENT_BINARY_DIR}/\${CONFIGURATION}/${PROJ_NAME}.app/Contents/Resources/Base.lproj/${xib}.nib
                             ${CMAKE_CURRENT_SOURCE_DIR}/ui/Base.lproj/${xib}.xib
                      COMMENT "Compiling ${CMAKE_CURRENT_SOURCE_DIR}/ui/Base.lproj/${xib}.xib")
319 320

ENDFOREACH()
321

322
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX})
323 324 325 326 327

SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJ_NAME}.app")

INSTALL(TARGETS ${PROJ_NAME} BUNDLE DESTINATION . COMPONENT Runtime)

328
SET(QT_PLUGINS_DESTDIR ${PROJ_NAME}.app/Contents/Plugins)
329 330
#--------------------------------------------------------------------------------
# Install needed Qt plugins by copying directories from the qt installation
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353


#MESSAGE("GUI====")
#foreach(plugin ${Qt5Gui_PLUGINS})
#  message("Plugin ${plugin} is at location ${_loc}")
#endforeach()

LIST(APPEND QT_PLUGINS_IMAGEFORMAT  Qt5::QTgaPlugin
                                    Qt5::QGifPlugin
                                    Qt5::QICNSPlugin
                                    Qt5::QICOPlugin
                                    Qt5::QJpegPlugin
                                    Qt5::QJp2Plugin
                                    Qt5::QMngPlugin
                                    Qt5::QTiffPlugin
                                    Qt5::QDDSPlugin)

# we need two plugin directories platform and imageformats
GET_TARGET_PROPERTY(_loc Qt5::QCocoaIntegrationPlugin LOCATION)
INSTALL(FILES ${_loc} DESTINATION ${QT_PLUGINS_DESTDIR}/platforms COMPONENT Runtime)
LIST(APPEND QT_PLUGINS Qt5::QCocoaIntegrationPlugin)

FOREACH(plugin ${QT_PLUGINS_IMAGEFORMAT})
354
  GET_TARGET_PROPERTY(_loc ${plugin} LOCATION)
355 356
  INSTALL(FILES ${_loc} DESTINATION ${QT_PLUGINS_DESTDIR}/imageformats COMPONENT Runtime)
  LIST(APPEND QT_PLUGINS ${plugin})
357 358 359
ENDFOREACH()

# directories to look for dependencies
360
SET(DIRS ${CMAKE_INSTALL_PREFIX}/lib ${QT_LIB_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/sparkle)
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382

INSTALL(CODE "
    file(GLOB_RECURSE QTPLUGINS
      \"\${CMAKE_INSTALL_PREFIX}/${QT_PLUGINS_DESTDIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    include(BundleUtilities)
    SET(BU_CHMOD_BUNDLE_ITEMS TRUE)
    fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
    " COMPONENT Runtime)

#================================
# Packaging
#================================
SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJ_NAME})
SET( CPACK_PACKAGE_NAME ${PROJ_NAME} )
SET( CPACK_PACKAGE_CONTACT "Alexandre Lision")
SET( CPACK_PACKAGE_VENDOR "Savoir-faire Linux")
SET( CPACK_PACKAGE_VERSION_MAJOR ${PROG_MAJOR_VERSION})
SET( CPACK_PACKAGE_VERSION_MINOR ${PROG_MINOR_VERSION})
SET( CPACK_PACKAGE_VERSION_PATCH ${PROG_PATCH_VERSION})
SET(CPACK_BINARY_DRAGNDROP ON)
SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
INCLUDE(CPack)