source: trunk/CMakeLists.txt@ 2891

Last change on this file since 2891 was 2891, checked in by cogsi, 10 years ago

azbox: default config dir now /PLUGINS/OpenXCAS/oscamCAS

File size: 24.3 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 set (CS_OS_HW "tuxbox")
21 set (CS_OS_SYS "linux")
22 elseif (OSCAM_SYSTEM_NAME MATCHES "TripleDragon")
23 set (OSCamOperatingSystem "TripleDragon")
24 set (CS_OS_HW "tuxbox")
25 set (CS_OS_SYS "linux")
26 elseif (OSCAM_SYSTEM_NAME MATCHES "Coolstream")
27 set (OSCamOperatingSystem "NeutrinoHD")
28 set (CS_OS_HW "coolstream")
29 set (CS_OS_SYS "linux")
30 elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
31 set (OSCamOperatingSystem "SlugOS")
32 set (CS_OS_HW "nslu2")
33 set (CS_OS_SYS "linux")
34 elseif (OSCAM_SYSTEM_NAME MATCHES "Fonera2")
35 set (OSCamOperatingSystem "Fonera2")
36 set (CS_OS_HW "fonera2")
37 set (CS_OS_SYS "linux")
38 elseif (OSCAM_SYSTEM_NAME MATCHES "AZBox")
39 set (OSCamOperatingSystem "AZBox")
40 set (CS_OS_HW "azbox")
41 set (CS_OS_SYS "linux")
42 elseif (OSCAM_SYSTEM_NAME MATCHES "agv2+w")
43 set (OSCamOperatingSystem "agv2+w")
44 set (CS_OS_HW "agv2+w")
45 set (CS_OS_SYS "linux")
46 elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
47 set (OSCamOperatingSystem "WRT54G")
48 set (CS_OS_HW "wrt54g")
49 set (CS_OS_SYS "linux")
50 elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
51 set (OSCamOperatingSystem "Amino")
52 set (CS_OS_HW "amino")
53 set (CS_OS_SYS "linux")
54 elseif (OSCAM_SYSTEM_NAME MATCHES "QboxHD")
55 set (OSCamOperatingSystem "QboxHD")
56 set (CS_OS_HW "qboxhd")
57 set (CS_OS_SYS "linux")
58 else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
59 message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
60 set (OSCamOperatingSystem "Unknown")
61 set (CS_OS_HW "unknown")
62 set (CS_OS_SYS "unknown")
63 endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
64else (CMAKE_CROSSCOMPILING)
65 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
66 set (OSCamOperatingSystem "Linux")
67 set (CS_OS_HW "pc")
68 set (CS_OS_SYS "linux")
69 elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
70 set (OSCamOperatingSystem "FreeBSD")
71 set (CS_OS_HW "pc")
72 set (CS_OS_SYS "freebsd")
73 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
74 set (OSCamOperatingSystem "Mac OS X")
75 set (CS_OS_HW "mac")
76 set (CS_OS_SYS "macosx")
77 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
78 SET( CMAKE_CFLAGS "${CMAKE_CFLAGS} -m32" )
79 elseif (${CYGWIN})
80 set (OSCamOperatingSystem "Windows/Cygwin")
81 set (CS_OS_HW "pc")
82 set (CS_OS_SYS "cygwin")
83 set (CMAKE_SYSTEM_PROCESSOR "i386")
84 else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
85 message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
86 set (OSCamOperatingSystem "Unknown")
87 set (CS_OS_HW "unknown")
88 set (CS_OS_SYS "unknown")
89 endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
90endif (CMAKE_CROSSCOMPILING)
91
92#----------------------- some paths ------------------------------
93
94set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
95set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
96
97if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
98include_directories (
99 ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
100 ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
101 if[CS_WITH_GBOX]
102 ${CMAKE_CURRENT_SOURCE_DIR}/csgbox
103 endif[CS_WITH_GBOX]
104 ${CMAKE_CURRENT_SOURCE_DIR}/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 if[CS_WITH_GBOX]
113 ${CMAKE_CURRENT_SOURCE_DIR}/csgbox
114 endif[CS_WITH_GBOX]
115 ${OPTIONAL_INCLUDE_DIR}
116 )
117endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
118
119if(OSCamOperatingSystem MATCHES "Windows/Cygwin")
120link_directories (
121 /usr/lib
122 /usr/lib/w32api
123 /cygdrive/c/WINDOWS/system32/
124 ${OPTIONAL_LINK_DIR}
125 )
126else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
127link_directories (
128 ${OPTIONAL_LINK_DIR}
129 )
130endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
131
132#----------------------- global options ------------------------------
133
134if (OSCamOperatingSystem MATCHES "Linux")
135 add_definitions ("-DOS_LINUX")
136 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
137elseif (OSCamOperatingSystem MATCHES "Mac OS X")
138 add_definitions ("-DOS_MACOSX -DHAVE_PCSC -DNEED_DAEMON -DCS_NOSHM")
139 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
140elseif (OSCamOperatingSystem MATCHES "Tuxbox")
141 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
142 if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
143 add_definitions ("-DOS_LINUX -DTUXBOX -DMIPSEL")
144 else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
145 add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
146 endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
147elseif (OSCamOperatingSystem MATCHES "TripleDragon")
148 add_definitions ("-DOS_LINUX -DTRIPLEDRAGON -DSTB04SCI -DTUXBOX -DPPC")
149 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
150elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
151 add_definitions ("-DOS_LINUX -DTUXBOX -DCOOL")
152 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
153elseif (OSCamOperatingSystem MATCHES "SlugOS")
154 add_definitions ("-DOS_LINUX -DARM")
155 set (DEFAULT_CS_CONFDIR "/var/etc")
156elseif (OSCamOperatingSystem MATCHES "Fonera2")
157 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
158 set (DEFAULT_CS_CONFDIR "/var/etc")
159elseif (OSCamOperatingSystem MATCHES "AZBox")
160 add_definitions ("-DOS_LINUX -DMIPSEL -DAZBOX")
161 set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/oscamCAS")
162elseif (OSCamOperatingSystem MATCHES "agv2+w")
163 add_definitions ("-DOS_LINUX -DUCLIBC")
164 set (DEFAULT_CS_CONFDIR "/etc")
165elseif (OSCamOperatingSystem MATCHES "WRT54G")
166 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
167 set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
168elseif (OSCamOperatingSystem MATCHES "Amino")
169 add_definitions ("-DOS_LINUX -DSH4 -DTUXBOX")
170 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
171elseif (OSCamOperatingSystem MATCHES "QboxHD")
172 add_definitions ("-DOS_LINUX -DSH4 -DQBOXHD -DTUXBOX")
173 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
174elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
175 add_definitions ("-DOS_CYGWIN32 -static -DHAVE_PCSC")
176 set (DEFAULT_CS_CONFDIR ".")
177elseif (OSCamOperatingSystem MATCHES "FreeBSD")
178 add_definitions ("-DOS_FREEBSD")
179 set (DEFAULT_CS_CONFDIR ".")
180endif (OSCamOperatingSystem MATCHES "Linux")
181
182set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
183add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
184
185set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
186set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
187
188add_definitions ("-DUSE_CMAKE")
189add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
190add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
191add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
192add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
193
194#----------------------- subdirectories ------------------------------
195
196include (CheckIncludeFile)
197if(CS_ANTICASC)
198 add_definitions ("-DCS_ANTICASC")
199endif(CS_ANTICASC)
200
201if(CS_LOGHISTORY)
202 add_definitions ("-DCS_LOGHISTORY")
203endif(CS_LOGHISTORY)
204
205if(CS_WITH_GBOX)
206 add_definitions ("-DCS_WITH_GBOX")
207endif(CS_WITH_GBOX)
208
209if(CS_LED)
210 add_definitions ("-DCS_LED")
211endif (CS_LED)
212
213if (WEBIF)
214 add_definitions ("-DWEBIF")
215endif (WEBIF)
216
217if(IRDETO_GUESSING)
218 add_definitions ("-DIRDETO_GUESSING")
219endif (IRDETO_GUESSING)
220
221check_include_file ("pthread.h" HAVE_PTHREAD)
222if (HAVE_PTHREAD)
223 message(STATUS " pthread found. Adding pthread support ")
224 add_definitions ("-DHAVE_PTHREAD_H")
225elseif (HAVE_PTHREAD)
226 message(STATUS " no pthread found. No smartreader ")
227endif (HAVE_PTHREAD)
228
229check_include_file ("openssl/aes.h" HAVE_AES)
230if (HAVE_AES)
231 add_definitions ("-DHAVE_AES")
232endif (HAVE_AES)
233
234check_include_file ("openssl/sha.h" HAVE_SHA)
235if (HAVE_SHA)
236 add_definitions ("-DHAVE_SHA")
237endif (HAVE_SHA)
238
239
240if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
241 if (LIBRTDIR)
242 check_include_file ("${LIBRTDIR}/include/time.h" HAVE_LIBRT_STATIC)
243 if (HAVE_LIBRT_STATIC)
244 if (EXISTS ${LIBRTDIR}/lib/librt.a)
245 message(STATUS " static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).")
246 add_definitions ("-I${LIBRTDIR}/include/")
247 add_library(imp_librt STATIC IMPORTED)
248 set_property(TARGET imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a)
249 else (EXISTS ${LIBRTDIR}/lib/librt.a)
250 message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb). No smartreader support)")
251 unset (HAVE_LIBRT_STATIC)
252 endif (EXISTS ${LIBRTDIR}/lib/librt.a)
253 else (HAVE_LIBRT_STATIC)
254 message(STATUS " no librt found (needed by libusb). No smartreader support")
255 endif (HAVE_LIBRT_STATIC)
256 else (LIBRTDIR)
257 check_include_file ("time.h" HAVE_LIBRT)
258 if (HAVE_LIBRT)
259 message(STATUS " librt found (needed by libusb).")
260 else (HAVE_LIBRT)
261 message(STATUS " no librt found (needed by libusb. No smartreader support")
262 endif (HAVE_LIBRT)
263 endif (LIBRTDIR)
264else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
265 set (HAVE_LIBRT True)
266endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
267
268
269if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
270 if (LIBUSBDIR)
271 check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB)
272 if (HAVE_LIBUSB AND HAVE_PTHREAD)
273 if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
274 message(STATUS " static libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ")
275 add_definitions ("-DLIBUSB")
276 add_definitions ("-I${LIBUSBDIR}/include/")
277 add_library(imp_libusb STATIC IMPORTED)
278 set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a)
279 else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
280 message(STATUS " static libusb 1.0 not found (${LIBUSBDIR}/lib/libusb-1.0.a). No smartreader support ")
281 unset(HAVE_LIBUSB)
282 unset(HAVE_LIBRT)
283 unset(HAVE_LIBRT_STATIC)
284 endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
285 else (HAVE_LIBUSB AND HAVE_PTHREAD)
286 message(STATUS " no libusb 1.0 found. No smartreader support")
287 endif (HAVE_LIBUSB AND HAVE_PTHREAD)
288 else (LIBUSBDIR)
289 check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB)
290 if (HAVE_LIBUSB AND HAVE_PTHREAD)
291 if (EXISTS /usr/local/lib/libusb-1.0.a)
292 message(STATUS " static libusb 1.0 found : /usr/local/lib/libusb-1.0.a . Adding smartreader support ")
293 add_definitions ("-DLIBUSB")
294 add_definitions ("-I/usr/local/include")
295 add_library(imp_libusb STATIC IMPORTED)
296 set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION /usr/local/lib/libusb-1.0.a)
297 elseif (EXISTS /usr/lib/libusb-1.0.a)
298 message(STATUS " static libusb 1.0 found : /usr/lib/libusb-1.0.a . Adding smartreader support ")
299 add_definitions ("-DLIBUSB")
300 add_library(imp_libusb STATIC IMPORTED)
301 set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION /usr/lib/libusb-1.0.a)
302 else (EXISTS /usr/local/lib/libusb-1.0.a)
303 message(STATUS " static libusb 1.0 not found (not in /usr/local/lib/ or /usr/lib/) . No smartreader support ")
304 unset(HAVE_LIBUSB)
305 unset(HAVE_LIBRT)
306 unset(HAVE_LIBRT_STATIC)
307 endif (EXISTS /usr/local/lib/libusb-1.0.a)
308 else (HAVE_LIBUSB AND HAVE_PTHREAD)
309 message(STATUS " no libusb 1.0 found. No smartreader support")
310 endif (HAVE_LIBUSB AND HAVE_PTHREAD)
311 endif (LIBUSBDIR)
312endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
313
314
315check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
316if (HAVE_PCSC)
317 add_definitions ("-DHAVE_PCSC")
318if (OSCamOperatingSystem MATCHES "Linux")
319 add_definitions ("-I/usr/include/PCSC")
320endif (OSCamOperatingSystem MATCHES "Linux")
321else (HAVE_PCSC)
322if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
323 add_definitions ("-Icygwin")
324 set (HAVE_PCSC "1")
325endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
326endif (HAVE_PCSC)
327
328
329#----------------------- subdirectories ------------------------------
330
331add_subdirectory (csctapi)
332add_subdirectory (cscrypt)
333if(CS_WITH_GBOX)
334 add_subdirectory (csgbox)
335endif(CS_WITH_GBOX)
336if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
337 if (HAVE_LIBUSB)
338 add_subdirectory (utils)
339 endif (HAVE_LIBUSB)
340endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
341
342#----------------------- file groups ------------------------------
343
344file (GLOB csmodules_srcs "module-*.c")
345file (GLOB csmodules_hdrs "module-*.h")
346file (GLOB csreaders_srcs "reader-*.c")
347file (GLOB csreaders_hdrs "reader-*.h")
348file (GLOB csoscam_srcs "oscam-*.c")
349file (GLOB csoscam_hdrs "oscam-*.h")
350file (GLOB exe_srcs "oscam.c")
351file (GLOB exe_hdrs "globals.h")
352file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
353
354#----------------------- modules ------------------------------
355
356set (csmodules "csmodules")
357add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
358
359#----------------------- readers ------------------------------
360
361set (csreaders "csreaders")
362add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
363
364#----------------------- other oscam files ------------------------------
365
366set (csoscam "csoscam")
367add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
368
369#----------------------- the executable ------------------------------
370
371set (exe_name "oscam")
372add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
373if(CS_WITH_GBOX)
374 target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt csgbox)
375else(CS_WITHGBOX)
376 target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt)
377endif(CS_WITH_GBOX)
378if(HAVE_LIBRT AND HAVE_LIBUSB)
379 target_link_libraries (${exe_name} imp_libusb)
380 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
381 target_link_libraries (${exe_name} rt)
382 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
383 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
384 target_link_libraries (${exe_name} setupapi)
385 target_link_libraries (${exe_name} ole32)
386 target_link_libraries (${exe_name} shell32)
387 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
388endif(HAVE_LIBRT AND HAVE_LIBUSB)
389
390if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
391 target_link_libraries (${exe_name} imp_libusb)
392 if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
393 target_link_libraries (${exe_name} imp_librt)
394 endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
395 if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
396 target_link_libraries (${exe_name} setupapi)
397 target_link_libraries (${exe_name} ole32)
398 target_link_libraries (${exe_name} shell32)
399 endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
400endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
401
402if (HAVE_PTHREAD)
403 target_link_libraries (${exe_name} pthread)
404endif (HAVE_PTHREAD)
405
406if (HAVE_AES)
407 target_link_libraries (${exe_name} crypto)
408endif (HAVE_AES)
409
410if (HAVE_PCSC)
411if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
412if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
413 target_link_libraries (${exe_name} pcsclite)
414endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
415endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
416endif (HAVE_PCSC)
417
418
419add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
420
421#----------------------- specific options ------------------------------
422
423if (OSCamOperatingSystem MATCHES "Linux")
424elseif (OSCamOperatingSystem MATCHES "Mac OS X")
425 FIND_LIBRARY (PCSC_LIBRARY PCSC)
426 message (STATUS "OS X system PCSC : ${PCSC_LIBRARY}")
427 target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
428 set (HAVE_PCSC "1")
429 FIND_LIBRARY (IOKit_LIBRARY IOKit)
430 target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
431 FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
432 target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
433elseif (OSCamOperatingSystem MATCHES "Tuxbox")
434 target_link_libraries ( ${exe_name} dl)
435elseif (OSCamOperatingSystem MATCHES "TripleDragon")
436 target_link_libraries ( ${exe_name} dl)
437elseif (OSCamOperatingSystem MATCHES "SlugOS")
438elseif (OSCamOperatingSystem MATCHES "Fonera2")
439elseif (OSCamOperatingSystem MATCHES "agv2+w")
440elseif (OSCamOperatingSystem MATCHES "WRT54G")
441elseif (OSCamOperatingSystem MATCHES "Amino")
442elseif (OSCamOperatingSystem MATCHES "QboxHD")
443elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
444 message (STATUS "Windows system PCSC : winscard.dll")
445 target_link_libraries (${exe_name} winscard)
446 target_link_libraries (${exe_name} setupapi )
447 target_link_libraries (${exe_name} ole32)
448 target_link_libraries (${exe_name} shell32)
449elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
450 target_link_libraries ( ${exe_name} rt nxp )
451elseif (OSCamOperatingSystem MATCHES "AZBox")
452 add_library(xcas STATIC IMPORTED)
453 set_property(TARGET xcas PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/openxcas/libOpenXCASAPI.a)
454 target_link_libraries(${exe_name} xcas)
455endif (OSCamOperatingSystem MATCHES "Linux")
456
457#----------------------- put svnversion in the build ------------------------------
458# at every target rebuild, we re-build the oscam.c compilation...
459
460# add the needed dependency
461add_dependencies (${exe_name} svnversion)
462add_dependencies (${csoscam} svnversion-log)
463
464# how to re-build the files which printout the version
465add_custom_target (
466 svnversion
467 ALL
468 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
469)
470add_custom_target (
471 svnversion-log
472 ALL
473 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
474)
475
476#if the svnversion program is absent, this will leave the SVN_REVISION string empty,
477#but won't stop CMake.
478execute_process (COMMAND "svnversion" "-n" "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE OSCAM_SVN_REVISION)
479
480if (OSCAM_SVN_REVISION)
481 string (REGEX REPLACE "[0-9]+:" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
482 string (REPLACE "M" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
483 string (REPLACE "exported" "0" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
484else (OSCAM_SVN_REVISION)
485 set (OSCAM_SVN_REVISION "0")
486endif (OSCAM_SVN_REVISION)
487
488# pass the version to the compilations as a define
489add_definitions ("-D'CS_SVN_VERSION=\"${OSCAM_SVN_REVISION}\"'")
490
491#----------------------- global compile and link options ------------------------------
492
493# some optimisations
494if (OSCamOperatingSystem MATCHES "Mac OS X")
495 add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer -m32 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")
496elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
497 add_definitions ("-O2 -Winline -Wall -finline-functions -fomit-frame-pointer")
498else (OSCamOperatingSystem MATCHES "Mac OS X")
499 add_definitions ("-Winline -Wall -Wextra")
500 set (CMAKE_C_FLAGS "-O2 -finline-functions -fomit-frame-pointer")
501 set (CMAKE_C_FLAGS_DEBUG "-O0 -g")
502endif (OSCamOperatingSystem MATCHES "Mac OS X")
503
504# we don't want the '-rdynamic' in the link command
505set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
506
507# we want to strip if not Debug build
508if (OSCamOperatingSystem MATCHES "Mac OS X")
509set (CMAKE_EXE_LINKER_FLAGS "-s -m32 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")
510else (OSCamOperatingSystem MATCHES "Mac OS X")
511 if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
512 set (CMAKE_EXE_LINKER_FLAGS "-s")
513 endif (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
514endif (OSCamOperatingSystem MATCHES "Mac OS X")
515
516if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
517 set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
518endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
519
520#----------------------- installation -----------------------------
521
522file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
523file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
524file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
525file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
526file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
527 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
528 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
529 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
530 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
531 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
532 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
533 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
534 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
535file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
536 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
537
538install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
539install (FILES ${config_files} DESTINATION etc COMPONENT config)
540install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
541install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
542install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
543install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
544install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
545
546#----------------------- we can use CPack to build pacakges --------------------------
547
548# get version from source file
549execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
550 OUTPUT_VARIABLE CS_VERSION)
551string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
552string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
553string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
554string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
555set (CPACK_PACKAGE_VERSION
556 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
557
558# compute my filename
559set (CPACK_PACKAGE_FILE_NAME
560 "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
561
562# wich archive we want to generate
563set (CPACK_GENERATOR "TGZ")
564
565# what to put in the archive
566set (CPACK_STRIP_FILES TRUE)
567set (CPACK_COMPONENTS_ALL bin)# config doc)
568
569# ok, we can now use CPack
570include (CPack)
571
572#----------------------- printout resume -----------------------------
573
574message (STATUS "")
575message (STATUS " operating system: ${OSCamOperatingSystem}")
576message (STATUS " system type: ${CS_OSTYPE}")
577message (STATUS " system: ${CS_OS_SYS}")
578message (STATUS " cpu: ${CS_OS_CPU}")
579message (STATUS " hw: ${CS_OS_HW}")
580if (HAVE_AES)
581 message (STATUS " use system aes functions")
582else (HAVE_AES)
583 message (STATUS " use built-in aes functions")
584endif (HAVE_AES)
585if (HAVE_SHA)
586 message (STATUS " use system sha functions")
587else (HAVE_SHA)
588 message (STATUS " use built-in sha functions")
589endif (HAVE_SHA)
590if (HAVE_PCSC)
591 message (STATUS " use system pcsc functions")
592endif (HAVE_PCSC)
593if (HAVE_PTHREAD)
594 message (STATUS " use system pthread functions")
595endif (HAVE_PTHREAD)
596if (HAVE_LIBUSB)
597 message (STATUS " use system libusb functions")
598endif (HAVE_LIBUSB)
599if (WEBIF)
600 message (STATUS " web interface enabled")
601endif (WEBIF)
602if (IRDETO_GUESSING)
603 message (STATUS " irdeto guessing enabled")
604endif (IRDETO_GUESSING)
605if(CS_WITH_GBOX)
606 message (STATUS " gbox protocol enabled")
607endif(CS_WITH_GBOX)
608if(CS_LED)
609 message (STATUS " led trigger support enabled")
610endif(CS_LED)
611message (STATUS "")
Note: See TracBrowser for help on using the repository browser.