-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
880 lines (798 loc) · 37.1 KB
/
CMakeLists.txt
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
project (OSCam C)
#----------------------- minimum version of cmake to use ------------
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(SET CMP0003 NEW)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
#----------------------- detect system ------------------------------
if (CMAKE_CROSSCOMPILING)
if (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
set (OSCamOperatingSystem "Tuxbox")
elseif (OSCAM_SYSTEM_NAME MATCHES "TripleDragon")
set (OSCamOperatingSystem "TripleDragon")
elseif (OSCAM_SYSTEM_NAME MATCHES "Coolstream")
set (OSCamOperatingSystem "NeutrinoHD")
elseif (OSCAM_SYSTEM_NAME MATCHES "CST2")
set (OSCamOperatingSystem "NHD2")
elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
set (OSCamOperatingSystem "SlugOS")
elseif (OSCAM_SYSTEM_NAME MATCHES "WRT350NV2")
set (OSCamOperatingSystem "OpenWRT")
set (CS_OS_HW "wrt350nv2")
elseif (OSCAM_SYSTEM_NAME MATCHES "Dockstar")
set (OSCamOperatingSystem "OpenWRT")
set (CS_OS_HW "dockstar")
elseif (OSCAM_SYSTEM_NAME MATCHES "Fonera2")
set (OSCamOperatingSystem "Fonera2")
elseif (OSCAM_SYSTEM_NAME MATCHES "DIR-825")
set (OSCamOperatingSystem "DIR-825")
elseif (OSCAM_SYSTEM_NAME MATCHES "AZBox")
set (OSCamOperatingSystem "AZBox")
elseif (OSCAM_SYSTEM_NAME MATCHES "SU980")
set (OSCamOperatingSystem "SU980")
elseif (OSCAM_SYSTEM_NAME MATCHES "MCA")
set (OSCamOperatingSystem "MCA")
elseif (OSCAM_SYSTEM_NAME MATCHES "agv2+w")
set (OSCamOperatingSystem "agv2+w")
elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
set (OSCamOperatingSystem "WRT54G")
elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
set (OSCamOperatingSystem "Amino")
elseif (OSCAM_SYSTEM_NAME MATCHES "QboxHD")
set (OSCamOperatingSystem "QboxHD")
elseif (OSCAM_SYSTEM_NAME MATCHES "Padre")
set (OSCamOperatingSystem "Padre")
elseif (OSCAM_SYSTEM_NAME MATCHES "FriendlyARM")
set (OSCamOperatingSystem "FriendlyARM")
else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
set (OSCamOperatingSystem "Unknown")
endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
else (CMAKE_CROSSCOMPILING)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (OSCamOperatingSystem "Linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set (OSCamOperatingSystem "FreeBSD")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
set (OSCamOperatingSystem "OpenBSD")
elseif (OSCamOperatingSystem MATCHES "Padre")
add_definitions ("-DPADRE -DSPARC")
set (DEFAULT_CS_CONFDIR "/etc/oscam")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (OSCamOperatingSystem "Mac OS X")
execute_process(COMMAND sw_vers -productVersion COMMAND cut -c 1-4 COMMAND tr -d '\n' OUTPUT_VARIABLE SWVER)
execute_process(COMMAND xcodebuild -version COMMAND grep Xcode COMMAND sed "s/Xcode\ //g" COMMAND tr -d '\n' OUTPUT_VARIABLE XCODEVER)
message (STATUS "mac sdk version is ${SWVER}")
message (STATUS "mac Xcode version is ${XCODEVER}")
add_definitions ("-w")
set (CMAKE_OSX_DEPLOYMENT_TARGET "${SWVER}")
if (SWVER GREATER 10.5)
set (CMAKE_OSX_ARCHITECTURES "x86_64")
endif (SWVER GREATER 10.5)
if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
message (STATUS "Compiling with xcode less then 4.3 on 10.7 If You have time update You're Xcode")
endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
set (STATIC_LIBUSB True)
elseif (${CYGWIN})
set (OSCamOperatingSystem "Windows/Cygwin")
set (CMAKE_SYSTEM_PROCESSOR "i386")
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
set (OSCamOperatingSystem "Unknown")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif (CMAKE_CROSSCOMPILING)
#----------------------- some paths ------------------------------
set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/csctapi
${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
${CMAKE_CURRENT_SOURCE_DIR}/minilzo
${CMAKE_CURRENT_SOURCE_DIR}/ffdecsa
${CMAKE_CURRENT_SOURCE_DIR}/extapi/cygwin
/usr/include/w32api
${OPTIONAL_INCLUDE_DIR}
)
else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/csctapi
${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
${CMAKE_CURRENT_SOURCE_DIR}/minilzo
${CMAKE_CURRENT_SOURCE_DIR}/ffdecsa
${OPTIONAL_INCLUDE_DIR}
)
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
if(OSCamOperatingSystem MATCHES "Windows/Cygwin")
link_directories (
/usr/lib
/usr/lib/w32api
/cygdrive/c/WINDOWS/system32/
${OPTIONAL_LINK_DIR}
)
else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
link_directories (
${OPTIONAL_LINK_DIR}
)
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
#----------------------- global options ------------------------------
if (OSCamOperatingSystem MATCHES "Linux")
set (DEFAULT_CS_CONFDIR "/usr/local/etc")
elseif (OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT HAVE_PCSC EQUAL 0)
add_definitions ("-DWITH_PCSC=1")
endif (NOT HAVE_PCSC EQUAL 0)
set (DEFAULT_CS_CONFDIR "/usr/local/etc")
elseif (OSCamOperatingSystem MATCHES "Tuxbox")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "TripleDragon")
add_definitions ("-DSTB04SCI=1")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
add_definitions ("-DWITH_COOLAPI=1")
set (USE_COOLAPI "USE_COOLAPI")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "NHD2")
add_definitions ("-DWITH_COOLAPI2=1")
set (USE_COOLAPI2 "USE_COOLAPI2")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "SlugOS")
set (DEFAULT_CS_CONFDIR "/var/etc")
elseif (OSCamOperatingSystem MATCHES "OpenWRT")
if (CS_OS_HW MATCHES "wrt350nv2")
set (DEFAULT_CS_CONFDIR "/etc/oscam")
elseif (CS_OS_HW MATCHES "dockstar")
set (DEFAULT_CS_CONFDIR "/usr/oscam")
endif (CS_OS_HW MATCHES "wrt350nv2")
elseif (OSCamOperatingSystem MATCHES "Fonera2")
set (DEFAULT_CS_CONFDIR "/var/etc")
elseif (OSCamOperatingSystem MATCHES "DIR-825")
set (DEFAULT_CS_CONFDIR "/var/etc")
elseif (OSCamOperatingSystem MATCHES "AZBox")
add_definitions ("-DWITH_AZBOX=1")
set (USE_AZBOX "USE_AZBOX")
set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/oscamCAS")
elseif (OSCamOperatingSystem MATCHES "SU980")
set (USE_SU980 "USE_SU980")
add_definitions ("-DWITH_SU980=1")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "MCA")
add_definitions ("-DWITH_MCA=1")
set (USE_MCA "USE_MCA")
set (DEFAULT_CS_CONFDIR "/var/mca/d1")
elseif (OSCamOperatingSystem MATCHES "agv2+w")
set (DEFAULT_CS_CONFDIR "/etc")
elseif (OSCamOperatingSystem MATCHES "WRT54G")
set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
elseif (OSCamOperatingSystem MATCHES "Amino")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "QboxHD")
add_definitions ("-DQBOXHD=1")
set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
add_definitions ("-static -DWITH_PCSC=1")
set (DEFAULT_CS_CONFDIR ".")
elseif (OSCamOperatingSystem MATCHES "FreeBSD")
add_definitions ("-I/usr/local/include -L/usr/local/lib")
set (DEFAULT_CS_CONFDIR ".")
elseif (OSCamOperatingSystem MATCHES "OpenBSD")
add_definitions ("-I/usr/local/include -L/usr/local/lib")
set (DEFAULT_CS_CONFDIR "/etc/oscam")
elseif (OSCamOperatingSystem MATCHES "FriendlyARM")
set (DEFAULT_CS_CONFDIR ".")
endif (OSCamOperatingSystem MATCHES "Linux")
set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
add_definitions ("-DCS_CONFDIR=\"${CS_CONFDIR}\"")
#----------------------- subdirectories ------------------------------
include (CheckIncludeFile)
check_include_file ("pthread.h" HAVE_PTHREAD)
if (HAVE_PTHREAD)
message(STATUS " pthread found. Adding pthread support ")
add_definitions ("-DHAVE_PTHREAD_H")
elseif (HAVE_PTHREAD)
message(STATUS " no pthread found. No smartreader ")
endif (HAVE_PTHREAD)
check_include_file ("openssl/aes.h" HAVE_LIBCRYPTO)
if (HAVE_LIBCRYPTO)
add_definitions ("-DWITH_LIBCRYPTO=1")
set (USE_LIBCRYPTO "USE_LIBCRYPTO")
else (HAVE_LIBCRYPTO)
message (STATUS " LIBCRYTO NOT FOUND OR DISABLED NO SSL SUPPORT POSSIBLE")
endif (HAVE_LIBCRYPTO)
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SSL OUTPUT_VARIABLE CONFIG_WITH_SSL OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
message ( STATUS " ssl is added by You compiling with ssl included")
elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 1)
message (STATUS " ssl is added by You but it was already enabled by config file")
elseif (CONFIG_WITH_SSL MATCHES "N" AND NOT WITH_SSL EQUAL 1)
message (STATUS " SSL IS NOT INCLUDED IN THIS COMPILATION")
endif (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
if (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0)
message(status " SSL is added by config file ${CONFIG_WITH_SSL} compiling with ssl included")
add_definitions ("-DWITH_SSL")
set (WITH_SSL "1")
elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 0)
message (status " The config file has ssl enabled, but You disabled it by you cmake command COMPILING WHITOUT SSL")
endif (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0)
find_package(OpenSSL)
if (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
include_directories(${OPENSSL_INCLUDE_DIR})
message(STATUS " openssl found.")
if (WITH_SSL EQUAL 1)
set(USE_SSL "USE_SSL")
endif (WITH_SSL EQUAL 1)
else (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
message(STATUS "SSL REQUESTED BUT OPENSSL or LYBCRYPTO NOT FOUND !!")
if (WITH_SSL)
message(STATUS " ssl support requested but openssl or libcrypto NOT FOUND COMPILING WHITOUT SSL !!! ")
set (WITH_SSL "0")
endif (WITH_SSL)
endif (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (LIBRTDIR)
check_include_file ("${LIBRTDIR}/include/time.h" HAVE_LIBRT_STATIC)
if (HAVE_LIBRT_STATIC)
if (EXISTS ${LIBRTDIR}/lib/librt.a)
message(STATUS " static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).")
add_definitions ("-I${LIBRTDIR}/include/")
add_library(imp_librt STATIC IMPORTED)
set_property(TARGET imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a)
else (EXISTS ${LIBRTDIR}/lib/librt.a)
message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb). No smartreader support)")
set (HAVE_LIBRT_STATIC False)
endif (EXISTS ${LIBRTDIR}/lib/librt.a)
else (HAVE_LIBRT_STATIC)
message(STATUS " no librt found (needed by libusb). No smartreader support")
endif (HAVE_LIBRT_STATIC)
else (LIBRTDIR)
check_include_file ("time.h" HAVE_LIBRT)
if (HAVE_LIBRT)
message(STATUS " librt found (needed by libusb).")
else (HAVE_LIBRT)
message(STATUS " no librt found (needed by libusb. No smartreader support")
endif (HAVE_LIBRT)
endif (LIBRTDIR)
if (WITH_STAPI)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
message(STATUS " liboscam_stapi.a found")
add_definitions ("-DWITH_STAPI=1")
add_library(stapilib STATIC IMPORTED)
set_property(TARGET stapilib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
set (HAVE_LIBSTAPI True)
set (USE_STAPI "USE_STAPI")
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
message(FATAL " liboscam_stapi.a support requested but not found! ")
set (HAVE_LIBSTAPI False)
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
endif (WITH_STAPI)
if (WITH_STAPI5)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
message(STATUS " liboscam_stapi5.a found")
add_definitions ("-DWITH_STAPI5=1")
add_library(stapi5lib STATIC IMPORTED)
set_property(TARGET stapi5lib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
set (HAVE_LIBSTAPI5 True)
set (USE_STAPI5 "USE_STAPI5")
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
message(FATAL " liboscam_stapi5.a support requested but not found! ")
set (HAVE_LIBSTAPI5 False)
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
endif (WITH_STAPI5)
else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
set (HAVE_LIBRT True)
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
if (LIBUSBDIR)
check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB)
if (HAVE_LIBUSB AND HAVE_PTHREAD)
if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
if (STATIC_LIBUSB EQUAL 1)
message(STATUS " libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ")
add_definitions ("-DWITH_LIBUSB=1")
add_definitions ("-I${LIBUSBDIR}/include/")
set (LIBUSB "USE_LIBUSB")
add_library(imp_libusb STATIC IMPORTED)
set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a)
elseif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
set (CMAKE_FIND_ROOT_PATH ${LIBUSBDIR})
find_library (LIBUSB_LIBRARY NAMES usb-1.0)
message(STATUS "libusb 1.0 found (${LIBUSB_LIBRARY}). Adding smartreader support ")
add_definitions ("-DWITH_LIBUSB=1")
add_definitions ("-I${LIBUSBDIR}/include/")
set (LIBUSB "USE_LIBUSB")
add_library(imp_libusb SHARED IMPORTED)
set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSB_LIBRARY} )
endif (STATIC_LIBUSB EQUAL 1)
else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
message(STATUS " libusb 1.0 not found (${LIBUSBDIR}/lib/libusb). No smartreader support ")
set (HAVE_LIBUSB False)
set (HAVE_LIBRT False)
set (HAVE_LIBRT_STATIC False)
endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
else (HAVE_LIBUSB AND HAVE_PTHREAD)
message(STATUS " no libusb 1.0 found. No smartreader support")
set (HAVE_LIBUSB False)
set (HAVE_LIBRT False)
set (HAVE_LIBRT_STATIC False)
endif (HAVE_LIBUSB AND HAVE_PTHREAD)
else (LIBUSBDIR)
if (NOT HAVE_LIBUSB EQUAL 0)
check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB)
check_include_file ("libusb-1.0/libusb.h" PRESENT)
endif(NOT HAVE_LIBUSB EQUAL 0)
if (OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT)
find_file (USBINCL_LOC "libusb-1.0/libusb.h")
if (EXISTS ${USBINCL_LOC})
add_definitions ("-I/usr/local/include -L/usr/local/lib -I/usr/include -L/usr/lib")
set (HAVE_LIBUSB True)
set (PRESENT True)
set (USE_LIBUSB "USE_LIBUSB")
if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
set (STATICLIBUSB False)
elseif (STATIC_LIBUSB EQUAL 1)
set (STATICLIBUSB True)
endif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
endif (EXISTS ${USBINCL_LOC})
endif (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT)
endif (OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
if(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
message(STATUS " libusb 1.0 found (libusb-1.0.so) Adding smartreader support ")
add_definitions ("-DWITH_LIBUSB=1")
set (USE_LIBUSB "USE_LIBUSB")
set (STATICLIBUSB False)
endif(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
elseif(STATIC_LIBUSB EQUAL 1)
if (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
message(STATUS " static libusb 1.0 found (libusb-1.0.a). Adding smartreader support ")
add_definitions ("-DWITH_LIBUSB=1")
set (USE_LIBUSB "USE_LIBUSB")
set (STATICLIBUSB True)
else (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
message(STATUS " no libusb 1.0 found. No smartreader support")
set (HAVE_LIBUSB False)
endif (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
endif(NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
endif (LIBUSBDIR)
endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
if (HAVE_PCSC)
FIND_PATH (PCSC_PATH PCSC/wintypes.h)
if(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
message(STATUS " PCSC headers found (${OPTIONAL_INCLUDE_DIR}/PCSC). Adding PCSC support ")
add_definitions ("-DWITH_PCSC=1")
add_definitions ("-I${OPTIONAL_INCLUDE_DIR}/PCSC")
set (USE_PCSC "USE_PCSC")
elseif (EXISTS ${PCSC_PATH}/PCSC/wintypes.h AND NOT OPTIONAL_INCLUDE_DIR)
message(STATUS " PCSC headers found (${PCSC_PATH}/PCSC). Adding PCSC support ")
add_definitions ("-DWITH_PCSC=1")
add_definitions ("-I${PCSC_PATH}/PCSC")
set (USE_PCSC "USE_PCSC")
else (OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
set (HAVE_PCSC False)
if(OPTIONAL_INCLUDE_DIR)
message(STATUS " PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC or ${OPTIONAL_INCLUDE_DIR}/PCSC). No PCSC support ")
else(OPTIONAL_INCLUDE_DIR)
message(STATUS " PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC). No PCSC support ")
endif(OPTIONAL_INCLUDE_DIR)
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
endif(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
if (OSCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0)
set (USE_PCSC "USE_PCSC")
set (HAVE_PCSC "1")
endif (OSCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0)
else (HAVE_PCSC)
if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
add_definitions ("-Icygwin")
set (HAVE_PCSC "1")
set (USE_PCSC "USE_PCSC")
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
endif (HAVE_PCSC)
# Manage config.h based on command line parameters
# Manipulate config file based on given parameters and read unset parameters
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_EMU OUTPUT_VARIABLE CONFIG_WITH_EMU OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1)
add_definitions ("-DWITH_EMU")
set (WITH_EMU "1")
message (STATUS " EMU is added by config compiling with EMU")
endif (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1)
if (WITH_EMU)
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SOFTCAM OUTPUT_VARIABLE CONFIG_WITH_SOFTCAM OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1)
add_definitions ("-DWITH_SOFTCAM")
set (WITH_SOFTCAM "1")
message (STATUS " SOFTCAM is added by config linking SoftCam.Key")
endif (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1)
endif (WITH_EMU)
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --show-valid OUTPUT_VARIABLE config_vars_string OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCHALL "[A-Z0-9_]+" config_vars ${config_vars_string})
MACRO(GENERATE_OSCAM_CONFIG fullpath)
foreach(option ${config_vars})
if(DEFINED ${option})
if(${option})
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enable ${option})
else(${option})
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --disable ${option})
endif(${option})
endif(DEFINED ${option})
endforeach(option)
ENDMACRO(GENERATE_OSCAM_CONFIG fullpath)
GENERATE_OSCAM_CONFIG("${CMAKE_CURRENT_SOURCE_DIR}/config.h")
# Build config.mak and related files
# FIXME: Create USE_FLAGS and pass them to config.sh using --use-flags
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --objdir ${CMAKE_CURRENT_BINARY_DIR} --use-flags "${USE_STAPI} ${USE_STAPI5} /
${USE_COOLAPI} ${USE_SU980} ${USE_AZBOX} ${USE_MCA} ${USE_SSL} ${USE_LIBCRYPTO} ${USE_LIBUSB} ${USE_PCSC}" --make-config.mak)
# Generate webif/pages.c
execute_process (COMMAND make --no-print-directory --quiet -C ${CMAKE_CURRENT_SOURCE_DIR}/webif)
#----------------------- subdirectories ------------------------------
add_subdirectory (csctapi)
add_subdirectory (minilzo)
add_subdirectory (cscrypt)
add_subdirectory (ffdecsa)
#----------------------- file groups ------------------------------
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled MODULE_CAMD33 OUTPUT_VARIABLE CAMD33 OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CAMD33 MATCHES "N")
set (CAMD_33 "module-camd33*")
endif (CAMD33 MATCHES "N")
if (OSCamOperatingSystem MATCHES "Mac OS X")
file (GLOB csmodules_mac "module-dvbapi*" "module-lcd*" "${CAMD_33}")
file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
list (REMOVE_ITEM csmodules_srcs ${csmodules_mac})
file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
list (REMOVE_ITEM csmodules_hdrs ${csmodules_mac})
file (GLOB csreaders_srcs "reader-*.c")
file (GLOB csreaders_hdrs "reader-*.h")
file (GLOB csoscam_srcs "oscam-*.c")
file (GLOB csoscam_hdrs "oscam-*.h")
file (GLOB exe_srcs "oscam.c")
file (GLOB exe_hdrs "globals.h")
file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
else (OSCamOperatingSystem MATCHES "Mac OS X")
file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
file (GLOB csreaders_srcs "reader-*.c")
file (GLOB csreaders_hdrs "reader-*.h")
file (GLOB csoscam_srcs "oscam-*.c" "${CMAKE_CURRENT_BINARY_DIR}/config.c")
file (GLOB csoscam_hdrs "oscam-*.h")
file (GLOB exe_srcs "oscam.c")
file (GLOB exe_hdrs "globals.h")
file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
endif (OSCamOperatingSystem MATCHES "Mac OS X")
#----------------------- modules ------------------------------
set (csmodules "csmodules")
add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
#----------------------- readers ------------------------------
set (csreaders "csreaders")
add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
#----------------------- other oscam files ------------------------------
set (csoscam "csoscam")
add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
#----------------------- the executable ------------------------------
set (exe_name "oscam")
add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt minilzo ffdecsa)
if(HAVE_LIBRT AND HAVE_LIBUSB)
if (LIBUSBDIR)
set (libusb_link "imp_libusb")
else(LIBUSBDIR)
if (STATICLIBUSB)
set (libusb_link "libusb-1.0.a")
else (STATICLIBUSB)
set (libusb_link "usb-1.0")
endif(STATICLIBUSB)
endif(LIBUSBDIR)
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
set (rt_link "rt")
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
set (setupapi_link "setupapi")
set (ole32_link "ole32")
set (shell32_link "shell32")
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
endif(HAVE_LIBRT AND HAVE_LIBUSB)
if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
if (LIBUSBDIR)
set (libusb_link "imp_libusb")
else(LIBUSBDIR)
if (STATICLIBUSB)
set (libusb_link "libusb-1.0.a")
else (STATICLIBUSB)
set (libusb_link "usb-1.0")
endif(STATICLIBUSB)
endif(LIBUSBDIR)
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
set (rt_link "imp_librt")
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
set (setupapi_link "setupapi")
set (ole32_link "ole32")
set (shell32_link "shell32")
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
if (HAVE_PTHREAD)
set (pthread_link "pthread")
endif (HAVE_PTHREAD)
if (WITH_SSL)
target_link_libraries (${exe_name} ssl)
endif (WITH_SSL)
if (HAVE_LIBCRYPTO)
target_link_libraries (${exe_name} crypto)
endif (HAVE_LIBCRYPTO)
# some systems need libm for the nagra cak7 functions to work
check_include_file("math.h" HAVE_LIBM)
if(HAVE_LIBM)
target_link_libraries (${exe_name} m)
endif(HAVE_LIBM)
if (HAVE_PCSC)
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
target_link_libraries (${exe_name} pcsclite)
endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
endif (HAVE_PCSC)
if (HAVE_LIBSTAPI)
target_link_libraries(${exe_name} stapilib)
endif (HAVE_LIBSTAPI)
if (HAVE_LIBSTAPI5)
target_link_libraries(${exe_name} stapi5lib)
endif (HAVE_LIBSTAPI5)
add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
#----------------------- specific options ------------------------------
if (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
target_link_libraries (${exe_name} rt)
endif (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
if (OSCamOperatingSystem MATCHES "Linux")
elseif (OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT HAVE_PCSC EQUAL 0)
FIND_LIBRARY (PCSC_LIBRARY PCSC)
message (STATUS "PCSC Mac OS X found : ${PCSC_LIBRARY}")
add_definitions ("-DWITH_PCSC=1")
target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
set (HAVE_PCSC True)
FIND_LIBRARY (IOKit_LIBRARY IOKit)
target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
else (NOT HAVE_PCSC EQUAL 0)
message (STATUS "PCSC Mac OS X not found no pcsc support")
endif (NOT HAVE_PCSC EQUAL 0)
elseif (OSCamOperatingSystem MATCHES "Tuxbox")
set (dl_link "dl")
elseif (OSCamOperatingSystem MATCHES "TripleDragon")
set (dl_link "dl")
elseif (OSCamOperatingSystem MATCHES "SlugOS")
elseif (OSCamOperatingSystem MATCHES "OpenWRT")
elseif (OSCamOperatingSystem MATCHES "Fonera2")
elseif (OSCamOperatingSystem MATCHES "DIR-825")
elseif (OSCamOperatingSystem MATCHES "agv2+w")
elseif (OSCamOperatingSystem MATCHES "WRT54G")
elseif (OSCamOperatingSystem MATCHES "Amino")
elseif (OSCamOperatingSystem MATCHES "QboxHD")
elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
message (STATUS "Windows system PCSC : winscard.dll")
target_link_libraries (${exe_name} winscard)
target_link_libraries (${exe_name} setupapi )
target_link_libraries (${exe_name} ole32)
target_link_libraries (${exe_name} shell32)
elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
target_link_libraries (${exe_name} rt nxp)
elseif (OSCamOperatingSystem MATCHES "NHD2")
target_link_libraries (${exe_name} lnxcssUsr lnxscsUsr lnxnotifyqUsr lnxUKAL lnxplatUsr rt)
elseif (OSCamOperatingSystem MATCHES "AZBox")
add_library(xcas STATIC IMPORTED)
set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/openxcas/libOpenXCASAPI.a)
set (xcas_link "xcas")
elseif (OSCamOperatingSystem MATCHES "SU980")
target_link_libraries (${exe_name} rt entropic)
endif (OSCamOperatingSystem MATCHES "Linux")
target_link_libraries (${exe_name} ${libusb_link} ${rt_link} ${setupapi_link} ${ole32_link} ${shell32_link} ${pthread_link} ${dl_link} ${xcas_link})
#----------------------- put svnversion in the build ------------------------------
# at every target rebuild, we re-build the oscam.c compilation...
# add the needed dependency
add_dependencies (${exe_name} svnversion)
add_dependencies (${csoscam} svnversion-log)
# how to re-build the files which printout the version
add_custom_target (
svnversion
ALL
touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
)
add_custom_target (
svnversion-log
ALL
touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
)
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND cut -d "+" -f4 COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SVN_VERSION)
add_definitions ("-D'CS_SVN_VERSION=\"${CS_SVN_VERSION}\"'")
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND cut -d "+" -f1-3 COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SMOD_VERSION)
add_definitions ("-D'CS_SMOD_VERSION=\"${CS_SMOD_VERSION}\"'")
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND cut -d "+" -f3 COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SMOD_VERSION_HASH)
add_definitions ("-D'CS_SMOD_VERSION_HASH=\"${CS_SMOD_VERSION_HASH}\"'")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine COMMAND tr -d '\n' OUTPUT_VARIABLE CS_TARGET)
add_definitions ("-D'CS_TARGET=\"${CS_TARGET}\"'")
#----------------------- global compile and link options ------------------------------
#enable sse2 on x86
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3")
endif (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
# disable warning about unused but set variables in gcc 4.6+
if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 0 GCC_MINOR)
add_definitions ("-W -Wall ")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -pipe -ffunction-sections -fdata-sections -funroll-loops -fomit-frame-pointer -fno-schedule-insns")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
endif (CMAKE_COMPILER_IS_GNUCC)
# some optimisations
if (OSCamOperatingSystem MATCHES "Mac OS X")
if (SWVER GREATER 10.6)
if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
else (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
add_definitions("-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
elseif(SWVER LESS 10.7)
add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
endif (SWVER GREATER 10.6)
endif (OSCamOperatingSystem MATCHES "Mac OS X")
# we don't want the '-rdynamic' in the link command
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
# we want to strip if not Debug build
if (OSCamOperatingSystem MATCHES "Mac OS X")
if (SWVER MATCHES "10.8")
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message (STATUS " building with debug")
set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
elseif (SWVER MATCHES "10.7")
if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message (STATUS " building with debug")
set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
else(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message (STATUS " building with debug")
set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
endif(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
elseif (SWVER MATCHES "10.6")
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message (STATUS " building with debug")
set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
endif (SWVER MATCHES "10.8")
else (OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set (CMAKE_EXE_LINKER_FLAGS "-s")
else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message (STATUS " building with debug")
set (CMAKE_EXE_LINKER_FLAGS "-ggdb")
endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
endif (OSCamOperatingSystem MATCHES "Mac OS X")
if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
#----------------------- subdirectory list smargo ------------------------------
if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
if (HAVE_LIBUSB)
add_subdirectory (utils)
endif (HAVE_LIBUSB)
endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
#-------------------------------------------------------------------------------
if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT DEFINED ENV{ANDROID_NDK})
if (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN})
if (WITH_SOFTCAM)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
execute_process (COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key)
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
execute_process (COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key)
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--format=binary -Wl,SoftCam.Key -Wl,--format=default")
endif (WITH_SOFTCAM)
endif (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN})
endif (NOT DEFINED ENV{ANDROID_NDK})
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
#----------------------- installation -----------------------------
file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
"${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
install (FILES ${config_files} DESTINATION etc COMPONENT config)
install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
#----------------------- we can use CPack to build pacakges --------------------------
# get version from source file
execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
OUTPUT_VARIABLE CS_VERSION)
string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
set (CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
# compute my filename
set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_TARGET}")
# wich archive we want to generate
set (CPACK_GENERATOR "TGZ")
# what to put in the archive
set (CPACK_STRIP_FILES TRUE)
set (CPACK_COMPONENTS_ALL bin)# config doc)
# ok, we can now use CPack
include (CPack)
#----------------------- printout resume -----------------------------
message (STATUS "")
message (STATUS " operating system: ${OSCamOperatingSystem}")
message (STATUS " target system: ${CS_TARGET}")
message (STATUS " revision: ${CS_SVN_VERSION}")
if (HAVE_LIBCRYPTO)
message (STATUS " use system libcrypto functions")
else (HAVE_LIBCRYPTO)
message (STATUS " use built-in crypt functions")
endif (HAVE_LIBCRYPTO)
if (HAVE_PCSC)
message (STATUS " use system pcsc functions")
endif (HAVE_PCSC)
if (HAVE_PTHREAD)
message (STATUS " use system pthread functions")
endif (HAVE_PTHREAD)
if (HAVE_LIBUSB)
if(STATIC_LIBUSB EQUAL 1)
message (STATUS " You selected to enable static libusb")
endif(STATIC_LIBUSB EQUAL 1)
if(STATICLIBUSB AND NOT LIBUSBDIR)
message (STATUS " use static libusb functions")
else(STATICLIBUSB AND NOT LIBUSBDIR)
if (LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
message(STATUS " use system libusb from selected LIBUSBDIR functions")
elseif (LIBUSBDIR AND STATIC_LIBUSB EQUAL 1)
message(STATUS " use static libusb from selected LIBUSBDIR functions")
elseif(LIBUSBDIR)
message(STATUS " use system libusb from selected LIBUSBDIR functions")
elseif(NOT LIBUSBDIR AND NOT STATIC_LIBUSB)
message (STATUS " use system libusb functions")
endif(LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
endif(STATICLIBUSB AND NOT LIBUSBDIR)
endif (HAVE_LIBUSB)
if (WITH_EMU)
message (STATUS " Compile with EMU support")
if (WITH_SOFTCAM)
message (STATUS " SoftCam.Key will be linked as well")
endif (WITH_SOFTCAM)
endif (WITH_EMU)
message (STATUS "")