1 | project (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
|
---|
9 | cmake_minimum_required (VERSION 2.4)
|
---|
10 | if(COMMAND cmake_policy)
|
---|
11 | cmake_policy(SET CMP0005 OLD)
|
---|
12 | cmake_policy(SET CMP0003 NEW)
|
---|
13 | endif(COMMAND cmake_policy)
|
---|
14 |
|
---|
15 | #----------------------- detect system ------------------------------
|
---|
16 |
|
---|
17 | if (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")
|
---|
64 | else (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")
|
---|
90 | endif (CMAKE_CROSSCOMPILING)
|
---|
91 |
|
---|
92 | #----------------------- some paths ------------------------------
|
---|
93 |
|
---|
94 | set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
|
---|
95 | set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
|
---|
96 |
|
---|
97 | if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
98 | include_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 | )
|
---|
108 | else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
109 | include_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 | )
|
---|
117 | endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
118 |
|
---|
119 | if(OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
120 | link_directories (
|
---|
121 | /usr/lib
|
---|
122 | /usr/lib/w32api
|
---|
123 | /cygdrive/c/WINDOWS/system32/
|
---|
124 | ${OPTIONAL_LINK_DIR}
|
---|
125 | )
|
---|
126 | else (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
127 | link_directories (
|
---|
128 | ${OPTIONAL_LINK_DIR}
|
---|
129 | )
|
---|
130 | endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
131 |
|
---|
132 | #----------------------- global options ------------------------------
|
---|
133 |
|
---|
134 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
135 | add_definitions ("-DOS_LINUX")
|
---|
136 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
137 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
138 | add_definitions ("-DOS_MACOSX -DHAVE_PCSC -DNEED_DAEMON -DCS_NOSHM")
|
---|
139 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
140 | elseif (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")
|
---|
147 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
148 | add_definitions ("-DOS_LINUX -DTRIPLEDRAGON -DSTB04SCI -DTUXBOX -DPPC")
|
---|
149 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
150 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
151 | add_definitions ("-DOS_LINUX -DTUXBOX -DCOOL")
|
---|
152 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
153 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
154 | add_definitions ("-DOS_LINUX -DARM")
|
---|
155 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
156 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
157 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
|
---|
158 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
159 | elseif (OSCamOperatingSystem MATCHES "AZBox")
|
---|
160 | add_definitions ("-DOS_LINUX -DMIPSEL -DAZBOX")
|
---|
161 | set (DEFAULT_CS_CONFDIR "/PLUGINS/OpenXCAS/oscamCAS")
|
---|
162 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
163 | add_definitions ("-DOS_LINUX -DUCLIBC")
|
---|
164 | set (DEFAULT_CS_CONFDIR "/etc")
|
---|
165 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
166 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
|
---|
167 | set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
|
---|
168 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
169 | add_definitions ("-DOS_LINUX -DSH4 -DTUXBOX")
|
---|
170 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
171 | elseif (OSCamOperatingSystem MATCHES "QboxHD")
|
---|
172 | add_definitions ("-DOS_LINUX -DSH4 -DQBOXHD -DTUXBOX")
|
---|
173 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
174 | elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
175 | add_definitions ("-DOS_CYGWIN32 -static -DHAVE_PCSC")
|
---|
176 | set (DEFAULT_CS_CONFDIR ".")
|
---|
177 | elseif (OSCamOperatingSystem MATCHES "FreeBSD")
|
---|
178 | add_definitions ("-DOS_FREEBSD")
|
---|
179 | set (DEFAULT_CS_CONFDIR ".")
|
---|
180 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
181 |
|
---|
182 | set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
|
---|
183 | add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
|
---|
184 |
|
---|
185 | set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
---|
186 | set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
|
---|
187 |
|
---|
188 | add_definitions ("-DUSE_CMAKE")
|
---|
189 | add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
|
---|
190 | add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
|
---|
191 | add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
|
---|
192 | add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
|
---|
193 |
|
---|
194 | #----------------------- subdirectories ------------------------------
|
---|
195 |
|
---|
196 | include (CheckIncludeFile)
|
---|
197 | if(CS_ANTICASC)
|
---|
198 | add_definitions ("-DCS_ANTICASC")
|
---|
199 | endif(CS_ANTICASC)
|
---|
200 |
|
---|
201 | if(CS_LOGHISTORY)
|
---|
202 | add_definitions ("-DCS_LOGHISTORY")
|
---|
203 | endif(CS_LOGHISTORY)
|
---|
204 |
|
---|
205 | if(CS_WITH_GBOX)
|
---|
206 | add_definitions ("-DCS_WITH_GBOX")
|
---|
207 | endif(CS_WITH_GBOX)
|
---|
208 |
|
---|
209 | if(CS_LED)
|
---|
210 | add_definitions ("-DCS_LED")
|
---|
211 | endif (CS_LED)
|
---|
212 |
|
---|
213 | if (WEBIF)
|
---|
214 | add_definitions ("-DWEBIF")
|
---|
215 | endif (WEBIF)
|
---|
216 |
|
---|
217 | if(IRDETO_GUESSING)
|
---|
218 | add_definitions ("-DIRDETO_GUESSING")
|
---|
219 | endif (IRDETO_GUESSING)
|
---|
220 |
|
---|
221 | check_include_file ("pthread.h" HAVE_PTHREAD)
|
---|
222 | if (HAVE_PTHREAD)
|
---|
223 | message(STATUS " pthread found. Adding pthread support ")
|
---|
224 | add_definitions ("-DHAVE_PTHREAD_H")
|
---|
225 | elseif (HAVE_PTHREAD)
|
---|
226 | message(STATUS " no pthread found. No smartreader ")
|
---|
227 | endif (HAVE_PTHREAD)
|
---|
228 |
|
---|
229 | check_include_file ("openssl/aes.h" HAVE_AES)
|
---|
230 | if (HAVE_AES)
|
---|
231 | add_definitions ("-DHAVE_AES")
|
---|
232 | endif (HAVE_AES)
|
---|
233 |
|
---|
234 | check_include_file ("openssl/sha.h" HAVE_SHA)
|
---|
235 | if (HAVE_SHA)
|
---|
236 | add_definitions ("-DHAVE_SHA")
|
---|
237 | endif (HAVE_SHA)
|
---|
238 |
|
---|
239 |
|
---|
240 | if (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)
|
---|
264 | else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
265 | set (HAVE_LIBRT True)
|
---|
266 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
267 |
|
---|
268 |
|
---|
269 | if( 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)
|
---|
312 | endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
313 |
|
---|
314 |
|
---|
315 | check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
|
---|
316 | if (HAVE_PCSC)
|
---|
317 | add_definitions ("-DHAVE_PCSC")
|
---|
318 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
319 | add_definitions ("-I/usr/include/PCSC")
|
---|
320 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
321 | else (HAVE_PCSC)
|
---|
322 | if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
323 | add_definitions ("-Icygwin")
|
---|
324 | set (HAVE_PCSC "1")
|
---|
325 | endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
326 | endif (HAVE_PCSC)
|
---|
327 |
|
---|
328 |
|
---|
329 | #----------------------- subdirectories ------------------------------
|
---|
330 |
|
---|
331 | add_subdirectory (csctapi)
|
---|
332 | add_subdirectory (cscrypt)
|
---|
333 | if(CS_WITH_GBOX)
|
---|
334 | add_subdirectory (csgbox)
|
---|
335 | endif(CS_WITH_GBOX)
|
---|
336 | if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
337 | if (HAVE_LIBUSB)
|
---|
338 | add_subdirectory (utils)
|
---|
339 | endif (HAVE_LIBUSB)
|
---|
340 | endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
341 |
|
---|
342 | #----------------------- file groups ------------------------------
|
---|
343 |
|
---|
344 | file (GLOB csmodules_srcs "module-*.c")
|
---|
345 | file (GLOB csmodules_hdrs "module-*.h")
|
---|
346 | file (GLOB csreaders_srcs "reader-*.c")
|
---|
347 | file (GLOB csreaders_hdrs "reader-*.h")
|
---|
348 | file (GLOB csoscam_srcs "oscam-*.c")
|
---|
349 | file (GLOB csoscam_hdrs "oscam-*.h")
|
---|
350 | file (GLOB exe_srcs "oscam.c")
|
---|
351 | file (GLOB exe_hdrs "globals.h")
|
---|
352 | file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
|
---|
353 |
|
---|
354 | #----------------------- modules ------------------------------
|
---|
355 |
|
---|
356 | set (csmodules "csmodules")
|
---|
357 | add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
|
---|
358 |
|
---|
359 | #----------------------- readers ------------------------------
|
---|
360 |
|
---|
361 | set (csreaders "csreaders")
|
---|
362 | add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
|
---|
363 |
|
---|
364 | #----------------------- other oscam files ------------------------------
|
---|
365 |
|
---|
366 | set (csoscam "csoscam")
|
---|
367 | add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
|
---|
368 |
|
---|
369 | #----------------------- the executable ------------------------------
|
---|
370 |
|
---|
371 | set (exe_name "oscam")
|
---|
372 | add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
|
---|
373 | if(CS_WITH_GBOX)
|
---|
374 | target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt csgbox)
|
---|
375 | else(CS_WITHGBOX)
|
---|
376 | target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt)
|
---|
377 | endif(CS_WITH_GBOX)
|
---|
378 | if(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")
|
---|
388 | endif(HAVE_LIBRT AND HAVE_LIBUSB)
|
---|
389 |
|
---|
390 | if (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")
|
---|
400 | endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
|
---|
401 |
|
---|
402 | if (HAVE_PTHREAD)
|
---|
403 | target_link_libraries (${exe_name} pthread)
|
---|
404 | endif (HAVE_PTHREAD)
|
---|
405 |
|
---|
406 | if (HAVE_AES)
|
---|
407 | target_link_libraries (${exe_name} crypto)
|
---|
408 | endif (HAVE_AES)
|
---|
409 |
|
---|
410 | if (HAVE_PCSC)
|
---|
411 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
412 | if (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
413 | target_link_libraries (${exe_name} pcsclite)
|
---|
414 | endif (NOT OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
415 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
416 | endif (HAVE_PCSC)
|
---|
417 |
|
---|
418 |
|
---|
419 | add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
|
---|
420 |
|
---|
421 | #----------------------- specific options ------------------------------
|
---|
422 |
|
---|
423 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
424 | elseif (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})
|
---|
433 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
434 | target_link_libraries ( ${exe_name} dl)
|
---|
435 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
436 | target_link_libraries ( ${exe_name} dl)
|
---|
437 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
438 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
439 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
440 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
441 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
442 | elseif (OSCamOperatingSystem MATCHES "QboxHD")
|
---|
443 | elseif (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)
|
---|
449 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
450 | target_link_libraries ( ${exe_name} rt nxp )
|
---|
451 | elseif (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)
|
---|
455 | endif (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
|
---|
461 | add_dependencies (${exe_name} svnversion)
|
---|
462 | add_dependencies (${csoscam} svnversion-log)
|
---|
463 |
|
---|
464 | # how to re-build the files which printout the version
|
---|
465 | add_custom_target (
|
---|
466 | svnversion
|
---|
467 | ALL
|
---|
468 | touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
|
---|
469 | )
|
---|
470 | add_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.
|
---|
478 | execute_process (COMMAND "svnversion" "-n" "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE OSCAM_SVN_REVISION)
|
---|
479 |
|
---|
480 | if (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}")
|
---|
484 | else (OSCAM_SVN_REVISION)
|
---|
485 | set (OSCAM_SVN_REVISION "0")
|
---|
486 | endif (OSCAM_SVN_REVISION)
|
---|
487 |
|
---|
488 | # pass the version to the compilations as a define
|
---|
489 | add_definitions ("-D'CS_SVN_VERSION=\"${OSCAM_SVN_REVISION}\"'")
|
---|
490 |
|
---|
491 | #----------------------- global compile and link options ------------------------------
|
---|
492 |
|
---|
493 | # some optimisations
|
---|
494 | if (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")
|
---|
496 | elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
|
---|
497 | add_definitions ("-O2 -Winline -Wall -finline-functions -fomit-frame-pointer")
|
---|
498 | else (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")
|
---|
502 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
503 |
|
---|
504 | # we don't want the '-rdynamic' in the link command
|
---|
505 | set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
---|
506 |
|
---|
507 | # we want to strip if not Debug build
|
---|
508 | if (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
509 | set (CMAKE_EXE_LINKER_FLAGS "-s -m32 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")
|
---|
510 | else (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)
|
---|
514 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
515 |
|
---|
516 | if (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
517 | set (CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup")
|
---|
518 | endif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
519 |
|
---|
520 | #----------------------- installation -----------------------------
|
---|
521 |
|
---|
522 | file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
|
---|
523 | file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
|
---|
524 | file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
|
---|
525 | file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
|
---|
526 | file (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")
|
---|
535 | file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
|
---|
536 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
|
---|
537 |
|
---|
538 | install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
|
---|
539 | install (FILES ${config_files} DESTINATION etc COMPONENT config)
|
---|
540 | install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
|
---|
541 | install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
|
---|
542 | install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
|
---|
543 | install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
|
---|
544 | install (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
|
---|
549 | execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
|
---|
550 | OUTPUT_VARIABLE CS_VERSION)
|
---|
551 | string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
|
---|
552 | string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
|
---|
553 | string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
|
---|
554 | string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
|
---|
555 | set (CPACK_PACKAGE_VERSION
|
---|
556 | "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
---|
557 |
|
---|
558 | # compute my filename
|
---|
559 | set (CPACK_PACKAGE_FILE_NAME
|
---|
560 | "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
|
---|
561 |
|
---|
562 | # wich archive we want to generate
|
---|
563 | set (CPACK_GENERATOR "TGZ")
|
---|
564 |
|
---|
565 | # what to put in the archive
|
---|
566 | set (CPACK_STRIP_FILES TRUE)
|
---|
567 | set (CPACK_COMPONENTS_ALL bin)# config doc)
|
---|
568 |
|
---|
569 | # ok, we can now use CPack
|
---|
570 | include (CPack)
|
---|
571 |
|
---|
572 | #----------------------- printout resume -----------------------------
|
---|
573 |
|
---|
574 | message (STATUS "")
|
---|
575 | message (STATUS " operating system: ${OSCamOperatingSystem}")
|
---|
576 | message (STATUS " system type: ${CS_OSTYPE}")
|
---|
577 | message (STATUS " system: ${CS_OS_SYS}")
|
---|
578 | message (STATUS " cpu: ${CS_OS_CPU}")
|
---|
579 | message (STATUS " hw: ${CS_OS_HW}")
|
---|
580 | if (HAVE_AES)
|
---|
581 | message (STATUS " use system aes functions")
|
---|
582 | else (HAVE_AES)
|
---|
583 | message (STATUS " use built-in aes functions")
|
---|
584 | endif (HAVE_AES)
|
---|
585 | if (HAVE_SHA)
|
---|
586 | message (STATUS " use system sha functions")
|
---|
587 | else (HAVE_SHA)
|
---|
588 | message (STATUS " use built-in sha functions")
|
---|
589 | endif (HAVE_SHA)
|
---|
590 | if (HAVE_PCSC)
|
---|
591 | message (STATUS " use system pcsc functions")
|
---|
592 | endif (HAVE_PCSC)
|
---|
593 | if (HAVE_PTHREAD)
|
---|
594 | message (STATUS " use system pthread functions")
|
---|
595 | endif (HAVE_PTHREAD)
|
---|
596 | if (HAVE_LIBUSB)
|
---|
597 | message (STATUS " use system libusb functions")
|
---|
598 | endif (HAVE_LIBUSB)
|
---|
599 | if (WEBIF)
|
---|
600 | message (STATUS " web interface enabled")
|
---|
601 | endif (WEBIF)
|
---|
602 | if (IRDETO_GUESSING)
|
---|
603 | message (STATUS " irdeto guessing enabled")
|
---|
604 | endif (IRDETO_GUESSING)
|
---|
605 | if(CS_WITH_GBOX)
|
---|
606 | message (STATUS " gbox protocol enabled")
|
---|
607 | endif(CS_WITH_GBOX)
|
---|
608 | if(CS_LED)
|
---|
609 | message (STATUS " led trigger support enabled")
|
---|
610 | endif(CS_LED)
|
---|
611 | message (STATUS "")
|
---|