File: CMakeLists.txt

package info (click to toggle)
ring 20190215.1.f152c98~ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 66,208 kB
  • sloc: ansic: 304,045; cpp: 187,144; python: 16,054; xml: 8,285; sh: 5,217; makefile: 3,448; objc: 2,805; java: 1,909; cs: 1,575; asm: 236
file content (941 lines) | stat: -rw-r--r-- 25,635 bytes parent folder | download
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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

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

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

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

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

INCLUDE(GNUInstallDirs)
INCLUDE(CMakePackageConfigHelpers)
INCLUDE(GenerateExportHeader)

option (ENABLE_SHARED "Build shared library" ON)

string(SUBSTRING ${CMAKE_GENERATOR} 0 14 CMAKE_GENERATOR_SHORT)
if(CMAKE_GENERATOR_SHORT MATCHES "Visual Studio ")
    message(STATUS "Generating VS project")
    set(CMAKE_CXX_COMPILER_ID "MSVC")
    set(ENABLE_TEST false)
    set(ENABLE_STATIC true)
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /W0")
endif()

if (NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
    ADD_DEFINITIONS(
       ${QT_DEFINITIONS}
       -fexceptions
       -O2
    )
endif()

# Options
set(CHK_FREEABLE_BEFORE_ERASE_ACCOUNT_DESCRIPTION
"Check that an account has been marked freeable by the client
before freeing the structures. This avoids various race
conditions while removing accounts but may not be supported by
all clients. ON by default on Linux systems, otherwise OFF.")

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  option (CHK_FREEABLE_BEFORE_ERASE_ACCOUNT CHK_FREEABLE_BEFORE_ERASE_ACCOUNT_DESCRIPTION ON)
ELSE()
  option (CHK_FREEABLE_BEFORE_ERASE_ACCOUNT CHK_FREEABLE_BEFORE_ERASE_ACCOUNT_DESCRIPTION OFF)
ENDIF()

PROJECT(ringclient)

# 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()

SET(CMAKE_CXX_STANDARD 14)
SET(CXX_STANDARD_REQUIRED TRUE)

SET(CMAKE_AUTOMOC TRUE)

SET(LOCAL_CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LOCAL_CMAKE_MODULE_PATH})

SET(QT5_MODULE_PATH ${QT5_PATH}/lib/cmake)

FIND_PACKAGE(Ring REQUIRED)
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5LinguistTools) # translations
FIND_PACKAGE(Qt5Sql REQUIRED)
FIND_PACKAGE(Qt5Gui REQUIRED)

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT ENABLE_LIBWRAP)
   FIND_PACKAGE(Qt5DBus)
ELSE()
   SET(ENABLE_LIBWRAP true)
ENDIF()


IF(NOT ENABLE_TEST)
  SET(ENABLE_TEST false)
ENDIF()


IF((${ENABLE_TEST} MATCHES true))
  SET(ENABLE_LIBWRAP true) # because mocks use the same interface present in src/qtwrapper
ENDIF()

if (NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
# Enable some useful warnings
    ADD_DEFINITIONS(
       -Wall
       -Wextra
       -Wmissing-declarations
       -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
       -Wunused-value
       -pedantic
       -Wnonnull
       -Wsequence-point
       #-Wsystem-headers
       -Wsizeof-pointer-memaccess
       #-Wuseless-cast
       -Wvarargs

       #See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
       -Wno-unused-function
       -Wno-attributes
    )
endif()

#Add more warnings for compilers that support it. I used this command:
#curl https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Warning-Options.html | \
#grep -E "^[\t ]+<br><dt><code>-W[a-zA-Z=-]*" -o | grep -E "\-W[a-zA-Z=-]*" -o >
#cat /tmp/48 /tmp/49 | sort | uniq -u
# IF (CMAKE_COMPILER_IS_GNUCC)

IF (CMAKE_COMPILER_IS_GNUCC)
   IF (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
      ADD_DEFINITIONS(
         -Wunused-but-set-parameter
         -Wconditionally-supported
         #-Wsuggest-attribute=const
         -Wno-cpp
         -Wdouble-promotion
         -Wdate-time
         -Wdelete-incomplete
         -Wfloat-conversion
      )
   ENDIF()

   if (GCC_VERSION VERSION_GREATER 5.1 OR GCC_VERSION VERSION_EQUAL 5.1)
      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()

   IF (GCC_VERSION VERSION_GREATER 6.0 OR GCC_VERSION VERSION_EQUAL 6.0)
      ADD_DEFINITIONS(
         -Wnull-dereference
         -Wshift-negative-value
         -Wshift-overflow
         -Wduplicated-cond
         -Wmisleading-indentation
      )
   ENDIF()
ENDIF()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   ADD_DEFINITIONS(
      -Wno-c++98-compat
      -Wno-c++98-compat-pedantic
      -Wno-unknown-pragmas
      -Wno-documentation-unknown-command
      -Wno-padded
      -Wno-old-style-cast
      -Wno-sign-conversion
      -Wno-exit-time-destructors
      -Wno-global-constructors
      -Wno-shorten-64-to-32
      #-Weverything
   )
endif()

# OS X
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

   SET(CMAKE_MACOSX_RPATH ON)
   SET(CMAKE_SKIP_BUILD_RPATH FALSE)
   SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
   SET(CMAKE_INSTALL_RPATH "${CMAKE_CURRENT_SOURCE_DIR}")
   SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

IF(${ENABLE_LIBWRAP} MATCHES true)
   # The daemon is only required for when using direct linking
   IF (${RING_FOUND} MATCHES "false")
      MESSAGE(FATAL_ERROR "The daemon is required")
   ENDIF()

   ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/src/qtwrapper)
   ADD_DEFINITIONS(-DENABLE_LIBWRAP=true) # Use native calls (no dbus)
   if (NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
      ADD_DEFINITIONS(-Wno-unknown-pragmas)
   endif()
   SET(ENABLE_QT5 true) # Use Qt5
   MESSAGE(STATUS "Compiling with qtwrapper enabled, Qt5 enabled.")

   INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/qtwrapper/)

   IF(${VERBOSE_IPC} MATCHES true)
      MESSAGE(STATUS "Adding more debug output")
      ADD_DEFINITIONS(-DVERBOSE_IPC=true)
   ENDIF()
ENDIF()

IF (${RING_FOUND} MATCHES "true")
   INCLUDE_DIRECTORIES(${ring_INCLUDE_DIRS})
ENDIF()

IF(NOT (${ENABLE_VIDEO} MATCHES false))
   MESSAGE(STATUS "VIDEO enabled")
   SET(ENABLE_VIDEO 1 CACHE BOOLEAN "Enable video")
   add_definitions( -DENABLE_VIDEO=true )
ENDIF(NOT (${ENABLE_VIDEO} MATCHES false))

# ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=1)

if (CHK_FREEABLE_BEFORE_ERASE_ACCOUNT)
   ADD_DEFINITIONS(
      -DCHK_FREEABLE_BEFORE_ERASE_ACCOUNT
   )
endif ()

SET(GENERIC_LIB_VERSION "1.0.0")

INCLUDE_DIRECTORIES(SYSTEM ${QT_INCLUDES} )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR})

IF(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
    # Build dbus api
    IF(DEFINED RING_XML_INTERFACES_DIR)
        SET (dbus_xml_introspecs_path ${RING_XML_INTERFACES_DIR})
    ELSEIF(EXISTS "${RING_BUILD_DIR}/../bin/dbus")
        SET (dbus_xml_introspecs_path ${RING_BUILD_DIR}/../bin/dbus)
    ELSE()
        SET (dbus_xml_introspecs_path ${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces)
    ENDIF()

    MESSAGE(STATUS "Using Ring DBus-XML interfaces in ${dbus_xml_introspecs_path}")
ENDIF()

#File to compile
SET( libringclient_LIB_SRCS
  #Data objects
  src/call.cpp
  src/uri.cpp
  src/account.cpp
  src/person.cpp
  src/contactmethod.cpp
  src/numbercategory.cpp
  src/macro.cpp
  src/collectionextensioninterface.cpp
  src/video/rate.cpp
  src/video/device.cpp
  src/video/renderer.cpp
  src/certificate.cpp
  src/securityflaw.cpp
  src/ringtone.cpp
  src/profile.cpp
  src/contactrequest.cpp
  src/media/media.cpp
  src/media/audio.cpp
  src/media/video.cpp
  src/media/text.cpp
  src/media/file.cpp
  src/media/recording.cpp
  src/media/avrecording.cpp
  src/media/textrecording.cpp

  #Models
  src/accountmodel.cpp
  src/availableaccountmodel.cpp
  src/callmodel.cpp
  src/categorizedhistorymodel.cpp
  src/categorizedbookmarkmodel.cpp
  src/categorizedcontactmodel.cpp
  src/presencestatusmodel.cpp
  src/phonedirectorymodel.cpp
  src/historytimecategorymodel.cpp
  src/numbercategorymodel.cpp
  src/macromodel.cpp
  src/keyexchangemodel.cpp
  src/tlsmethodmodel.cpp
  src/protocolmodel.cpp
  src/profilemodel.cpp
  src/ringtonemodel.cpp
  src/securityevaluationmodel.cpp
  src/personmodel.cpp
  src/collectionmodel.cpp
  src/collectionextensionmodel.cpp
  src/collectionmanagerinterface.cpp
  src/networkinterfacemodel.cpp
  src/certificatemodel.cpp
  src/ciphermodel.cpp
  src/chainoftrustmodel.cpp
  src/video/devicemodel.cpp
  src/video/sourcemodel.cpp
  src/video/channel.cpp
  src/video/resolution.cpp
  src/video/configurationproxy.cpp
  src/audio/alsapluginmodel.cpp
  src/audio/inputdevicemodel.cpp
  src/audio/managermodel.cpp
  src/audio/outputdevicemodel.cpp
  src/audio/ringtonedevicemodel.cpp
  src/audio/settings.cpp
  src/media/recordingmodel.cpp
  src/bannedcontactmodel.cpp
  src/contactmodel.cpp
  src/newcallmodel.cpp
  src/newdevicemodel.cpp
  src/newcodecmodel.cpp
  src/conversationmodel.cpp
  src/database.cpp
  src/authority/daemon.cpp
  src/authority/databasehelper.cpp
  src/lrc.cpp
  src/newaccountmodel.cpp
  src/callbackshandler.cpp
  src/behaviorcontroller.cpp
  src/datatransfermodel.cpp
  src/newvideo.cpp
  src/shmrenderer.cpp
  src/directrenderer.cpp

  #Data collections
  src/collectioninterface.cpp
  src/collectioneditor.cpp
  src/fallbackpersoncollection.cpp
  src/daemoncertificatecollection.cpp
  src/foldercertificatecollection.cpp
  src/localrecordingcollection.cpp
  src/localtextrecordingcollection.cpp
  src/localprofilecollection.cpp
  src/localringtonecollection.cpp
  src/peerprofilecollection.cpp

  #Communication
  src/dbus/configurationmanager.cpp
  src/dbus/callmanager.cpp
  src/dbus/instancemanager.cpp
  src/dbus/videomanager.cpp
  src/dbus/presencemanager.cpp

  #Default interface implementations
  src/globalinstances.cpp
  src/presenceserializerdefault.cpp
  src/pixmapmanipulatordefault.cpp
  src/shortcutcreatordefault.cpp
  src/actionextenderdefault.cpp
  src/dbuserrorhandlerdefault.cpp

  #Other
  src/avmodel.cpp
  src/hookmanager.cpp
  src/namedirectory.cpp
  src/itembase.cpp
  src/private/vcardutils.cpp
  src/private/videorenderermanager.cpp
  src/video/previewmanager.cpp
  src/private/sortproxies.cpp
  src/private/threadworker.cpp
  src/mime.cpp
  src/smartinfohub.cpp
  src/usage_statistics.cpp

  #Extension
  src/extensions/presencecollectionextension.cpp
  src/extensions/securityevaluationextension.cpp
)

# Public API
SET( libringclient_LIB_HDRS
  src/account.h
  src/accountmodel.h
  src/availableaccountmodel.h
  src/call.h
  src/call.hpp
  src/callmodel.h
  src/categorizedhistorymodel.h
  src/person.h
  src/collectioninterface.h
  src/collectioninterface.hpp
  src/categorizedbookmarkmodel.h
  src/categorizedcontactmodel.h
  src/presencestatusmodel.h
  src/contactmethod.h
  src/phonedirectorymodel.h
  src/historytimecategorymodel.h
  src/numbercategorymodel.h
  src/keyexchangemodel.h
  src/tlsmethodmodel.h
  src/protocolmodel.h
  src/profilemodel.h
  src/numbercategory.h
  src/ringtonemodel.h
  src/localrecordingcollection.h
  src/localringtonecollection.h
  src/localprofilecollection.h
  src/localtextrecordingcollection.h
  src/peerprofilecollection.h
  src/securityevaluationmodel.h
  src/certificate.h
  src/personmodel.h
  src/collectionmodel.h
  src/collectionextensionmodel.h
  src/collectionextensionmodel.hpp
  src/macromodel.h
  src/hookmanager.h
  src/namedirectory.h
  src/uri.h
  src/macro.h
  src/ringtone.h
  src/profile.h
  src/itembase.h
  src/itembase.hpp
  src/mime.h
  src/collectionextensioninterface.h
  src/collectionmanagerinterface.h
  src/collectionmanagerinterface.hpp
  src/networkinterfacemodel.h
  src/certificatemodel.h
  src/ciphermodel.h
  src/collectionmediator.h
  src/collectionmediator.hpp
  src/collectioneditor.h
  src/collectioneditor.hpp
  src/fallbackpersoncollection.h
  src/daemoncertificatecollection.h
  src/foldercertificatecollection.h
  src/securityflaw.h
  src/collectioncreationinterface.h
  src/collectionconfigurationinterface.h
  src/chainoftrustmodel.h
  src/contactrequest.h
  src/globalinstances.h
  src/presenceserializerdefault.h
  src/pixmapmanipulatordefault.h
  src/shortcutcreatordefault.h
  src/dbuserrorhandlerdefault.h
  src/itemdataroles.h
  src/smartinfohub.h
  src/usage_statistics.h
  src/bannedcontactmodel.h
  src/vcard.h
  src/shmrenderer.h
  src/directrenderer.h
)

SET(libringclient_api_LIB_HDRS
  src/api/interaction.h
  src/api/conversation.h
  src/api/contact.h
  src/api/call.h
  src/api/account.h
  src/api/lrc.h
  src/api/avmodel.h
  src/api/newaccountmodel.h
  src/api/newcallmodel.h
  src/api/newcodecmodel.h
  src/api/newdevicemodel.h
  src/api/contactmodel.h
  src/api/conversationmodel.h
  src/api/profile.h
  src/api/behaviorcontroller.h
  src/api/datatransfermodel.h
  src/api/datatransfer.h
  src/api/newvideo.h
)


SET(libringclient_video_LIB_HDRS
  src/video/device.h
  src/video/devicemodel.h
  src/video/sourcemodel.h
  src/video/renderer.h
  src/video/resolution.h
  src/video/channel.h
  src/video/rate.h
  src/video/previewmanager.h
  src/video/configurationproxy.h
  #The renderer implementations are not exported on purpose
)

SET(libringclient_audio_LIB_HDRS
  src/audio/alsapluginmodel.h
  src/audio/inputdevicemodel.h
  src/audio/managermodel.h
  src/audio/outputdevicemodel.h
  src/audio/ringtonedevicemodel.h
  src/audio/settings.h
)

SET(libringclient_extensions_LIB_HDRS
  src/extensions/presencecollectionextension.h
  src/extensions/securityevaluationextension.h
)

SET(libringclient_media_LIB_HDRS
  src/media/media.h
  src/media/audio.h
  src/media/video.h
  src/media/text.h
  src/media/file.h
  src/media/recording.h
  src/media/avrecording.h
  src/media/textrecording.h
  src/media/recordingmodel.h
)

SET(libringclient_interface_LIB_HDRS
  src/interfaces/contactmethodselectori.h
  src/interfaces/presenceserializeri.h
  src/interfaces/itemmodelstateserializeri.h
  src/interfaces/pixmapmanipulatori.h
  src/interfaces/shortcutcreatori.h
  src/interfaces/actionextenderi.h
  src/interfaces/dbuserrorhandleri.h
)

SET( libringclient_extra_LIB_HDRS
  src/typedefs.h
)

IF(${ENABLE_LIBWRAP} MATCHES true OR ${ENABLE_TEST} MATCHES true)
   # done this way because of bug in cmake 2.8
   # (not necessary in 3.0+)
ELSE()
   # presence manager interface
   SET ( presencemanager_xml  ${dbus_xml_introspecs_path}/cx.ring.Ring.PresenceManager.xml )

   SET( dbus_metatype_path "${CMAKE_CURRENT_SOURCE_DIR}/src/dbus/metatypes.h")

   SET_SOURCE_FILES_PROPERTIES(
      ${presencemanager_xml}
      PROPERTIES
      CLASSNAME PresenceManagerInterface
      INCLUDE ${dbus_metatype_path}
   )

   QT5_ADD_DBUS_INTERFACE(
      libringclient_LIB_SRCS
      ${presencemanager_xml}
      presencemanager_dbus_interface
   )

   # configuration manager interface
   SET ( configurationmanager_xml  ${dbus_xml_introspecs_path}/cx.ring.Ring.ConfigurationManager.xml )

   SET_SOURCE_FILES_PROPERTIES(
      ${configurationmanager_xml}
      PROPERTIES
      CLASSNAME ConfigurationManagerInterface
      INCLUDE ${dbus_metatype_path}
   )

   QT5_ADD_DBUS_INTERFACE(
      libringclient_LIB_SRCS
      ${configurationmanager_xml}
      configurationmanager_dbus_interface
   )

   # call manager interface
   SET ( callmanager_xml  ${dbus_xml_introspecs_path}/cx.ring.Ring.CallManager.xml )

   SET_SOURCE_FILES_PROPERTIES(
      ${callmanager_xml}
      PROPERTIES
      CLASSNAME CallManagerInterface
      INCLUDE ${dbus_metatype_path}
   )

   QT5_ADD_DBUS_INTERFACE(
      libringclient_LIB_SRCS
      ${callmanager_xml}
      callmanager_dbus_interface
   )

   # video manager interface
   SET ( video_xml  ${dbus_xml_introspecs_path}/cx.ring.Ring.VideoManager.xml )

   SET_SOURCE_FILES_PROPERTIES(
      ${video_xml}
      PROPERTIES
      CLASSNAME VideoManagerInterface
      INCLUDE ${dbus_metatype_path}
   )

   QT5_ADD_DBUS_INTERFACE(
      libringclient_LIB_SRCS
      ${video_xml}
      video_dbus_interface
   )


   # instance interface
   SET ( instance_xml  ${dbus_xml_introspecs_path}/cx.ring.Ring.Instance.xml )

   SET_SOURCE_FILES_PROPERTIES(
      ${instance_xml}
      PROPERTIES
      CLASSNAME InstanceManagerInterface
      INCLUDE ${dbus_metatype_path}
   )

   QT5_ADD_DBUS_INTERFACE(
      libringclient_LIB_SRCS
      ${instance_xml}
      instance_dbus_interface
   )
ENDIF()

# Manually wrap private files and interfaces
SET(libringclient_PRIVATE_HDRS
   src/private/call_p.h
   src/private/namedirectory_p.h
   src/private/account_p.h
   src/private/sortproxies.h
   src/private/accountmodel_p.h
   src/private/phonedirectorymodel_p.h
   src/private/videorenderer_p.h
   src/private/textrecording_p.h
   src/private/videodevice_p.h
   src/private/collectionmodel_p.h
   src/private/securityflaw_p.h
   src/private/macromodel_p.h
   src/private/person_p.h
   src/collectioncreationinterface.h
   src/private/securityevaluationmodel_p.h
   src/collectionconfigurationinterface.h
   src/private/imconversationmanagerprivate.h
   src/private/smartInfoHub_p.h
   src/private/certificatemodel_p.h
)


IF(${ENABLE_LIBWRAP} MATCHES true AND ${ENABLE_TEST} MATCHES false)
   SET(libringclient_PRIVATE_HDRS
      ${libringclient_PRIVATE_HDRS}

      src/qtwrapper/callmanager_wrap.h
      src/qtwrapper/configurationmanager_wrap.h
      src/qtwrapper/instancemanager_wrap.h
      src/qtwrapper/presencemanager_wrap.h
      src/qtwrapper/videomanager_wrap.h
   )
ENDIF()

IF(NOT ${ENABLE_TEST} MATCHES true)
  QT5_WRAP_CPP(LIB_HEADER_MOC ${libringclient_PRIVATE_HDRS})
ENDIF()

IF(NOT ${ENABLE_STATIC} MATCHES false)
    message(STATUS "Configuring as static lib")
    add_library( ringclient_static  STATIC ${libringclient_LIB_SRCS} ${LIB_HEADER_MOC} )
    target_link_libraries(ringclient_static Qt5::Core)
    target_link_libraries(ringclient_static Qt5::Gui)
    target_link_libraries( ringclient_static
       -lpthread
       ${QT_QTDBUS_LIBRARY}
       ${QT_QTCORE_LIBRARY}
       ${QT_QTGUI_LIBRARY}
       Qt5::Sql
       )
    SET_TARGET_PROPERTIES( ringclient_static
       PROPERTIES VERSION ${GENERIC_LIB_VERSION}
    )
ENDIF()

if (ENABLE_SHARED)
    message(STATUS "Configuring as shared lib")
    add_library(ringclient SHARED ${libringclient_LIB_SRCS} ${LIB_HEADER_MOC} )
    target_link_libraries(ringclient Qt5::Core Qt5::Gui)
endif()

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    if (ENABLE_SHARED)
        target_link_libraries(ringclient Qt5::DBus)
    endif()
  IF(${ENABLE_STATIC} MATCHES true)
      target_link_libraries(ringclient_static Qt5::DBus)
  ENDIF()
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    FIND_PACKAGE(Qt5Concurrent)

    #For some reason, QSemaphore wont compile on Windows without QtConcurrent
    if(${ENABLE_STATIC} MATCHES true)
        target_link_libraries(ringclient_static Qt5::Concurrent)
    endif()

    if(ENABLE_SHARED)
        target_link_libraries(ringclient Qt5::Concurrent)
    endif()
ENDIF()


IF (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
    TARGET_LINK_LIBRARIES( ringclient
        -lpthread
        ${QT_QTCORE_LIBRARY}
        Qt5::Gui
        Qt5::Sql
        )
ENDIF()

IF(${ENABLE_LIBWRAP} MATCHES true)
   IF((NOT ${ring_BIN} MATCHES "ring_BIN-NOTFOUND") AND ENABLE_SHARED)
      TARGET_LINK_LIBRARIES( ringclient
         qtwrapper
         ${ring_BIN}
      )
   ELSE()
      # Allow building with undefined symbols when only the daemon headers are provided
      # It speeds up our CI builds
      IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
         SET_TARGET_PROPERTIES( ringclient PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
      ENDIF()
   ENDIF()
   IF(NOT ${ENABLE_STATIC} MATCHES false)
      TARGET_LINK_LIBRARIES( ringclient_static
         qtwrapper
         ${ring_BIN}
      )
   ENDIF()

ELSE()
   TARGET_LINK_LIBRARIES( ringclient
      ${QT_QTDBUS_LIBRARY}
   )
ENDIF()

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
   TARGET_LINK_LIBRARIES( ringclient
      -lrt
   )

   IF(NOT ${ENABLE_STATIC} MATCHES false)
      TARGET_LINK_LIBRARIES( ringclient_static
         -lrt
      )
   ENDIF()
ENDIF()

if(ENABLE_SHARED)
    SET_TARGET_PROPERTIES( ringclient
      PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_VERSION}
    )
endif()

SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)

INSTALL( FILES ${libringclient_LIB_HDRS} ${libringclient_extra_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_video_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/video
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_audio_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/audio
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_media_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/media
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_extensions_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/extensions
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_interface_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/interfaces
  COMPONENT Devel
)

INSTALL( FILES ${libringclient_api_LIB_HDRS}
  DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/api
  COMPONENT Devel
)


#This hack force Debian based system to return a non multi-arch path
#this is required to prevent the .deb libringclient.so from having an
#higher priority than the prefixed one.
STRING(REPLACE "${CMAKE_LIBRARY_ARCHITECTURE}" "" SANE_LIBRARY_PATH "${CMAKE_INSTALL_FULL_LIBDIR}" )

IF(NOT ${ENABLE_STATIC} MATCHES false)
    INSTALL( TARGETS ringclient_static
        ARCHIVE DESTINATION ${SANE_LIBRARY_PATH}
        LIBRARY DESTINATION ${SANE_LIBRARY_PATH}
        DESTINATION ${SANE_LIBRARY_PATH}
    )
ENDIF()

if(ENABLE_SHARED)
    INSTALL( TARGETS ringclient
        ARCHIVE DESTINATION ${SANE_LIBRARY_PATH}
        RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
        LIBRARY DESTINATION ${SANE_LIBRARY_PATH}
        DESTINATION ${SANE_LIBRARY_PATH}
    )
endif()

SET(LIB_INSTALL_DIR ${SANE_LIBRARY_PATH})

# Create a CMake config file

# TARGET_INCLUDE_DIRECTORIES(ringclient PUBLIC
# "$<INSTALL_INTERFACE:$<CMAKE_INSTALL_PREFIX>/${INCLUDE_INSTALL_DIR}/libringclient>"
# )
SET(libringclient_CONFIG_PATH "${CMAKE_CURRENT_BINARY_DIR}/LibRingClientConfig.cmake")

CONFIGURE_PACKAGE_CONFIG_FILE(
   "${CMAKE_SOURCE_DIR}/cmake/LibRingClientConfig.cmake.in" ${libringclient_CONFIG_PATH}
   INSTALL_DESTINATION ${LIB_INSTALL_DIR}/libringclient/cmake
   PATH_VARS INCLUDE_INSTALL_DIR
)

INSTALL( FILES ${libringclient_CONFIG_PATH}
  DESTINATION ${SANE_LIBRARY_PATH}/cmake/LibRingClient
  COMPONENT Devel
)

# WRITE_BASIC_PACKAGE_VERSION_FILE(
#    ${libringclient_CONFIG_PATH}
#    VERSION ${GENERIC_LIB_VERSION}
#    COMPATIBILITY SameMajorVersion
# )

# translations
IF( Qt5LinguistTools_FOUND )
   # translation template file
   SET(TS_TEMPLATE ${CMAKE_SOURCE_DIR}/translations/lrc_en.ts)

   # get all translation files except the template
   FILE(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/translations/*.ts)
   LIST(REMOVE_ITEM TS_FILES ${TS_TEMPLATE})

   # compiled .qm files
   QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES})

   ADD_CUSTOM_TARGET(translations ALL DEPENDS ${QM_FILES})

   INSTALL(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/libringclient/translations")
ENDIF()

# uninstall target
CONFIGURE_FILE(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)


IF((${ENABLE_TEST} MATCHES true))
  ADD_DEFINITIONS(-DENABLE_LIBWRAP=true) # Avoid dbus models
  ADD_DEFINITIONS(-DENABLE_TEST=true) # Use mocks
  INCLUDE_DIRECTORIES(SYSTEM ${Qt5Core_INCLUDE_DIRS} )
  INCLUDE_DIRECTORIES(SYSTEM ${Qt5Gui_INCLUDE_DIRS} )
  FIND_PACKAGE(Cppunit REQUIRED)
  FIND_PACKAGE(Qt5Widgets)
  MESSAGE(STATUS "Is cppunit present? " ${CPPUNIT_FOUND})
  # unit testing
  IF (CPPUNIT_FOUND)
    add_executable(LRCTester
      test/mocks/callmanager_mock.h
      test/mocks/configurationmanager_mock.h
      test/mocks/instancemanager_mock.h
      test/mocks/presencemanager_mock.h
      test/mocks/videomanager_mock.h
      test/test_runner.cpp
      test/databasetester.h
      test/databasetester.cpp
      test/utils/waitforsignalhelper.h
      test/utils/waitforsignalhelper.cpp
      test/conversationmodeltester.h
      test/conversationmodeltester.cpp
      test/contactmodeltester.h
      test/contactmodeltester.cpp
      test/datatransfertester.h
      test/datatransfertester.cpp
      test/newcallmodeltester.h
      test/newcallmodeltester.cpp
      test/newaccountmodeltester.h
      test/newaccountmodeltester.cpp
      ${libringclient_LIB_SRCS}
      ${LIB_HEADER_MOC}
      ${libringclient_PRIVATE_HDRS}
    )
    TARGET_LINK_LIBRARIES(LRCTester
       -lcppunit
       -lpthread
       ${QT_QTCORE_LIBRARY}
       Qt5::Gui
       Qt5::Sql
    )

    IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
       TARGET_LINK_LIBRARIES( LRCTester
          -lrt
       )
    ENDIF()
    enable_testing()
    add_test(TEST LRCTester)
  ENDIF()
ENDIF()