CMakeLists.txt 9.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)

# First, check is the compiler is new enough, most version of Clang are fine
# until problems arise, checking for GCC is enough
IF (CMAKE_COMPILER_IS_GNUCC)
   EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
   IF (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
      MESSAGE(STATUS "Found GCC version >= 4.8: " ${GCC_VERSION})
   ELSE()
      MESSAGE(FATAL_ERROR "Your version of GCC is too old, please install GCC 4.8 or later")
   ENDIF()
ENDIF()

ADD_DEFINITIONS("-std=c++1y")

16
# set project name and version
17
PROJECT(ring-client-gnome)
18
SET(PROJECT_VERSION_MAJOR 0)
Guillaume Roguez's avatar
Guillaume Roguez committed
19
SET(PROJECT_VERSION_MINOR 4)
Guillaume Roguez's avatar
Guillaume Roguez committed
20
SET(PROJECT_VERSION_PATCH 0)
21 22 23 24

# add the binary tree to the search path for include files
# so that we will find config.h
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
25

26 27
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

28
# include custom cmake modules
29
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/GResources.cmake)
30
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/GSettings.cmake)
31 32 33 34 35 36 37 38 39 40 41 42

# make sure we're using Qt5
SET(ENABLE_QT5 true)

# for now, set debug as default
SET(CMAKE_BUILD_TYPE Debug)

# find packages
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0>=3.10)
FIND_PACKAGE(LibRingClient REQUIRED)
FIND_PACKAGE(Qt5Core REQUIRED)
43 44
PKG_CHECK_MODULES(CLUTTER REQUIRED clutter-1.0)
PKG_CHECK_MODULES(CLUTTERGTK REQUIRED clutter-gtk-1.0)
45
PKG_CHECK_MODULES(ICONSYMBLIC REQUIRED gnome-icon-theme-symbolic)
46
PKG_CHECK_MODULES(EBOOK REQUIRED libebook-1.2>=3.10)
47
PKG_CHECK_MODULES(LIBNOTIFY libnotify>=0.7.6) #optional
48 49 50 51

# include libs
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${LIB_RING_CLIENT_INCLUDE_DIR})
Stepan Salenikovich's avatar
Stepan Salenikovich committed
52
INCLUDE_DIRECTORIES(SYSTEM ${Qt5Core_INCLUDE_DIRS} )
53 54
INCLUDE_DIRECTORIES(${CLUTTER_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CLUTTERGTK_INCLUDE_DIRS})
55
INCLUDE_DIRECTORIES(${EBOOK_INCLUDE_DIRS})
56
INCLUDE_DIRECTORIES(${LIBNOTIFY_INCLUDE_DIRS})
57 58 59

# link libs
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
60 61 62 63
LINK_DIRECTORIES(${LIB_RING_LIBRARY_INCLUDE_DIR})
LINK_DIRECTORIES(${Qt5Core_LIBRARY_DIRS} )
LINK_DIRECTORIES(${CLUTTER_LIBRARY_DIRS})
LINK_DIRECTORIES(${CLUTTERGTK_LIBRARY_DIRS})
64
LINK_DIRECTORIES(${EBOOK_LIBRARY_DIRS})
65
LINK_DIRECTORIES(${LIBNOTIFY_LIBRARY_DIRS})
66

67 68
# lib compiler flags
ADD_DEFINITIONS(${GTK3_CFLAGS})
69
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
70 71 72 73
ADD_DEFINITIONS(${LIB_RING_LIBRARY_CFLAGS})
ADD_DEFINITIONS(${Qt5Core_CFLAGS})
ADD_DEFINITIONS(${CLUTTER_CFLAGS})
ADD_DEFINITIONS(${CLUTTERGTK_CFLAGS})
74
ADD_DEFINITIONS(${EBOOK_CFLAGS})
75
ADD_DEFINITIONS(${LIBNOTIFY_CFLAGS})
76

Guillaume Roguez's avatar
Guillaume Roguez committed
77 78 79 80 81 82 83 84 85
IF(NOT ${ENABLE_STATIC} MATCHES false)
  SET(QT5_MODULE_PATH ${QT5_PATH}/lib/cmake)
  FIND_PACKAGE(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus)
  FIND_PACKAGE(Qt5DBus REQUIRED)
  INCLUDE_DIRECTORIES(SYSTEM ${Qt5DBus_INCLUDE_DIRS} )
  LINK_DIRECTORIES(${Qt5DBus_LIBRARY_DIRS} )
  ADD_DEFINITIONS(${Qt5DBus_CFLAGS})
ENDIF()

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
# warnings
ADD_DEFINITIONS(
   -Wall
   -Wextra
   -Wno-cpp
   -Wmissing-noreturn
   -Wpointer-arith
   -Wcast-align
   -Wwrite-strings
   -Wformat-nonliteral
   -Wformat-security
   -Wswitch-enum
   -Winit-self
   -Wmissing-include-dirs
   -Wundef
   -Wmissing-format-attribute
   -Wno-reorder
   -Wunused
   -Wuninitialized
   -Woverloaded-virtual
   -Wsuggest-attribute=const
   -Wunused-value
   -Wdouble-promotion
   -Wnonnull
   -Wsequence-point
   -Wunused-but-set-parameter
   -Wsizeof-pointer-memaccess
   -Wvarargs
)

# more warnings
IF (CMAKE_COMPILER_IS_GNUCC)
   IF (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
      ADD_DEFINITIONS(
         -Wconditionally-supported
         -Wdate-time
         -Wdelete-incomplete
         -Wfloat-conversion
      )
   ENDIF()

   IF (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0)
      ADD_DEFINITIONS(
         -Wsuggest-override
         -Wsuggest-final-types
         -Wsuggest-final-methods
         -Wbool-compare
         -Wformat-signedness
         -Wlogical-not-parentheses
         -Wnormalized
         -Wshift-count-negative
         -Wshift-count-overflow
         -Wsized-deallocation
         -Wsizeof-array-argument
      )
   ENDIF()

ENDIF()

# source files to compile
SET( SRC_FILES
   src/main.cpp
148 149 150 151
   src/ring_client.h
   src/ring_client.cpp
   src/ring_client_options.h
   src/ring_client_options.c
152 153
   src/ringmainwindow.h
   src/ringmainwindow.cpp
154 155
   src/incomingcallview.h
   src/incomingcallview.cpp
Stepan Salenikovich's avatar
Stepan Salenikovich committed
156 157
   src/currentcallview.h
   src/currentcallview.cpp
158 159 160 161
   src/models/gtkaccessproxymodel.h
   src/models/gtkaccessproxymodel.cpp
   src/models/gtkqtreemodel.h
   src/models/gtkqtreemodel.cpp
Stepan Salenikovich's avatar
Stepan Salenikovich committed
162 163
   src/utils/drawing.h
   src/utils/drawing.c
164 165
   src/video/video_widget.h
   src/video/video_widget.cpp
166 167
   src/models/gtkqsortfiltertreemodel.h
   src/models/gtkqsortfiltertreemodel.cpp
168 169 170 171 172 173 174 175
   src/accountview.h
   src/accountview.cpp
   src/accountgeneraltab.h
   src/accountgeneraltab.cpp
   src/accountaudiotab.h
   src/accountaudiotab.cpp
   src/accountvideotab.h
   src/accountvideotab.cpp
Stepan Salenikovich's avatar
Stepan Salenikovich committed
176 177
   src/accountadvancedtab.h
   src/accountadvancedtab.cpp
178 179
   src/accountsecuritytab.h
   src/accountsecuritytab.cpp
180 181
   src/models/activeitemproxymodel.h
   src/models/activeitemproxymodel.cpp
182
   src/defines.h
Stepan Salenikovich's avatar
Stepan Salenikovich committed
183 184
   src/video/xrectsel.h
   src/video/xrectsel.c
185 186
   src/dialogs.h
   src/dialogs.c
187 188
   src/mediasettingsview.h
   src/mediasettingsview.cpp
189 190
   src/generalsettingsview.h
   src/generalsettingsview.cpp
191 192 193 194
   src/backends/edscontactbackend.h
   src/backends/edscontactbackend.cpp
   src/delegates/pixbufdelegate.h
   src/delegates/pixbufdelegate.cpp
195 196
   src/callsview.h
   src/callsview.cpp
197 198
   src/contactsview.h
   src/contactsview.cpp
199 200
   src/frequentcontactsview.h
   src/frequentcontactsview.cpp
201 202 203 204 205 206
   src/historyview.h
   src/historyview.cpp
   src/utils/models.h
   src/utils/models.cpp
   src/utils/calling.h
   src/utils/calling.cpp
207 208
   src/ringnotify.h
   src/ringnotify.cpp
209 210
   src/video/videowindow.h
   src/video/videowindow.cpp
211 212
   src/utils/files.h
   src/utils/files.cpp
213 214
)

215 216 217 218
# compile glib resource files to c code
GLIB_COMPILE_RESOURCES( GLIB_RESOURCES_RING
   SOURCE
      pixmaps/pixmaps.gresource.xml
219
      ui/ui.gresource.xml
220 221
)

222 223 224 225 226 227 228 229
# IF(${ENABLE_TEST} MATCHES true)
#    ADD_SUBDIRECTORY( src/test)
# ENDIF()

# for translations
# FIND_PACKAGE ( Gettext REQUIRED )
# ADD_SUBDIRECTORY( po )

230 231 232 233
# install and compile glib gsettings schema
add_schema("cx.ring.RingGnome.gschema.xml" GSCHEMA_RING)

ADD_EXECUTABLE(gnome-ring ${GLIB_RESOURCES_RING} ${GSCHEMA_RING} ${SRC_FILES})
234

Guillaume Roguez's avatar
Guillaume Roguez committed
235
IF(NOT ${ENABLE_STATIC} MATCHES false)
236
TARGET_LINK_LIBRARIES(gnome-ring
237 238
   ${LIB_RING_CLIENT_LIBRARY}
   ${GTK3_LIBRARIES}
Guillaume Roguez's avatar
Guillaume Roguez committed
239 240
   ${Qt5Core_LIBRARIES}
   ${Qt5DBus_LIBRARIES}
241
   ${CLUTTER_LIBRARIES}
Guillaume Roguez's avatar
Guillaume Roguez committed
242
   ${CLUTTERGTK_LIBRARIES}
243
   ${EBOOK_LIBRARIES}
244
   ${LIBNOTIFY_LIBRARIES}
Guillaume Roguez's avatar
Guillaume Roguez committed
245 246 247 248
   -lpthread
   -lrt
   )
ELSE()
249
TARGET_LINK_LIBRARIES(gnome-ring
Guillaume Roguez's avatar
Guillaume Roguez committed
250 251 252 253 254
   ${LIB_RING_CLIENT_LIBRARY}
   ${GTK3_LIBRARIES}
   ${Qt5Core_LIBRARIES}
   ${CLUTTER_LIBRARIES}
   ${CLUTTERGTK_LIBRARIES}
255
   ${EBOOK_LIBRARIES}
256
   ${LIBNOTIFY_LIBRARIES}
Guillaume Roguez's avatar
Guillaume Roguez committed
257 258
   )
ENDIF()
259

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
# configure libnotify variable for config.h file
IF( LIBNOTIFY_FOUND )
   SET(USE_LIBNOTIFY 1)
ELSE()
   SET(USE_LIBNOTIFY 0)
ENDIF()

# create config header file to pass cmake settings to source code
CONFIGURE_FILE (
   "${PROJECT_SOURCE_DIR}/src/config.h.in"
   "${PROJECT_BINARY_DIR}/config.h"
)

# generate .desktop file
CONFIGURE_FILE (
   "${PROJECT_SOURCE_DIR}/gnome-ring.desktop.in"
   "${PROJECT_BINARY_DIR}/gnome-ring.desktop"
)

279
INSTALL(TARGETS gnome-ring
280 281
   RUNTIME DESTINATION bin
)
282

283
# install .desktop in XDG desktop dir so that it is recognized by the system
284 285 286 287
INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop
    DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
)

288 289 290 291 292 293 294 295 296 297 298 299
# install .desktop in the gnome-ring data dir, so that it can be copied to the
# autostart dir by the client
INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop
   DESTINATION
      ${CMAKE_INSTALL_PREFIX}/share/gnome-ring/
   PERMISSIONS
      WORLD_READ
      OWNER_WRITE
      OWNER_READ
      GROUP_READ
)

300 301 302 303 304 305 306
INSTALL(FILES pixmaps/ring.svg
    DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
)

INSTALL(FILES gnome-ring.appdata.xml
    DESTINATION ${CMAKE_INSTALL_PREFIX}/share/appdata/
)
307

308
# install shell script which will launch "ring"
309 310
INSTALL(
   FILES
311
      "${PROJECT_SOURCE_DIR}/src/ring"
312 313 314 315 316 317 318 319 320 321
   DESTINATION
      ${CMAKE_INSTALL_PREFIX}/bin
   PERMISSIONS
      WORLD_READ
      OWNER_WRITE
      OWNER_READ
      GROUP_READ
      OWNER_EXECUTE
      GROUP_EXECUTE
      WORLD_EXECUTE
322 323
)

324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
# add a target to generate API documentation with Doxygen
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile @ONLY)
    ADD_CUSTOM_TARGET(doc
        COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc
        COMMENT "Generating API documentation with Doxygen" VERBATIM
    )

    # create doc/README.md symlink to README since Doxygen doesn't understand file with no extension
    ADD_CUSTOM_COMMAND(
        TARGET doc
        PRE_BUILD
        COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_SOURCE_DIR}/doc/README.md
    )
ENDIF(DOXYGEN_FOUND)