source: trunk/CMakeLists.txt @ 11431

Last change on this file since 11431 was 11431, checked in by felixka, 12 months ago

[CMAKE]

  • some systems need libm for nagra cak7
  • patch provided by @caveman99
  • fix for ticket #4681
  • Property svn:eol-style set to LF
File size: 36.1 KB
Line 
1project (OSCam C)
2
3#----------------------- minimum version of cmake to use ------------
4
5# if you want to switch to 2.6 min, please look at the escaped definitions
6# later in this file (the add_definitions in 2.6 don't need to be escaped),
7# and remove the CMP0005 policy.
8# the CMP0003 could also be removed for cmake 2.6
9cmake_minimum_required (VERSION 2.4)
10if(COMMAND cmake_policy)
11    cmake_policy(SET CMP0005 OLD)
12    cmake_policy(SET CMP0003 NEW)
13endif(COMMAND cmake_policy)
14
15#----------------------- detect system ------------------------------
16
17if (CMAKE_CROSSCOMPILING)
18    if (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
19        set (OSCamOperatingSystem "Tuxbox")
20    elseif (OSCAM_SYSTEM_NAME MATCHES "TripleDragon")
21        set (OSCamOperatingSystem "TripleDragon")
22    elseif (OSCAM_SYSTEM_NAME MATCHES "Coolstream")
23        set (OSCamOperatingSystem "NeutrinoHD")
24    elseif (OSCAM_SYSTEM_NAME MATCHES "CST2")
25        set (OSCamOperatingSystem "NHD2")
26    elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
27        set (OSCamOperatingSystem "SlugOS")
28    elseif (OSCAM_SYSTEM_NAME MATCHES "WRT350NV2")
29        set (OSCamOperatingSystem "OpenWRT")
30        set (CS_OS_HW "wrt350nv2")
31    elseif (OSCAM_SYSTEM_NAME MATCHES "Dockstar")
32        set (OSCamOperatingSystem "OpenWRT")
33        set (CS_OS_HW "dockstar")
34    elseif (OSCAM_SYSTEM_NAME MATCHES "Fonera2")
35        set (OSCamOperatingSystem "Fonera2")
36    elseif (OSCAM_SYSTEM_NAME MATCHES "DIR-825")
37        set (OSCamOperatingSystem "DIR-825")
38    elseif (OSCAM_SYSTEM_NAME MATCHES "AZBox")
39        set (OSCamOperatingSystem "AZBox")
40    elseif (OSCAM_SYSTEM_NAME MATCHES "SU980")
41        set (OSCamOperatingSystem "SU980")
42    elseif (OSCAM_SYSTEM_NAME MATCHES "MCA")
43        set (OSCamOperatingSystem "MCA")
44    elseif (OSCAM_SYSTEM_NAME MATCHES "agv2+w")
45        set (OSCamOperatingSystem "agv2+w")
46    elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
47        set (OSCamOperatingSystem "WRT54G")
48    elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
49        set (OSCamOperatingSystem "Amino")
50    elseif (OSCAM_SYSTEM_NAME MATCHES "QboxHD")
51        set (OSCamOperatingSystem "QboxHD")
52    elseif (OSCAM_SYSTEM_NAME MATCHES "Padre")
53        set (OSCamOperatingSystem "Padre")
54    elseif (OSCAM_SYSTEM_NAME MATCHES "FriendlyARM")
55        set (OSCamOperatingSystem "FriendlyARM")
56    else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
57        message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
58        set (OSCamOperatingSystem "Unknown")
59    endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
60else (CMAKE_CROSSCOMPILING)
61    if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
62        set (OSCamOperatingSystem "Linux")
63    elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
64        set (OSCamOperatingSystem "FreeBSD")
65    elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
66        set (OSCamOperatingSystem "OpenBSD")
67    elseif (OSCamOperatingSystem MATCHES "Padre")
68        add_definitions ("-DPADRE -DSPARC")
69        set (DEFAULT_CS_CONFDIR "/etc/oscam")
70    elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
71        set (OSCamOperatingSystem "Mac OS X")
72    execute_process(COMMAND sw_vers -productVersion COMMAND cut -c 1-4 COMMAND tr -d '\n' OUTPUT_VARIABLE SWVER)
73    execute_process(COMMAND xcodebuild -version COMMAND grep Xcode COMMAND sed "s/Xcode\ //g" COMMAND tr -d '\n' OUTPUT_VARIABLE XCODEVER)
74    message (STATUS "mac sdk version is ${SWVER}")
75    message (STATUS "mac Xcode version is ${XCODEVER}")
76    add_definitions ("-w")
77    set (CMAKE_OSX_DEPLOYMENT_TARGET "${SWVER}")
78        if (SWVER GREATER 10.5)
79    set (CMAKE_OSX_ARCHITECTURES "x86_64")
80    endif (SWVER GREATER 10.5)
81    if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
82    message (STATUS "Compiling with xcode less then 4.3 on 10.7 If You have time update You're Xcode")
83    endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
84    set (STATIC_LIBUSB True)
85    elseif (${CYGWIN})
86        set (OSCamOperatingSystem "Windows/Cygwin")
87        set (CMAKE_SYSTEM_PROCESSOR "i386")
88    else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
89        message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
90        set (OSCamOperatingSystem "Unknown")
91    endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
92endif (CMAKE_CROSSCOMPILING)
93
94#----------------------- some paths ------------------------------
95
96set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
97set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
98
99if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
100include_directories (
101    ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
102    ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
103    ${CMAKE_CURRENT_SOURCE_DIR}/minilzo
104    ${CMAKE_CURRENT_SOURCE_DIR}/extapi/cygwin
105    /usr/include/w32api
106    ${OPTIONAL_INCLUDE_DIR}
107    )
108else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
109include_directories (
110    ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
111    ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
112    ${CMAKE_CURRENT_SOURCE_DIR}/minilzo
113    ${OPTIONAL_INCLUDE_DIR}
114    )
115endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
116
117if(OSCamOperatingSystem MATCHES "Windows/Cygwin")
118link_directories (
119    /usr/lib
120    /usr/lib/w32api
121    /cygdrive/c/WINDOWS/system32/
122    ${OPTIONAL_LINK_DIR}
123    )
124else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
125link_directories (
126    ${OPTIONAL_LINK_DIR}
127    )
128endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
129
130#----------------------- global options ------------------------------
131
132if (OSCamOperatingSystem MATCHES "Linux")
133    set (DEFAULT_CS_CONFDIR "/usr/local/etc")
134elseif (OSCamOperatingSystem MATCHES "Mac OS X")
135    if (NOT HAVE_PCSC EQUAL 0)
136    add_definitions ("-DWITH_PCSC=1")
137    endif (NOT HAVE_PCSC EQUAL 0)
138    set (DEFAULT_CS_CONFDIR "/usr/local/etc")
139elseif (OSCamOperatingSystem MATCHES "Tuxbox")
140    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
141elseif (OSCamOperatingSystem MATCHES "TripleDragon")
142    add_definitions ("-DSTB04SCI=1")
143    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
144elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
145    add_definitions ("-DWITH_COOLAPI=1")
146    set (USE_COOLAPI "USE_COOLAPI")
147    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
148elseif (OSCamOperatingSystem MATCHES "NHD2")
149    add_definitions ("-DWITH_COOLAPI2=1")
150    set (USE_COOLAPI2 "USE_COOLAPI2")
151    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
152elseif (OSCamOperatingSystem MATCHES "SlugOS")
153    set (DEFAULT_CS_CONFDIR "/var/etc")
154elseif (OSCamOperatingSystem MATCHES "OpenWRT")
155    if (CS_OS_HW MATCHES "wrt350nv2")
156        set (DEFAULT_CS_CONFDIR "/etc/oscam")
157    elseif (CS_OS_HW MATCHES "dockstar")
158        set (DEFAULT_CS_CONFDIR "/usr/oscam")
159    endif (CS_OS_HW MATCHES "wrt350nv2")
160elseif (OSCamOperatingSystem MATCHES "Fonera2")
161    set (DEFAULT_CS_CONFDIR "/var/etc")
162elseif (OSCamOperatingSystem MATCHES "DIR-825")
163    set (DEFAULT_CS_CONFDIR "/var/etc")
164elseif (OSCamOperatingSystem MATCHES "AZBox")
165    add_definitions ("-DWITH_AZBOX=1")
166    set (USE_AZBOX "USE_AZBOX")
167    set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/oscamCAS")
168elseif (OSCamOperatingSystem MATCHES "SU980")
169    set (USE_SU980 "USE_SU980")
170    add_definitions ("-DWITH_SU980=1")
171    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
172elseif (OSCamOperatingSystem MATCHES "MCA")
173    add_definitions ("-DWITH_MCA=1")
174    set (USE_MCA "USE_MCA")
175    set (DEFAULT_CS_CONFDIR "/var/mca/d1")
176elseif (OSCamOperatingSystem MATCHES "agv2+w")
177    set (DEFAULT_CS_CONFDIR "/etc")
178elseif (OSCamOperatingSystem MATCHES "WRT54G")
179    set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
180elseif (OSCamOperatingSystem MATCHES "Amino")
181    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
182elseif (OSCamOperatingSystem MATCHES "QboxHD")
183    add_definitions ("-DQBOXHD=1")
184    set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
185elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
186    add_definitions ("-static -DWITH_PCSC=1")
187    set (DEFAULT_CS_CONFDIR ".")
188elseif (OSCamOperatingSystem MATCHES "FreeBSD")
189    add_definitions ("-I/usr/local/include -L/usr/local/lib")
190    set (DEFAULT_CS_CONFDIR ".")
191elseif (OSCamOperatingSystem MATCHES "OpenBSD")
192    add_definitions ("-I/usr/local/include -L/usr/local/lib")
193    set (DEFAULT_CS_CONFDIR "/etc/oscam")
194elseif (OSCamOperatingSystem MATCHES "FriendlyARM")
195    set (DEFAULT_CS_CONFDIR ".")
196endif (OSCamOperatingSystem MATCHES "Linux")
197
198set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
199add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
200
201
202#----------------------- subdirectories ------------------------------
203
204include (CheckIncludeFile)
205
206check_include_file ("pthread.h" HAVE_PTHREAD)
207if (HAVE_PTHREAD)
208    message(STATUS "  pthread found. Adding pthread support ")
209    add_definitions ("-DHAVE_PTHREAD_H")
210elseif (HAVE_PTHREAD)
211    message(STATUS "  no pthread found. No smartreader ")
212endif (HAVE_PTHREAD)
213
214check_include_file ("openssl/aes.h" HAVE_LIBCRYPTO)
215if (HAVE_LIBCRYPTO)
216    add_definitions ("-DWITH_LIBCRYPTO=1")
217    set (USE_LIBCRYPTO "USE_LIBCRYPTO")
218else (HAVE_LIBCRYPTO)
219    message (STATUS " LIBCRYTO NOT FOUND OR DISABLED NO SSL SUPPORT POSSIBLE")
220endif (HAVE_LIBCRYPTO)
221
222execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SSL OUTPUT_VARIABLE CONFIG_WITH_SSL OUTPUT_STRIP_TRAILING_WHITESPACE)
223if (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
224    message ( STATUS " ssl is added by You compiling with ssl included")
225elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 1)
226    message (STATUS " ssl is added by You but it was already enabled by config file")
227elseif (CONFIG_WITH_SSL MATCHES "N" AND NOT WITH_SSL EQUAL 1)
228    message (STATUS " SSL IS NOT INCLUDED IN THIS COMPILATION")
229endif (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
230
231if (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0)
232    message(status "  SSL is added by config file ${CONFIG_WITH_SSL} compiling with ssl included")
233    add_definitions ("-DWITH_SSL")
234    set (WITH_SSL "1")
235elseif (CONFIG_WITH_SSL MATCHES "Y" AND WITH_SSL EQUAL 0)
236    message (status  " The config file has ssl enabled, but You disabled it by you cmake command COMPILING WHITOUT SSL")
237endif (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0)
238
239find_package(OpenSSL)
240if (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
241    include_directories(${OPENSSL_INCLUDE_DIR})
242    message(STATUS "  openssl found.")
243    if (WITH_SSL EQUAL 1)
244    set(USE_SSL "USE_SSL")
245    endif (WITH_SSL EQUAL 1)
246else (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
247    message(STATUS "SSL REQUESTED BUT OPENSSL or LYBCRYPTO NOT FOUND !!")
248    if (WITH_SSL)
249        message(STATUS " ssl support requested but openssl or libcrypto NOT FOUND  COMPILING WHITOUT SSL !!! ")
250    set (WITH_SSL "0")
251    endif (WITH_SSL)
252endif (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
253
254if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
255   if (LIBRTDIR)
256        check_include_file ("${LIBRTDIR}/include/time.h" HAVE_LIBRT_STATIC)
257        if (HAVE_LIBRT_STATIC)
258            if (EXISTS ${LIBRTDIR}/lib/librt.a)
259                message(STATUS "  static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).")
260                add_definitions ("-I${LIBRTDIR}/include/")
261                add_library(imp_librt STATIC IMPORTED)
262                set_property(TARGET imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a)
263            else (EXISTS ${LIBRTDIR}/lib/librt.a)
264                message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb). No smartreader support)")
265                set (HAVE_LIBRT_STATIC False)
266            endif (EXISTS ${LIBRTDIR}/lib/librt.a)
267        else (HAVE_LIBRT_STATIC)
268            message(STATUS "  no librt found (needed by libusb). No smartreader support")
269        endif (HAVE_LIBRT_STATIC)
270    else (LIBRTDIR)
271        check_include_file ("time.h" HAVE_LIBRT)
272        if (HAVE_LIBRT)
273            message(STATUS "  librt found (needed by libusb).")
274        else (HAVE_LIBRT)
275            message(STATUS "  no librt found (needed by libusb. No smartreader support")
276        endif (HAVE_LIBRT)
277    endif (LIBRTDIR)
278    if (WITH_STAPI)
279            if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
280                message(STATUS "  liboscam_stapi.a found")
281                add_definitions ("-DWITH_STAPI=1")
282            add_library(stapilib STATIC IMPORTED)
283                set_property(TARGET stapilib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
284                set (HAVE_LIBSTAPI True)
285            set (USE_STAPI "USE_STAPI")
286            else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
287                message(FATAL "  liboscam_stapi.a support requested but not found! ")
288                set (HAVE_LIBSTAPI False)
289            endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi.a)
290    endif (WITH_STAPI)
291    if (WITH_STAPI5)
292            if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
293                message(STATUS "  liboscam_stapi5.a found")
294                add_definitions ("-DWITH_STAPI5=1")
295            add_library(stapi5lib STATIC IMPORTED)
296                set_property(TARGET stapi5lib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
297                set (HAVE_LIBSTAPI5 True)
298            set (USE_STAPI5 "USE_STAPI5")
299            else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
300                message(FATAL "  liboscam_stapi5.a support requested but not found! ")
301                set (HAVE_LIBSTAPI5 False)
302            endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stapi/liboscam_stapi5.a)
303    endif (WITH_STAPI5)
304else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
305    set (HAVE_LIBRT True)
306endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
307
308
309if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
310    if (LIBUSBDIR)
311        check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB)
312    if (HAVE_LIBUSB AND HAVE_PTHREAD)
313            if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
314        if (STATIC_LIBUSB EQUAL 1)
315                message(STATUS "  libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ")
316                add_definitions ("-DWITH_LIBUSB=1")
317                add_definitions ("-I${LIBUSBDIR}/include/")
318        set (LIBUSB "USE_LIBUSB")
319                add_library(imp_libusb STATIC IMPORTED)
320                set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a)
321        elseif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
322        set (CMAKE_FIND_ROOT_PATH ${LIBUSBDIR})
323        find_library (LIBUSB_LIBRARY NAMES usb-1.0)
324        message(STATUS "libusb 1.0 found (${LIBUSB_LIBRARY}). Adding smartreader support ")
325                add_definitions ("-DWITH_LIBUSB=1")
326                add_definitions ("-I${LIBUSBDIR}/include/")
327        set (LIBUSB "USE_LIBUSB")
328                add_library(imp_libusb SHARED IMPORTED)
329                set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSB_LIBRARY} )
330        endif (STATIC_LIBUSB EQUAL 1)
331            else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
332                message(STATUS "  libusb 1.0 not found (${LIBUSBDIR}/lib/libusb). No smartreader support ")
333                set (HAVE_LIBUSB False)
334                set (HAVE_LIBRT False)
335                set (HAVE_LIBRT_STATIC False)
336            endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
337        else (HAVE_LIBUSB AND HAVE_PTHREAD)
338            message(STATUS "  no libusb 1.0 found. No smartreader support")
339                set (HAVE_LIBUSB False)
340                set (HAVE_LIBRT False)
341                set (HAVE_LIBRT_STATIC False)
342        endif (HAVE_LIBUSB AND HAVE_PTHREAD)
343    else (LIBUSBDIR)
344    if (NOT HAVE_LIBUSB EQUAL 0)
345        check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB)
346        check_include_file ("libusb-1.0/libusb.h" PRESENT)
347    endif(NOT HAVE_LIBUSB EQUAL 0)
348    if (OSCamOperatingSystem MATCHES "Mac OS X")
349      if (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT)
350       find_file (USBINCL_LOC "libusb-1.0/libusb.h")
351       if (EXISTS ${USBINCL_LOC})
352        add_definitions ("-I/usr/local/include -L/usr/local/lib -I/usr/include -L/usr/lib")
353        set (HAVE_LIBUSB True)
354        set (PRESENT True)
355        set (USE_LIBUSB "USE_LIBUSB")
356            if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
357        set (STATICLIBUSB False)
358        elseif (STATIC_LIBUSB EQUAL 1)
359        set (STATICLIBUSB True)
360        endif (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
361       endif (EXISTS ${USBINCL_LOC})
362      endif (NOT HAVE_LIBUSB EQUAL 0 AND NOT PRESENT)
363    endif (OSCamOperatingSystem MATCHES "Mac OS X")
364    if (NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
365        if(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
366                   message(STATUS " libusb 1.0 found (libusb-1.0.so) Adding smartreader support ")
367                   add_definitions ("-DWITH_LIBUSB=1")
368           set (USE_LIBUSB "USE_LIBUSB")
369           set (STATICLIBUSB False)
370        endif(HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
371    elseif(STATIC_LIBUSB EQUAL 1)
372          if (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)             
373                message(STATUS "  static libusb 1.0 found (libusb-1.0.a). Adding smartreader support ")
374                add_definitions ("-DWITH_LIBUSB=1")
375        set (USE_LIBUSB "USE_LIBUSB")
376        set (STATICLIBUSB True)
377          else (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
378            message(STATUS "  no libusb 1.0 found. No smartreader support")
379        set (HAVE_LIBUSB False)
380          endif (HAVE_LIBUSB AND HAVE_PTHREAD AND PRESENT)
381    endif(NOT STATIC_LIBUSB OR STATIC_LIBUSB EQUAL 0)
382    endif (LIBUSBDIR)
383endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
384
385check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
386if (HAVE_PCSC)
387    FIND_PATH (PCSC_PATH PCSC/wintypes.h)
388    if(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
389    message(STATUS "  PCSC headers found (${OPTIONAL_INCLUDE_DIR}/PCSC). Adding PCSC support ")
390    add_definitions ("-DWITH_PCSC=1")
391    add_definitions ("-I${OPTIONAL_INCLUDE_DIR}/PCSC")
392    set (USE_PCSC "USE_PCSC")
393    elseif (EXISTS ${PCSC_PATH}/PCSC/wintypes.h AND NOT OPTIONAL_INCLUDE_DIR)
394        message(STATUS "  PCSC headers found (${PCSC_PATH}/PCSC). Adding PCSC support ")
395        add_definitions ("-DWITH_PCSC=1")
396        add_definitions ("-I${PCSC_PATH}/PCSC")
397    set (USE_PCSC "USE_PCSC")
398    else (OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
399    if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
400        set (HAVE_PCSC False)
401        if(OPTIONAL_INCLUDE_DIR)
402            message(STATUS "  PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC or ${OPTIONAL_INCLUDE_DIR}/PCSC). No PCSC support ")
403        else(OPTIONAL_INCLUDE_DIR)
404            message(STATUS "  PCSC headers not found (not in /usr/include/PCSC or /usr/local/include/PCSC). No PCSC support ")
405        endif(OPTIONAL_INCLUDE_DIR)
406    endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
407    endif(OPTIONAL_INCLUDE_DIR AND EXISTS ${OPTIONAL_INCLUDE_DIR}/PCSC/wintypes.h)
408    if (OSCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0)
409    set (USE_PCSC "USE_PCSC")
410    set (HAVE_PCSC "1")
411    endif (OSCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0)
412else (HAVE_PCSC)
413if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
414    add_definitions ("-Icygwin")
415    set (HAVE_PCSC "1")
416    set (USE_PCSC "USE_PCSC")
417endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
418endif (HAVE_PCSC)
419
420# Manage config.h based on command line parameters
421# Manipulate config file based on given parameters and read unset parameters
422
423execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --show-valid OUTPUT_VARIABLE config_vars_string OUTPUT_STRIP_TRAILING_WHITESPACE)
424string(REGEX MATCHALL "[A-Z0-9_]+" config_vars ${config_vars_string})
425
426MACRO(GENERATE_OSCAM_CONFIG fullpath)
427    foreach(option ${config_vars})
428        if(DEFINED ${option})
429            if(${option})
430                execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enable ${option})
431            else(${option})
432                execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --disable ${option})
433            endif(${option})
434        endif(DEFINED ${option})
435    endforeach(option)
436ENDMACRO(GENERATE_OSCAM_CONFIG fullpath)
437
438GENERATE_OSCAM_CONFIG("${CMAKE_CURRENT_SOURCE_DIR}/config.h")
439
440# Build config.mak and related files
441# FIXME: Create USE_FLAGS and pass them to config.sh using --use-flags
442execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --objdir ${CMAKE_CURRENT_BINARY_DIR} --use-flags  "${USE_STAPI} ${USE_STAPI5} /
443${USE_COOLAPI} ${USE_SU980} ${USE_AZBOX} ${USE_MCA} ${USE_SSL} ${USE_LIBCRYPTO} ${USE_LIBUSB} ${USE_PCSC}" --make-config.mak)
444# Generate webif/pages.c
445execute_process (COMMAND make --no-print-directory --quiet -C ${CMAKE_CURRENT_SOURCE_DIR}/webif)
446
447#----------------------- subdirectories ------------------------------
448
449add_subdirectory (csctapi)
450add_subdirectory (minilzo)
451add_subdirectory (cscrypt)
452
453#----------------------- file groups ------------------------------
454execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled MODULE_CAMD33 OUTPUT_VARIABLE CAMD33 OUTPUT_STRIP_TRAILING_WHITESPACE)
455if (CAMD33 MATCHES "N")
456set (CAMD_33 "module-camd33*")
457endif (CAMD33 MATCHES "N")
458if (OSCamOperatingSystem MATCHES "Mac OS X")
459file (GLOB csmodules_mac  "module-dvbapi*" "module-lcd*" "${CAMD_33}")
460file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
461list (REMOVE_ITEM csmodules_srcs ${csmodules_mac})
462file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
463list (REMOVE_ITEM csmodules_hdrs ${csmodules_mac})
464file (GLOB csreaders_srcs "reader-*.c")
465file (GLOB csreaders_hdrs "reader-*.h")
466file (GLOB csoscam_srcs "oscam-*.c")
467file (GLOB csoscam_hdrs "oscam-*.h")
468file (GLOB exe_srcs "oscam.c")
469file (GLOB exe_hdrs "globals.h")
470file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
471else (OSCamOperatingSystem MATCHES "Mac OS X")
472file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
473file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
474file (GLOB csreaders_srcs "reader-*.c")
475file (GLOB csreaders_hdrs "reader-*.h")
476file (GLOB csoscam_srcs "oscam-*.c" "${CMAKE_CURRENT_BINARY_DIR}/config.c")
477file (GLOB csoscam_hdrs "oscam-*.h")
478file (GLOB exe_srcs "oscam.c")
479file (GLOB exe_hdrs "globals.h")
480file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
481endif (OSCamOperatingSystem MATCHES "Mac OS X")
482#----------------------- modules ------------------------------
483
484set (csmodules "csmodules")
485add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
486
487#----------------------- readers ------------------------------
488
489set (csreaders "csreaders")
490add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
491
492#----------------------- other oscam files ------------------------------
493
494set (csoscam "csoscam")
495add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
496
497#----------------------- the executable ------------------------------
498
499set (exe_name "oscam")
500add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
501target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt minilzo)
502if(HAVE_LIBRT AND HAVE_LIBUSB)
503   if (LIBUSBDIR)
504    set (libusb_link "imp_libusb")
505   else(LIBUSBDIR)
506    if (STATICLIBUSB)
507    set (libusb_link "libusb-1.0.a")
508    else (STATICLIBUSB)
509    set (libusb_link "usb-1.0")
510    endif(STATICLIBUSB)
511   endif(LIBUSBDIR)
512    if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
513    set (rt_link "rt")
514    endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
515    if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
516    set (setupapi_link "setupapi")
517    set (ole32_link "ole32")
518    set (shell32_link "shell32")
519    endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
520endif(HAVE_LIBRT AND HAVE_LIBUSB)
521
522if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
523   if (LIBUSBDIR)
524    set (libusb_link "imp_libusb")
525   else(LIBUSBDIR)
526    if (STATICLIBUSB)
527    set (libusb_link "libusb-1.0.a")
528    else (STATICLIBUSB)
529    set (libusb_link "usb-1.0")
530    endif(STATICLIBUSB)
531   endif(LIBUSBDIR)
532    if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
533        set (rt_link "imp_librt")
534    endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
535    if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
536    set (setupapi_link "setupapi")
537    set (ole32_link "ole32")
538    set (shell32_link "shell32")
539    endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
540endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
541
542if (HAVE_PTHREAD)
543    set (pthread_link "pthread")
544endif (HAVE_PTHREAD)
545
546if (WITH_SSL)
547    target_link_libraries (${exe_name} ssl)
548endif (WITH_SSL)
549
550if (HAVE_LIBCRYPTO)
551    target_link_libraries (${exe_name} crypto)
552endif (HAVE_LIBCRYPTO)
553
554# some systems need libm for the nagra cak7 functions to work
555check_include_file("math.h" HAVE_LIBM)
556if(HAVE_LIBM)
557    target_link_libraries (${exe_name} m)
558endif(HAVE_LIBM)
559
560if (HAVE_PCSC)
561if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
562if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
563    target_link_libraries (${exe_name} pcsclite)
564endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
565endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
566endif (HAVE_PCSC)
567
568if (HAVE_LIBSTAPI)
569    target_link_libraries(${exe_name} stapilib)
570endif (HAVE_LIBSTAPI)
571
572if (HAVE_LIBSTAPI5)
573    target_link_libraries(${exe_name} stapi5lib)
574endif (HAVE_LIBSTAPI5)
575
576add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
577
578#----------------------- specific options ------------------------------
579
580if (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
581    target_link_libraries (${exe_name} rt)
582endif (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
583
584if (OSCamOperatingSystem MATCHES "Linux")
585elseif (OSCamOperatingSystem MATCHES "Mac OS X")
586    if (NOT HAVE_PCSC EQUAL 0)
587    FIND_LIBRARY (PCSC_LIBRARY PCSC)
588    message (STATUS "PCSC Mac OS X found : ${PCSC_LIBRARY}")
589    add_definitions ("-DWITH_PCSC=1")
590    target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
591    set (HAVE_PCSC True)
592    FIND_LIBRARY (IOKit_LIBRARY IOKit)
593    target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
594    FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
595    target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
596    else (NOT HAVE_PCSC EQUAL 0)
597    message (STATUS "PCSC Mac OS X not found no pcsc support")
598    endif (NOT HAVE_PCSC EQUAL 0)
599elseif (OSCamOperatingSystem MATCHES "Tuxbox")
600    set (dl_link "dl")
601elseif (OSCamOperatingSystem MATCHES "TripleDragon")
602    set (dl_link "dl")
603elseif (OSCamOperatingSystem MATCHES "SlugOS")
604elseif (OSCamOperatingSystem MATCHES "OpenWRT")
605elseif (OSCamOperatingSystem MATCHES "Fonera2")
606elseif (OSCamOperatingSystem MATCHES "DIR-825")
607elseif (OSCamOperatingSystem MATCHES "agv2+w")
608elseif (OSCamOperatingSystem MATCHES "WRT54G")
609elseif (OSCamOperatingSystem MATCHES "Amino")
610elseif (OSCamOperatingSystem MATCHES "QboxHD")
611elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
612    message (STATUS "Windows system PCSC : winscard.dll")
613    target_link_libraries (${exe_name} winscard)
614    target_link_libraries (${exe_name} setupapi )
615    target_link_libraries (${exe_name} ole32)
616    target_link_libraries (${exe_name} shell32)
617elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
618    target_link_libraries (${exe_name} rt nxp)
619elseif (OSCamOperatingSystem MATCHES "NHD2")
620    target_link_libraries (${exe_name} lnxcssUsr lnxscsUsr lnxnotifyqUsr lnxUKAL lnxplatUsr rt)
621elseif (OSCamOperatingSystem MATCHES "AZBox")
622    add_library(xcas STATIC IMPORTED)
623    set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/openxcas/libOpenXCASAPI.a)
624    set (xcas_link "xcas")
625elseif (OSCamOperatingSystem MATCHES "SU980")
626    target_link_libraries (${exe_name} rt entropic)
627endif (OSCamOperatingSystem MATCHES "Linux")
628
629target_link_libraries (${exe_name} ${libusb_link} ${rt_link} ${setupapi_link} ${ole32_link} ${shell32_link} ${pthread_link} ${dl_link} ${xcas_link})
630
631#----------------------- put svnversion in the build ------------------------------
632# at every target rebuild, we re-build the oscam.c compilation...
633
634# add the needed dependency
635add_dependencies (${exe_name} svnversion)
636add_dependencies (${csoscam} svnversion-log)
637
638# how to re-build the files which printout the version
639add_custom_target (
640    svnversion
641    ALL
642    touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
643)
644add_custom_target (
645    svnversion-log
646    ALL
647    touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
648)
649
650execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SVN_VERSION)
651add_definitions ("-D'CS_SVN_VERSION=\"${CS_SVN_VERSION}\"'")
652
653execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine COMMAND tr -d '\n' OUTPUT_VARIABLE CS_TARGET)
654add_definitions ("-D'CS_TARGET=\"${CS_TARGET}\"'")
655#----------------------- global compile and link options ------------------------------
656# disable warning about unused but set variables in gcc 4.6+
657if (CMAKE_COMPILER_IS_GNUCC)
658    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
659    string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
660    list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
661    list(GET GCC_VERSION_COMPONENTS 0 GCC_MINOR)
662    add_definitions ("-W -Wall ")
663    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
664    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
665    set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
666    set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
667endif (CMAKE_COMPILER_IS_GNUCC)
668# some optimisations
669if (OSCamOperatingSystem MATCHES "Mac OS X")
670  if (SWVER GREATER 10.6)
671   if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
672    add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
673   else (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
674    add_definitions("-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
675   endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
676  elseif(SWVER LESS 10.7)
677    add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
678  endif (SWVER GREATER 10.6)
679endif (OSCamOperatingSystem MATCHES "Mac OS X")
680
681# we don't want the '-rdynamic' in the link command
682set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
683
684# we want to strip if not Debug build
685if (OSCamOperatingSystem MATCHES "Mac OS X")
686 if (SWVER MATCHES "10.8")
687  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
688    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
689  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
690    message (STATUS "  building with debug")
691    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
692  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
693 elseif (SWVER MATCHES "10.7")
694  if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
695   if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
696    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
697   else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
698    message (STATUS "  building with debug")
699    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
700   endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
701  else(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
702   if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
703    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
704   else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
705    message (STATUS "  building with debug")
706    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
707   endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
708  endif(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
709 elseif (SWVER MATCHES "10.6")
710  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
711    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
712  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
713    message (STATUS "  building with debug")
714    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
715  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
716 endif (SWVER MATCHES "10.8")
717else (OSCamOperatingSystem MATCHES "Mac OS X")
718  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
719    set (CMAKE_EXE_LINKER_FLAGS "-s")
720  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
721    message (STATUS "  building with debug")
722    set (CMAKE_EXE_LINKER_FLAGS "-ggdb")
723  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
724endif (OSCamOperatingSystem MATCHES "Mac OS X")
725
726if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
727    set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
728endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
729
730#----------------------- subdirectory list smargo ------------------------------
731
732if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
733    if (HAVE_LIBUSB)
734        add_subdirectory (utils)
735    endif (HAVE_LIBUSB)
736endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
737
738#--------------------------------------------------------------------------------
739
740#----------------------- installation -----------------------------
741
742file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
743file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
744file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
745file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
746file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
747                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
748                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
749                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
750                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
751                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
752                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
753                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
754                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
755file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
756                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
757
758install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
759install (FILES ${config_files} DESTINATION etc COMPONENT config)
760install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
761install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
762install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
763install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
764install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
765
766#----------------------- we can use CPack to build pacakges --------------------------
767
768# get version from source file
769execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
770    OUTPUT_VARIABLE CS_VERSION)
771string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
772string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
773string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
774string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
775set (CPACK_PACKAGE_VERSION
776     "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
777
778# compute my filename
779set (CPACK_PACKAGE_FILE_NAME
780     "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_TARGET}")
781
782# wich archive we want to generate
783set (CPACK_GENERATOR "TGZ")
784
785# what to put in the archive
786set (CPACK_STRIP_FILES TRUE)
787set (CPACK_COMPONENTS_ALL bin)# config doc)
788
789# ok, we can now use CPack
790include (CPack)
791
792#----------------------- printout resume -----------------------------
793
794message (STATUS "")
795message (STATUS "  operating system: ${OSCamOperatingSystem}")
796message (STATUS "  target system: ${CS_TARGET}")
797message (STATUS "  revision: ${CS_SVN_VERSION}")
798if (HAVE_LIBCRYPTO)
799    message (STATUS "  use system libcrypto functions")
800else (HAVE_LIBCRYPTO)
801    message (STATUS "  use built-in crypt functions")
802endif (HAVE_LIBCRYPTO)
803if (HAVE_PCSC)
804    message (STATUS "  use system pcsc functions")
805endif (HAVE_PCSC)
806if (HAVE_PTHREAD)
807    message (STATUS "  use system pthread functions")
808endif (HAVE_PTHREAD)
809if (HAVE_LIBUSB)
810if(STATIC_LIBUSB EQUAL 1)
811   message (STATUS "  You selected to enable static libusb")
812endif(STATIC_LIBUSB EQUAL 1)
813 if(STATICLIBUSB AND NOT LIBUSBDIR)
814    message (STATUS "  use static libusb functions")
815 else(STATICLIBUSB AND NOT LIBUSBDIR)
816   if (LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
817      message(STATUS "  use system libusb from selected LIBUSBDIR functions")
818   elseif (LIBUSBDIR AND STATIC_LIBUSB EQUAL 1)
819      message(STATUS "  use static libusb from selected LIBUSBDIR functions")
820   elseif(LIBUSBDIR)
821      message(STATUS " use system libusb from selected LIBUSBDIR functions")
822   elseif(NOT LIBUSBDIR AND NOT STATIC_LIBUSB)
823       message (STATUS "  use system libusb functions")
824   endif(LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
825 endif(STATICLIBUSB AND NOT LIBUSBDIR)
826endif (HAVE_LIBUSB)
827
828message (STATUS "")
Note: See TracBrowser for help on using the repository browser.