source: trunk/CMakeLists.txt@ 2953

Last change on this file since 2953 was 2953, checked in by rorothetroll, 10 years ago

added Seagate FreeAgent DockStar support. thanks Robby

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