3 #----------------------- minimum version of cmake to use ------------
5 cmake_minimum_required(VERSION 2.8.12)
7 cmake_policy(SET CMP0003 NEW)
9 cmake_policy(SET CMP0042 NEW)
12 cmake_policy(SET CMP0054 NEW)
15 #----------------------- detect system ------------------------------
17 if (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")
60 else (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)
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")
92 endif (CMAKE_CROSSCOMPILING)
94 #----------------------- some paths ------------------------------
96 set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
97 set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
99 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
100 include_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
106 ${OPTIONAL_INCLUDE_DIR}
108 else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
109 include_directories (
110 ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
111 ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
112 ${CMAKE_CURRENT_SOURCE_DIR}/minilzo
113 ${OPTIONAL_INCLUDE_DIR}
115 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
117 if(OSCamOperatingSystem MATCHES "Windows/Cygwin")
121 /cygdrive/c/WINDOWS/system32/
124 else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
128 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
130 #----------------------- global options ------------------------------
132 if (OSCamOperatingSystem MATCHES "Linux")
133 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
134 elseif (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")
139 elseif (OSCamOperatingSystem MATCHES "Tuxbox")
140 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
141 elseif (OSCamOperatingSystem MATCHES "TripleDragon")
142 add_definitions ("-DSTB04SCI=1")
143 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
144 elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
145 add_definitions ("-DWITH_COOLAPI=1")
146 set (USE_COOLAPI "USE_COOLAPI")
147 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
148 elseif (OSCamOperatingSystem MATCHES "NHD2")
149 add_definitions ("-DWITH_COOLAPI2=1")
150 set (USE_COOLAPI2 "USE_COOLAPI2")
151 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
152 elseif (OSCamOperatingSystem MATCHES "SlugOS")
153 set (DEFAULT_CS_CONFDIR "/var/etc")
154 elseif (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")
160 elseif (OSCamOperatingSystem MATCHES "Fonera2")
161 set (DEFAULT_CS_CONFDIR "/var/etc")
162 elseif (OSCamOperatingSystem MATCHES "DIR-825")
163 set (DEFAULT_CS_CONFDIR "/var/etc")
164 elseif (OSCamOperatingSystem MATCHES "AZBox")
165 add_definitions ("-DWITH_AZBOX=1")
166 set (USE_AZBOX "USE_AZBOX")
167 set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/oscamCAS")
168 elseif (OSCamOperatingSystem MATCHES "SU980")
169 set (USE_SU980 "USE_SU980")
170 add_definitions ("-DWITH_SU980=1")
171 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
172 elseif (OSCamOperatingSystem MATCHES "MCA")
173 add_definitions ("-DWITH_MCA=1")
174 set (USE_MCA "USE_MCA")
175 set (DEFAULT_CS_CONFDIR "/var/mca/d1")
176 elseif (OSCamOperatingSystem MATCHES "agv2+w")
177 set (DEFAULT_CS_CONFDIR "/etc")
178 elseif (OSCamOperatingSystem MATCHES "WRT54G")
179 set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
180 elseif (OSCamOperatingSystem MATCHES "Amino")
181 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
182 elseif (OSCamOperatingSystem MATCHES "QboxHD")
183 add_definitions ("-DQBOXHD=1")
184 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
185 elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
186 add_definitions ("-static -DWITH_PCSC=1")
187 set (DEFAULT_CS_CONFDIR ".")
188 elseif (OSCamOperatingSystem MATCHES "FreeBSD")
189 add_definitions ("-I/usr/local/include -L/usr/local/lib")
190 set (DEFAULT_CS_CONFDIR ".")
191 elseif (OSCamOperatingSystem MATCHES "OpenBSD")
192 add_definitions ("-I/usr/local/include -L/usr/local/lib")
193 set (DEFAULT_CS_CONFDIR "/etc/oscam")
194 elseif (OSCamOperatingSystem MATCHES "FriendlyARM")
195 set (DEFAULT_CS_CONFDIR ".")
196 endif (OSCamOperatingSystem MATCHES "Linux")
198 set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
199 add_definitions ("-DCS_CONFDIR=\"${CS_CONFDIR}\"")
202 #----------------------- subdirectories ------------------------------
204 include (CheckIncludeFile)
206 check_include_file ("pthread.h" HAVE_PTHREAD)
208 message(STATUS " pthread found. Adding pthread support ")
209 add_definitions ("-DHAVE_PTHREAD_H")
210 elseif (HAVE_PTHREAD)
211 message(STATUS " no pthread found. No smartreader ")
214 check_include_file ("openssl/aes.h" HAVE_LIBCRYPTO)
216 add_definitions ("-DWITH_LIBCRYPTO=1")
217 set (USE_LIBCRYPTO "USE_LIBCRYPTO")
218 else (HAVE_LIBCRYPTO)
219 message (STATUS " LIBCRYTO NOT FOUND OR DISABLED NO SSL SUPPORT POSSIBLE")
220 endif (HAVE_LIBCRYPTO)
222 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SSL OUTPUT_VARIABLE CONFIG_WITH_SSL OUTPUT_STRIP_TRAILING_WHITESPACE)
223 if (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
224 message ( STATUS " ssl is added by You compiling with ssl included")
225 elseif (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")
227 elseif (CONFIG_WITH_SSL MATCHES "N" AND NOT WITH_SSL EQUAL 1)
228 message (STATUS " SSL IS NOT INCLUDED IN THIS COMPILATION")
229 endif (CONFIG_WITH_SSL MATCHES "N" AND WITH_SSL EQUAL 1)
231 if (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")
235 elseif (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")
237 endif (CONFIG_WITH_SSL MATCHES "Y" AND NOT WITH_SSL EQUAL 0)
239 find_package(OpenSSL)
240 if (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)
246 else (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
247 message(STATUS "SSL REQUESTED BUT OPENSSL or LYBCRYPTO NOT FOUND !!")
249 message(STATUS " ssl support requested but openssl or libcrypto NOT FOUND COMPILING WHITOUT SSL !!! ")
252 endif (OPENSSL_FOUND AND HAVE_LIBCRYPTO)
254 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
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)
271 check_include_file ("time.h" HAVE_LIBRT)
273 message(STATUS " librt found (needed by libusb).")
275 message(STATUS " no librt found (needed by libusb. No smartreader support")
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)
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)
304 else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
305 set (HAVE_LIBRT True)
306 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
309 if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
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)
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)
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)
383 endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
385 check_include_file ("PCSC/wintypes.h" 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")
411 endif (OSCamOperatingSystem MATCHES "Mac OS X" AND NOT HAVE_PCSC EQUAL 0)
413 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
414 add_definitions ("-Icygwin")
416 set (USE_PCSC "USE_PCSC")
417 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
420 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled MODULE_STREAMRELAY OUTPUT_VARIABLE CONFIG_STREAMRELAY OUTPUT_STRIP_TRAILING_WHITESPACE)
421 if (CONFIG_STREAMRELAY MATCHES "Y" AND NOT MODULE_STREAMRELAY EQUAL 1)
423 check_include_file ("${LIBDVBCSADIR}/include/dvbcsa/dvbcsa.h" FOUND_LIBDVBCSA)
424 set (LIBADVBCSA_LIBRARY "${LIBDVBCSADIR}/libdvbcsa.a")
425 set (LIBDVBCSA_LIBRARY "${LIBDVBCSADIR}/libdvbcsa.so")
427 check_include_file ("dvbcsa/dvbcsa.h" FOUND_LIBDVBCSA)
428 find_library (LIBADVBCSA_LIBRARY NAMES libdvbcsa.a)
429 find_library (LIBDVBCSA_LIBRARY NAMES dvbcsa)
433 if (STATIC_LIBDVBCSA AND FOUND_LIBDVBCSA AND EXISTS ${LIBADVBCSA_LIBRARY})
434 message(STATUS " static libdvbcsa found (libdvbcsa.a).")
435 add_library(imp_libdvbcsa STATIC IMPORTED)
436 set_property(TARGET imp_libdvbcsa PROPERTY IMPORTED_LOCATION ${LIBADVBCSA_LIBRARY})
437 set (dvbcsa_link "imp_libdvbcsa")
438 set (STATICLIBDVBCSA 1)
439 elseif ((NOT STATIC_LIBDVBCSA OR STATIC_LIBDVBCSA EQUAL 0) AND FOUND_LIBDVBCSA AND EXISTS ${LIBDVBCSA_LIBRARY})
440 message(STATUS " libdvbcsa found (libdvbcsa.so).")
441 add_library(imp_libdvbcsa SHARED IMPORTED)
442 set_property(TARGET imp_libdvbcsa PROPERTY IMPORTED_LOCATION ${LIBDVBCSA_LIBRARY} )
443 set(dvbcsa_link dvbcsa)
444 set (STATICLIBDVBCSA 0)
445 else (STATIC_LIBDVBCSA AND FOUND_LIBDVBCSA AND EXISTS ${LIBADVBCSA_LIBRARY})
446 message(FATAL_ERROR " no libdvbcsa found!")
447 endif (STATIC_LIBDVBCSA AND FOUND_LIBDVBCSA AND EXISTS ${LIBADVBCSA_LIBRARY})
448 add_definitions ("-DSTATIC_LIBDVBCSA=${STATICLIBDVBCSA}")
449 else (HAVE_LIBDVBCSA)
450 message(FATAL_ERROR " HAVE_LIBDVBCSA disabled!")
451 endif (HAVE_LIBDVBCSA)
452 endif (CONFIG_STREAMRELAY MATCHES "Y" AND NOT MODULE_STREAMRELAY EQUAL 1)
454 # Manage config.h based on command line parameters
455 # Manipulate config file based on given parameters and read unset parameters
457 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --show-valid OUTPUT_VARIABLE config_vars_string OUTPUT_STRIP_TRAILING_WHITESPACE)
458 string(REGEX MATCHALL "[A-Z0-9_]+" config_vars ${config_vars_string})
460 MACRO(GENERATE_OSCAM_CONFIG fullpath)
461 foreach(option ${config_vars})
462 if(DEFINED ${option})
464 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enable ${option})
466 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --disable ${option})
468 endif(DEFINED ${option})
470 ENDMACRO(GENERATE_OSCAM_CONFIG fullpath)
472 GENERATE_OSCAM_CONFIG("${CMAKE_CURRENT_SOURCE_DIR}/config.h")
474 # Build config.mak and related files
475 # FIXME: Create USE_FLAGS and pass them to config.sh using --use-flags
476 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --objdir ${CMAKE_CURRENT_BINARY_DIR} --use-flags "${USE_STAPI} ${USE_STAPI5} /
477 ${USE_COOLAPI} ${USE_SU980} ${USE_AZBOX} ${USE_MCA} ${USE_SSL} ${USE_LIBCRYPTO} ${USE_LIBUSB} ${USE_PCSC}" --make-config.mak)
478 # Generate webif/pages.c
479 execute_process (COMMAND make --no-print-directory --quiet -C ${CMAKE_CURRENT_SOURCE_DIR}/webif)
481 #----------------------- subdirectories ------------------------------
483 add_subdirectory (csctapi)
484 add_subdirectory (minilzo)
485 add_subdirectory (cscrypt)
487 #----------------------- file groups ------------------------------
488 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled MODULE_CAMD33 OUTPUT_VARIABLE CAMD33 OUTPUT_STRIP_TRAILING_WHITESPACE)
489 if (CAMD33 MATCHES "N")
490 set (CAMD_33 "module-camd33*")
491 endif (CAMD33 MATCHES "N")
492 if (OSCamOperatingSystem MATCHES "Mac OS X")
493 file (GLOB csmodules_mac "module-dvbapi*" "module-lcd*" "${CAMD_33}")
494 file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
495 list (REMOVE_ITEM csmodules_srcs ${csmodules_mac})
496 file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
497 list (REMOVE_ITEM csmodules_hdrs ${csmodules_mac})
498 file (GLOB csreaders_srcs "reader-*.c")
499 file (GLOB csreaders_hdrs "reader-*.h")
500 file (GLOB csoscam_srcs "oscam-*.c")
501 file (GLOB csoscam_hdrs "oscam-*.h")
502 file (GLOB exe_srcs "oscam.c")
503 file (GLOB exe_hdrs "globals.h")
504 file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
505 else (OSCamOperatingSystem MATCHES "Mac OS X")
506 file (GLOB csmodules_srcs "module-*.c" "webif/pages.c")
507 file (GLOB csmodules_hdrs "module-*.h" "webif/pages.h")
508 file (GLOB csreaders_srcs "reader-*.c")
509 file (GLOB csreaders_hdrs "reader-*.h")
510 file (GLOB csoscam_srcs "oscam-*.c" "${CMAKE_CURRENT_BINARY_DIR}/config.c")
511 file (GLOB csoscam_hdrs "oscam-*.h")
512 file (GLOB exe_srcs "oscam.c")
513 file (GLOB exe_hdrs "globals.h")
514 file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
515 endif (OSCamOperatingSystem MATCHES "Mac OS X")
516 #----------------------- modules ------------------------------
518 set (csmodules "csmodules")
519 add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
521 #----------------------- readers ------------------------------
523 set (csreaders "csreaders")
524 add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
526 #----------------------- other oscam files ------------------------------
528 set (csoscam "csoscam")
529 add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
531 #----------------------- the executable ------------------------------
533 set (exe_name "oscam")
534 add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
535 target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt minilzo)
536 if(HAVE_LIBRT AND HAVE_LIBUSB)
538 set (libusb_link "imp_libusb")
541 set (libusb_link "libusb-1.0.a")
543 set (libusb_link "usb-1.0")
546 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
548 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
549 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
550 set (setupapi_link "setupapi")
551 set (ole32_link "ole32")
552 set (shell32_link "shell32")
553 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
554 endif(HAVE_LIBRT AND HAVE_LIBUSB)
556 if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
558 set (libusb_link "imp_libusb")
561 set (libusb_link "libusb-1.0.a")
563 set (libusb_link "usb-1.0")
566 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
567 set (rt_link "imp_librt")
568 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
569 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
570 set (setupapi_link "setupapi")
571 set (ole32_link "ole32")
572 set (shell32_link "shell32")
573 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
574 endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
577 set (pthread_link "pthread")
581 target_link_libraries (${exe_name} ssl)
585 target_link_libraries (${exe_name} crypto)
586 endif (HAVE_LIBCRYPTO)
588 # some systems need libm for the nagra cak7 functions to work
589 check_include_file("math.h" HAVE_LIBM)
591 target_link_libraries (${exe_name} m)
595 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
596 if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
597 target_link_libraries (${exe_name} pcsclite)
598 endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
599 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
603 target_link_libraries(${exe_name} stapilib)
604 endif (HAVE_LIBSTAPI)
607 target_link_libraries(${exe_name} stapi5lib)
608 endif (HAVE_LIBSTAPI5)
610 add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
612 #----------------------- specific options ------------------------------
614 if (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
615 target_link_libraries (${exe_name} rt)
616 endif (NOT OSCamOperatingSystem MATCHES "(Mac OS X|Windows/Cygwin|FreeBSD|OpenBSD)")
618 if (OSCamOperatingSystem MATCHES "Linux")
619 elseif (OSCamOperatingSystem MATCHES "Mac OS X")
620 if (NOT HAVE_PCSC EQUAL 0)
621 FIND_LIBRARY (PCSC_LIBRARY PCSC)
622 message (STATUS "PCSC Mac OS X found : ${PCSC_LIBRARY}")
623 add_definitions ("-DWITH_PCSC=1")
624 target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
626 FIND_LIBRARY (IOKit_LIBRARY IOKit)
627 target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
628 FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
629 target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
630 else (NOT HAVE_PCSC EQUAL 0)
631 message (STATUS "PCSC Mac OS X not found no pcsc support")
632 endif (NOT HAVE_PCSC EQUAL 0)
633 elseif (OSCamOperatingSystem MATCHES "Tuxbox")
635 elseif (OSCamOperatingSystem MATCHES "TripleDragon")
637 elseif (OSCamOperatingSystem MATCHES "SlugOS")
638 elseif (OSCamOperatingSystem MATCHES "OpenWRT")
639 elseif (OSCamOperatingSystem MATCHES "Fonera2")
640 elseif (OSCamOperatingSystem MATCHES "DIR-825")
641 elseif (OSCamOperatingSystem MATCHES "agv2+w")
642 elseif (OSCamOperatingSystem MATCHES "WRT54G")
643 elseif (OSCamOperatingSystem MATCHES "Amino")
644 elseif (OSCamOperatingSystem MATCHES "QboxHD")
645 elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
646 message (STATUS "Windows system PCSC : winscard.dll")
647 target_link_libraries (${exe_name} winscard)
648 target_link_libraries (${exe_name} setupapi )
649 target_link_libraries (${exe_name} ole32)
650 target_link_libraries (${exe_name} shell32)
651 elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
652 target_link_libraries (${exe_name} rt nxp)
653 elseif (OSCamOperatingSystem MATCHES "NHD2")
654 target_link_libraries (${exe_name} lnxcssUsr lnxscsUsr lnxnotifyqUsr lnxUKAL lnxplatUsr rt)
655 elseif (OSCamOperatingSystem MATCHES "AZBox")
656 add_library(xcas STATIC IMPORTED)
657 set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/extapi/openxcas/libOpenXCASAPI.a)
658 set (xcas_link "xcas")
659 elseif (OSCamOperatingSystem MATCHES "SU980")
660 target_link_libraries (${exe_name} rt entropic)
661 endif (OSCamOperatingSystem MATCHES "Linux")
663 target_link_libraries (${exe_name} ${libusb_link} ${rt_link} ${setupapi_link} ${ole32_link} ${shell32_link} ${pthread_link} ${dl_link} ${xcas_link} ${dvbcsa_link})
665 #----------------------- put svnversion in the build ------------------------------
666 # at every target rebuild, we re-build the oscam.c compilation...
668 # add the needed dependency
669 add_dependencies (${exe_name} svnversion)
670 add_dependencies (${csoscam} svnversion-log)
672 # how to re-build the files which printout the version
676 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
681 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
684 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --oscam-revision COMMAND tr -d '\n' OUTPUT_VARIABLE CS_SVN_VERSION)
685 add_definitions ("-D'CS_SVN_VERSION=\"${CS_SVN_VERSION}\"'")
687 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine COMMAND tr -d '\n' OUTPUT_VARIABLE CS_TARGET)
688 add_definitions ("-D'CS_TARGET=\"${CS_TARGET}\"'")
690 execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_ARM_NEON OUTPUT_VARIABLE CONFIG_WITH_ARM_NEON OUTPUT_STRIP_TRAILING_WHITESPACE)
691 if (CONFIG_WITH_ARM_NEON MATCHES "Y" AND NOT WITH_ARM_NEON EQUAL 0)
692 add_definitions ("-DWITH_ARM_NEON")
693 set (WITH_ARM_NEON "1")
694 elseif (CONFIG_WITH_ARM_NEON MATCHES "Y" AND NOT WITH_ARM_NEON EQUAL 0)
695 message (status " The config file has WITH_ARM_NEON enabled, but You disabled it by you cmake command COMPILING WHITOUT arm neon optimization")
696 endif (CONFIG_WITH_ARM_NEON MATCHES "Y" AND NOT WITH_ARM_NEON EQUAL 0)
697 #----------------------- global compile and link options ------------------------------
698 #enable sse2 on x86, neon on arm
699 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
700 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3")
701 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "(arm)|(ARM)")
702 if (WITH_ARM_NEON EQUAL 1)
703 message(status " ARM NEON is enabled, compiling with neon optimization")
704 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon")
705 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfpu=neon")
706 else (WITH_ARM_NEON EQUAL 1)
707 message(status " ARM NEON is disabled, compiling without neon optimization")
708 endif (WITH_ARM_NEON EQUAL 1)
709 endif (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
711 # disable warning about unused but set variables in gcc 4.6+
712 if (CMAKE_COMPILER_IS_GNUCC)
713 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
714 string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
715 list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
716 list(GET GCC_VERSION_COMPONENTS 0 GCC_MINOR)
717 add_definitions ("-W -Wall ")
718 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -pipe -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-schedule-insns")
719 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
720 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
721 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
722 endif (CMAKE_COMPILER_IS_GNUCC)
724 if (OSCamOperatingSystem MATCHES "Mac OS X")
725 if (SWVER GREATER 10.6)
726 if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
727 add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
728 else (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
729 add_definitions("-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
730 endif (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
731 elseif(SWVER LESS 10.7)
732 add_definitions("-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
733 endif (SWVER GREATER 10.6)
734 endif (OSCamOperatingSystem MATCHES "Mac OS X")
736 # we don't want the '-rdynamic' in the link command
737 set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
739 # we want to strip if not Debug build
740 if (OSCamOperatingSystem MATCHES "Mac OS X")
741 if (SWVER MATCHES "10.8")
742 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
743 set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
744 else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
745 message (STATUS " building with debug")
746 set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
747 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
748 elseif (SWVER MATCHES "10.7")
749 if (SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
750 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
751 set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
752 else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
753 message (STATUS " building with debug")
754 set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
755 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
756 else(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
757 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
758 set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
759 else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
760 message (STATUS " building with debug")
761 set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SWVER}.sdk")
762 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
763 endif(SWVER EQUAL 10.7 AND XCODEVER LESS 4.3)
764 elseif (SWVER MATCHES "10.6")
765 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
766 set (CMAKE_EXE_LINKER_FLAGS "-isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
767 else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
768 message (STATUS " building with debug")
769 set (CMAKE_EXE_LINKER_FLAGS "-ggdb -isysroot /Developer/SDKs/MacOSX${SWVER}.sdk")
770 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
771 endif (SWVER MATCHES "10.8")
772 else (OSCamOperatingSystem MATCHES "Mac OS X")
773 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
774 set (CMAKE_EXE_LINKER_FLAGS "-s")
775 else (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
776 message (STATUS " building with debug")
777 set (CMAKE_EXE_LINKER_FLAGS "-ggdb")
778 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
779 endif (OSCamOperatingSystem MATCHES "Mac OS X")
781 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
782 set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
783 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
785 #----------------------- subdirectory list smargo ------------------------------
787 if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
789 add_subdirectory (utils)
791 endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
793 #--------------------------------------------------------------------------------
795 #----------------------- installation -----------------------------
797 file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
798 file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
799 file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
800 file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
801 file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
802 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
803 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
804 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
805 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
806 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
807 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
808 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
809 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
810 file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
811 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
813 install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
814 install (FILES ${config_files} DESTINATION etc COMPONENT config)
815 install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
816 install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
817 install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
818 install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
819 install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
821 #----------------------- we can use CPack to build pacakges --------------------------
823 # get version from source file
824 execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
825 OUTPUT_VARIABLE CS_VERSION)
826 string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
827 string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
828 string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
829 string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
830 set (CPACK_PACKAGE_VERSION
831 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
833 # compute my filename
834 set (CPACK_PACKAGE_FILE_NAME
835 "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_TARGET}")
837 # wich archive we want to generate
838 set (CPACK_GENERATOR "TGZ")
840 # what to put in the archive
841 set (CPACK_STRIP_FILES TRUE)
842 set (CPACK_COMPONENTS_ALL bin)# config doc)
844 # ok, we can now use CPack
847 #----------------------- printout resume -----------------------------
850 message (STATUS " operating system: ${OSCamOperatingSystem}")
851 message (STATUS " target system: ${CS_TARGET}")
852 message (STATUS " revision: ${CS_SVN_VERSION}")
854 message (STATUS " use system libcrypto functions")
855 else (HAVE_LIBCRYPTO)
856 message (STATUS " use built-in crypt functions")
857 endif (HAVE_LIBCRYPTO)
859 message (STATUS " use system pcsc functions")
862 message (STATUS " use system pthread functions")
865 if(STATIC_LIBUSB EQUAL 1)
866 message (STATUS " You selected to enable static libusb")
867 endif(STATIC_LIBUSB EQUAL 1)
868 if(STATICLIBUSB AND NOT LIBUSBDIR)
869 message (STATUS " use static libusb functions")
870 else(STATICLIBUSB AND NOT LIBUSBDIR)
871 if (LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
872 message(STATUS " use system libusb from selected LIBUSBDIR functions")
873 elseif (LIBUSBDIR AND STATIC_LIBUSB EQUAL 1)
874 message(STATUS " use static libusb from selected LIBUSBDIR functions")
876 message(STATUS " use system libusb from selected LIBUSBDIR functions")
877 elseif(NOT LIBUSBDIR AND NOT STATIC_LIBUSB)
878 message (STATUS " use system libusb functions")
879 endif(LIBUSBDIR AND STATIC_LIBUSB EQUAL 0)
880 endif(STATICLIBUSB AND NOT LIBUSBDIR)
883 if(STATIC_LIBDVBCSA EQUAL 1)
884 message (STATUS " You selected to enable static libdvbcsa")
885 endif(STATIC_LIBDVBCSA EQUAL 1)
886 if(STATICLIBDVBCSA AND NOT LIBDVBCSADIR)
887 message (STATUS " use static libdvbcsa functions")
888 else(STATICLIBDVBCSA AND NOT LIBDVBCSADIR)
889 if (LIBDVBCSADIR AND STATIC_LIBDVBCSA EQUAL 0)
890 message(STATUS " use system libdvbcsa from selected LIBDVBCSADIR functions")
891 elseif (LIBDVBCSADIR AND STATIC_LIBDVBCSA EQUAL 1)
892 message(STATUS " use static libdvbcsa from selected LIBDVBCSADIR functions")
894 message(STATUS " use system libdvbcsa from selected LIBDVBCSADIR functions")
895 elseif(NOT LIBDVBCSADIR AND NOT STATIC_LIBDVBCSA)
896 message (STATUS " use system libdvbcsa functions")
897 endif(LIBDVBCSADIR AND STATIC_LIBDVBCSA EQUAL 0)
898 endif(STATICLIBDVBCSA AND NOT LIBDVBCSADIR)
899 endif (HAVE_LIBDVBCSA)