source: trunk/CMakeLists.txt @ 11256

Last change on this file since 11256 was 11256, checked in by Aeon, 3 years ago

Added fixes for OpenBSD

  • Property svn:eol-style set to LF
File size: 35.9 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
554if (HAVE_PCSC)
555if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
556if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
557    target_link_libraries (${exe_name} pcsclite)
558endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
559endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
560endif (HAVE_PCSC)
561
562if (HAVE_LIBSTAPI)
563    target_link_libraries(${exe_name} stapilib)
564endif (HAVE_LIBSTAPI)
565
566if (HAVE_LIBSTAPI5)
567    target_link_libraries(${exe_name} stapi5lib)
568endif (HAVE_LIBSTAPI5)
569
570add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
571
572#----------------------- specific options ------------------------------
573
574if (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
575    target_link_libraries (${exe_name} rt)
576endif (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
577
578if (OSCamOperatingSystem MATCHES "Linux")
579elseif (OSCamOperatingSystem MATCHES "Mac OS X")
580    if (NOT HAVE_PCSC EQUAL 0)
581    FIND_LIBRARY (PCSC_LIBRARY PCSC)
582    message (STATUS "PCSC Mac OS X found : ${PCSC_LIBRARY}")
583    add_definitions ("-DWITH_PCSC=1")
584    target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
585    set (HAVE_PCSC True)
586    FIND_LIBRARY (IOKit_LIBRARY IOKit)
587    target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
588    FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
589    target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
590    else (NOT HAVE_PCSC EQUAL 0)
591    message (STATUS "PCSC Mac OS X not found no pcsc support")
592    endif (NOT HAVE_PCSC EQUAL 0)
593elseif (OSCamOperatingSystem MATCHES "Tuxbox")
594    set (dl_link "dl")
595elseif (OSCamOperatingSystem MATCHES "TripleDragon")
596    set (dl_link "dl")
597elseif (OSCamOperatingSystem MATCHES "SlugOS")
598elseif (OSCamOperatingSystem MATCHES "OpenWRT")
599elseif (OSCamOperatingSystem MATCHES "Fonera2")
600elseif (OSCamOperatingSystem MATCHES "DIR-825")
601elseif (OSCamOperatingSystem MATCHES "agv2+w")
602elseif (OSCamOperatingSystem MATCHES "WRT54G")
603elseif (OSCamOperatingSystem MATCHES "Amino")
604elseif (OSCamOperatingSystem MATCHES "QboxHD")
605elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
606    message (STATUS "Windows system PCSC : winscard.dll")
607    target_link_libraries (${exe_name} winscard)
608    target_link_libraries (${exe_name} setupapi )
609    target_link_libraries (${exe_name} ole32)
610    target_link_libraries (${exe_name} shell32)
611elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
612    target_link_libraries (${exe_name} rt nxp)
613elseif (OSCamOperatingSystem MATCHES "NHD2")
614    target_link_libraries (${exe_name} lnxcssUsr lnxscsUsr lnxnotifyqUsr lnxUKAL lnxplatUsr rt)
615elseif (OSCamOperatingSystem MATCHES "AZBox")
616    add_library(xcas STATIC IMPORTED)
617    set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/openxcas/libOpenXCASAPI.a)
618    set (xcas_link "xcas")
619elseif (OSCamOperatingSystem MATCHES "SU980")
620    target_link_libraries (${exe_name} rt entropic)
621endif (OSCamOperatingSystem MATCHES "Linux")
622
623target_link_libraries (${exe_name} ${libusb_link} ${rt_link} ${setupapi_link} ${ole32_link} ${shell32_link} ${pthread_link} ${dl_link} ${xcas_link})
624
625#----------------------- put svnversion in the build ------------------------------
626# at every target rebuild, we re-build the oscam.c compilation...
627
628# add the needed dependency
629add_dependencies (${exe_name} svnversion)
630add_dependencies (${csoscam} svnversion-log)
631
632# how to re-build the files which printout the version
633add_custom_target (
634    svnversion
635    ALL
636    touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
637)
638add_custom_target (
639    svnversion-log
640    ALL
641    touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
642)
643
644execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SVN_VERSION)
645add_definitions ("-D'CS_SVN_VERSION=\"${CS_SVN_VERSION}\"'")
646
647execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine COMMAND tr -d '\n' OUTPUT_VARIABLE CS_TARGET)
648add_definitions ("-D'CS_TARGET=\"${CS_TARGET}\"'")
649#----------------------- global compile and link options ------------------------------
650# disable warning about unused but set variables in gcc 4.6+
651if (CMAKE_COMPILER_IS_GNUCC)
652    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
653    string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
654    list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
655    list(GET GCC_VERSION_COMPONENTS 0 GCC_MINOR)
656    add_definitions ("-W -Wall ")
657    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
658    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
659    set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
660    set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
661endif (CMAKE_COMPILER_IS_GNUCC)
662# some optimisations
663if (OSCamOperatingSystem MATCHES "Mac OS X")
664  if (SWVER GREATER 10.6)
665   if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
666    add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
667   else (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
668    add_definitions("-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
669   endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
670  elseif(SWVER LESS 10.7)
671    add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
672  endif (SWVER GREATER 10.6)
673endif (OSCamOperatingSystem MATCHES "Mac OS X")
674
675# we don't want the '-rdynamic' in the link command
676set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
677
678# we want to strip if not Debug build
679if (OSCamOperatingSystem MATCHES "Mac OS X")
680 if (SWVER MATCHES "10.8")
681  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
682    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
683  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
684    message (STATUS "  building with debug")
685    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
686  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
687 elseif (SWVER MATCHES "10.7")
688  if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
689   if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
690    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
691   else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
692    message (STATUS "  building with debug")
693    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
694   endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
695  else(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
696   if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
697    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
698   else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
699    message (STATUS "  building with debug")
700    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
701   endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
702  endif(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
703 elseif (SWVER MATCHES "10.6")
704  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
705    set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
706  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
707    message (STATUS "  building with debug")
708    set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
709  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
710 endif (SWVER MATCHES "10.8")
711else (OSCamOperatingSystem MATCHES "Mac OS X")
712  if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
713    set (CMAKE_EXE_LINKER_FLAGS "-s")
714  else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
715    message (STATUS "  building with debug")
716    set (CMAKE_EXE_LINKER_FLAGS "-ggdb")
717  endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
718endif (OSCamOperatingSystem MATCHES "Mac OS X")
719
720if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
721    set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
722endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
723
724#----------------------- subdirectory list smargo ------------------------------
725
726if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
727    if (HAVE_LIBUSB)
728        add_subdirectory (utils)
729    endif (HAVE_LIBUSB)
730endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
731
732#--------------------------------------------------------------------------------
733
734#----------------------- installation -----------------------------
735
736file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
737file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
738file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
739file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
740file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
741                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
742                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
743                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
744                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
745                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
746                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
747                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
748                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
749file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
750                         "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
751
752install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
753install (FILES ${config_files} DESTINATION etc COMPONENT config)
754install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
755install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
756install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
757install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
758install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
759
760#----------------------- we can use CPack to build pacakges --------------------------
761
762# get version from source file
763execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
764    OUTPUT_VARIABLE CS_VERSION)
765string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
766string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
767string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
768string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
769set (CPACK_PACKAGE_VERSION
770     "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
771
772# compute my filename
773set (CPACK_PACKAGE_FILE_NAME
774     "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_TARGET}")
775
776# wich archive we want to generate
777set (CPACK_GENERATOR "TGZ")
778
779# what to put in the archive
780set (CPACK_STRIP_FILES TRUE)
781set (CPACK_COMPONENTS_ALL bin)# config doc)
782
783# ok, we can now use CPack
784include (CPack)
785
786#----------------------- printout resume -----------------------------
787
788message (STATUS "")
789message (STATUS "  operating system: ${OSCamOperatingSystem}")
790message (STATUS "  target system: ${CS_TARGET}")
791message (STATUS "  revision: ${CS_SVN_VERSION}")
792if (HAVE_LIBCRYPTO)
793    message (STATUS "  use system libcrypto functions")
794else (HAVE_LIBCRYPTO)
795    message (STATUS "  use built-in crypt functions")
796endif (HAVE_LIBCRYPTO)
797if (HAVE_PCSC)
798    message (STATUS "  use system pcsc functions")
799endif (HAVE_PCSC)
800if (HAVE_PTHREAD)
801    message (STATUS "  use system pthread functions")
802endif (HAVE_PTHREAD)
803if (HAVE_LIBUSB)
804if(STATIC_LIBUSB EQUAL 1)
805   message (STATUS "  You selected to enable static libusb")
806endif(STATIC_LIBUSB EQUAL 1)
807 if(STATICLIBUSB AND NOT LIBUSBDIR)
808    message (STATUS "  use static libusb functions")
809 else(STATICLIBUSB AND NOT LIBUSBDIR)
810   if (LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
811      message(STATUS "  use system libusb from selected LIBUSBDIR functions")
812   elseif (LIBUSBDIR AND STATIC_LIBUSB EQUAL 1)
813      message(STATUS "  use static libusb from selected LIBUSBDIR functions")
814   elseif(LIBUSBDIR)
815      message(STATUS " use system libusb from selected LIBUSBDIR functions")
816   elseif(NOT LIBUSBDIR AND NOT STATIC_LIBUSB)
817       message (STATUS "  use system libusb functions")
818   endif(LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
819 endif(STATICLIBUSB AND NOT LIBUSBDIR)
820endif (HAVE_LIBUSB)
821
822message (STATUS "")
Note: See TracBrowser for help on using the repository browser.