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 "agv2+w")
|
---|
39 | set (OSCamOperatingSystem "agv2+w")
|
---|
40 | set (CS_OS_HW "agv2+w")
|
---|
41 | set (CS_OS_SYS "linux")
|
---|
42 | elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
|
---|
43 | set (OSCamOperatingSystem "WRT54G")
|
---|
44 | set (CS_OS_HW "wrt54g")
|
---|
45 | set (CS_OS_SYS "linux")
|
---|
46 | elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
|
---|
47 | set (OSCamOperatingSystem "Amino")
|
---|
48 | set (CS_OS_HW "amino")
|
---|
49 | set (CS_OS_SYS "linux")
|
---|
50 | else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
51 | message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
|
---|
52 | set (OSCamOperatingSystem "Unknown")
|
---|
53 | set (CS_OS_HW "unknown")
|
---|
54 | set (CS_OS_SYS "unknown")
|
---|
55 | endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
56 | else (CMAKE_CROSSCOMPILING)
|
---|
57 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
58 | set (OSCamOperatingSystem "Linux")
|
---|
59 | set (CS_OS_HW "pc")
|
---|
60 | set (CS_OS_SYS "linux")
|
---|
61 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
---|
62 | set (OSCamOperatingSystem "Mac OS X")
|
---|
63 | set (CS_OS_HW "mac")
|
---|
64 | set (CS_OS_SYS "macosx")
|
---|
65 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
---|
66 | SET( CMAKE_CFLAGS "${CMAKE_CFLAGS} -m32" )
|
---|
67 | elseif (${CYGWIN})
|
---|
68 | set (OSCamOperatingSystem "Windows/Cygwin")
|
---|
69 | set (CS_OS_HW "pc")
|
---|
70 | set (CS_OS_SYS "cygwin")
|
---|
71 | set (CMAKE_SYSTEM_PROCESSOR "i386")
|
---|
72 | else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
73 | message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
|
---|
74 | set (OSCamOperatingSystem "Unknown")
|
---|
75 | set (CS_OS_HW "unknown")
|
---|
76 | set (CS_OS_SYS "unknown")
|
---|
77 | endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
78 | endif (CMAKE_CROSSCOMPILING)
|
---|
79 |
|
---|
80 | #----------------------- some paths ------------------------------
|
---|
81 |
|
---|
82 | set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
|
---|
83 | set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
|
---|
84 |
|
---|
85 | include_directories (
|
---|
86 | ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
|
---|
87 | ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
|
---|
88 | ${OPTIONAL_INCLUDE_DIR}
|
---|
89 | )
|
---|
90 | link_directories (${OPTIONAL_LINK_DIR})
|
---|
91 |
|
---|
92 | #----------------------- global options ------------------------------
|
---|
93 |
|
---|
94 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
95 | add_definitions ("-DOS_LINUX")
|
---|
96 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
97 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
98 | add_definitions ("-DOS_MACOSX -DHAVE_PCSC -DNEED_DAEMON -DCS_NOSHM")
|
---|
99 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
100 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
101 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
102 | if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
---|
103 | add_definitions ("-DOS_LINUX -DTUXBOX -DMIPSEL")
|
---|
104 | else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
---|
105 | add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
|
---|
106 | endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
---|
107 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
108 | add_definitions ("-DOS_LINUX -DTRIPLEDRAGON -DHAVE_DVBAPI -DSTB04SCI -DTUXBOX -DPPC")
|
---|
109 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
110 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
111 | add_definitions ("-DOS_LINUX -DTUXBOX -DCOOL")
|
---|
112 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
113 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
114 | add_definitions ("-DOS_LINUX -DARM")
|
---|
115 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
116 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
117 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
|
---|
118 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
119 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
120 | add_definitions ("-DOS_LINUX -DUCLIBC")
|
---|
121 | set (DEFAULT_CS_CONFDIR "/etc")
|
---|
122 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
123 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
|
---|
124 | set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
|
---|
125 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
126 | add_definitions ("-DOS_LINUX")
|
---|
127 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
128 | elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
129 | add_definitions ("-DOS_CYGWIN32 -static")
|
---|
130 | set (DEFAULT_CS_CONFDIR ".")
|
---|
131 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
132 |
|
---|
133 | set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
|
---|
134 | add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
|
---|
135 |
|
---|
136 | set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
---|
137 | set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
|
---|
138 |
|
---|
139 | add_definitions ("-DUSE_CMAKE")
|
---|
140 | add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
|
---|
141 | add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
|
---|
142 | add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
|
---|
143 | add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
|
---|
144 |
|
---|
145 | #----------------------- subdirectories ------------------------------
|
---|
146 |
|
---|
147 | include (CheckIncludeFile)
|
---|
148 | check_include_file ("pthread.h" HAVE_PTHREAD)
|
---|
149 | if (HAVE_PTHREAD)
|
---|
150 | message(STATUS " pthread found. Adding pthread support ")
|
---|
151 | add_definitions ("-DHAVE_PTHREAD_H")
|
---|
152 | elseif (HAVE_PTHREAD)
|
---|
153 | message(STATUS " no pthread found. No smartreader ")
|
---|
154 | endif (HAVE_PTHREAD)
|
---|
155 |
|
---|
156 | check_include_file ("openssl/aes.h" HAVE_AES)
|
---|
157 | if (HAVE_AES)
|
---|
158 | add_definitions ("-DHAVE_AES")
|
---|
159 | endif (HAVE_AES)
|
---|
160 |
|
---|
161 | check_include_file ("openssl/sha.h" HAVE_SHA)
|
---|
162 | if (HAVE_SHA)
|
---|
163 | add_definitions ("-DHAVE_SHA")
|
---|
164 | endif (HAVE_SHA)
|
---|
165 |
|
---|
166 |
|
---|
167 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
168 | if (LIBRTDIR)
|
---|
169 | check_include_file ("${LIBRTDIR}/include/time.h" HAVE_LIBRT_STATIC)
|
---|
170 | if (HAVE_LIBRT_STATIC)
|
---|
171 | if (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
172 | message(STATUS " static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).")
|
---|
173 | add_definitions ("-I${LIBRTDIR}/include/")
|
---|
174 | add_library(imp_librt STATIC IMPORTED)
|
---|
175 | set_property(TARGET imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a)
|
---|
176 | else (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
177 | message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb. No smartreader support)")
|
---|
178 | unset (HAVE_LIBRT_STATIC)
|
---|
179 | endif (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
180 | elseif (HAVE_LIBRT_STATIC)
|
---|
181 | message(STATUS " no librt found (needed by libusb. No smartreader support")
|
---|
182 | endif (HAVE_LIBRT_STATIC)
|
---|
183 | else (LIBRTDIR)
|
---|
184 | check_include_file ("time.h" HAVE_LIBRT)
|
---|
185 | if (HAVE_LIBRT)
|
---|
186 | message(STATUS " librt found (needed by libusb).")
|
---|
187 | target_link_libraries (${exe_name} rt)
|
---|
188 | else (HAVE_LIBRT)
|
---|
189 | message(STATUS " no librt found (needed by libusb. No smartreader support")
|
---|
190 | endif (HAVE_LIBRT)
|
---|
191 | endif (LIBRTDIR)
|
---|
192 | else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
193 | set (HAVE_LIBRT True)
|
---|
194 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
195 |
|
---|
196 |
|
---|
197 | if (LIBUSBDIR)
|
---|
198 | check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB)
|
---|
199 | if (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
200 | if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
201 | message(STATUS " static libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ")
|
---|
202 | add_definitions ("-DLIBUSB")
|
---|
203 | add_definitions ("-I${LIBUSBDIR}/include/")
|
---|
204 | add_library(imp_libusb STATIC IMPORTED)
|
---|
205 | set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
206 | else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
207 | unset(HAVE_LIBUSB)
|
---|
208 | unset(HAVE_LIBRT)
|
---|
209 | unset(HAVE_LIBRT_STATIC)
|
---|
210 | endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
211 | elseif (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
212 | message(STATUS " no libusb 1.0 found or missing librt. No smartreader support")
|
---|
213 | endif (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
214 | else (LIBUSBDIR)
|
---|
215 | check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB)
|
---|
216 | if (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
217 | if (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
218 | message(STATUS " static libusb 1.0 found : /usr/local/lib/libusb-1.0.a . Adding smartreader support ")
|
---|
219 | add_definitions ("-DLIBUSB")
|
---|
220 | add_definitions ("-I/usr/local/include")
|
---|
221 | add_library(imp_libusb STATIC IMPORTED)
|
---|
222 | set_property(TARGET imp_libusb PROPERTY IMPORTED_LOCATION /usr/local/lib/libusb-1.0.a)
|
---|
223 | else (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
224 | unset(HAVE_LIBUSB)
|
---|
225 | unset(HAVE_LIBRT)
|
---|
226 | unset(HAVE_LIBRT_STATIC)
|
---|
227 | endif (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
228 | else (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
229 | message(STATUS " no libusb 1.0 found or missing librt. No smartreader support")
|
---|
230 | endif (HAVE_LIBUSB AND HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
231 | endif (LIBUSBDIR)
|
---|
232 |
|
---|
233 |
|
---|
234 |
|
---|
235 |
|
---|
236 | check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
|
---|
237 | if (HAVE_PCSC)
|
---|
238 | add_definitions ("-DHAVE_PCSC")
|
---|
239 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
240 | add_definitions ("-I/usr/include/PCSC")
|
---|
241 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
242 | endif (HAVE_PCSC)
|
---|
243 |
|
---|
244 | #----------------------- subdirectories ------------------------------
|
---|
245 |
|
---|
246 | add_subdirectory (csctapi)
|
---|
247 | add_subdirectory (cscrypt)
|
---|
248 | if (HAVE_LIBUSB)
|
---|
249 | add_subdirectory (utils)
|
---|
250 | endif (HAVE_LIBUSB)
|
---|
251 |
|
---|
252 | #----------------------- file groups ------------------------------
|
---|
253 |
|
---|
254 | file (GLOB csmodules_srcs "module-*.c")
|
---|
255 | file (GLOB csmodules_hdrs "module-*.h")
|
---|
256 | file (GLOB csreaders_srcs "reader-*.c")
|
---|
257 | file (GLOB csreaders_hdrs "reader-*.h")
|
---|
258 | file (GLOB csoscam_srcs "oscam-*.c")
|
---|
259 | file (GLOB csoscam_hdrs "oscam-*.h")
|
---|
260 | file (GLOB exe_srcs "oscam.c")
|
---|
261 | file (GLOB exe_hdrs "globals.h")
|
---|
262 | file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
|
---|
263 |
|
---|
264 | #----------------------- modules ------------------------------
|
---|
265 |
|
---|
266 | set (csmodules "csmodules")
|
---|
267 | add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
|
---|
268 |
|
---|
269 | #----------------------- readers ------------------------------
|
---|
270 |
|
---|
271 | set (csreaders "csreaders")
|
---|
272 | add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
|
---|
273 |
|
---|
274 | #----------------------- other oscam files ------------------------------
|
---|
275 |
|
---|
276 | set (csoscam "csoscam")
|
---|
277 | add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
|
---|
278 |
|
---|
279 | #----------------------- the executable ------------------------------
|
---|
280 |
|
---|
281 | set (exe_name "oscam")
|
---|
282 | add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
|
---|
283 | target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt)
|
---|
284 | if (HAVE_PTHREAD)
|
---|
285 | target_link_libraries (${exe_name} pthread)
|
---|
286 | endif (HAVE_PTHREAD)
|
---|
287 |
|
---|
288 | if (HAVE_AES)
|
---|
289 | target_link_libraries (${exe_name} crypto)
|
---|
290 | endif (HAVE_AES)
|
---|
291 | if (HAVE_PCSC)
|
---|
292 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
293 | target_link_libraries (${exe_name} pcsclite)
|
---|
294 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
295 | endif (HAVE_PCSC)
|
---|
296 |
|
---|
297 | if (HAVE_LIBUSB)
|
---|
298 | target_link_libraries (${exe_name} imp_libusb)
|
---|
299 | endif (HAVE_LIBUSB)
|
---|
300 |
|
---|
301 | if (HAVE_LIBRT_STATIC)
|
---|
302 | target_link_libraries (${exe_name} imp_librt)
|
---|
303 | endif (HAVE_LIBRT_STATIC)
|
---|
304 |
|
---|
305 | if(HAVE_LIBRT AND NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
306 | target_link_libraries (${exe_name} rt)
|
---|
307 | endif(HAVE_LIBRT AND NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
308 |
|
---|
309 | add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
|
---|
310 |
|
---|
311 | #----------------------- specific options ------------------------------
|
---|
312 |
|
---|
313 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
314 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
315 | FIND_LIBRARY (PCSC_LIBRARY PCSC)
|
---|
316 | message (STATUS "OS X system PCSC : ${PCSC_LIBRARY}")
|
---|
317 | target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
|
---|
318 | set (HAVE_PCSC "1")
|
---|
319 | FIND_LIBRARY (IOKit_LIBRARY IOKit)
|
---|
320 | target_link_libraries ( ${exe_name} ${IOKit_LIBRARY})
|
---|
321 | FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
|
---|
322 | target_link_libraries ( ${exe_name} ${CoreFoundation_LIBRARY})
|
---|
323 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
324 | target_link_libraries ( ${exe_name} dl)
|
---|
325 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
326 | target_link_libraries ( ${exe_name} dl)
|
---|
327 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
328 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
329 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
330 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
331 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
332 | elseif (OSCamOperatingSystem MATCHES "Windows/cygwin")
|
---|
333 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
334 | target_link_libraries ( ${exe_name} rt nxp )
|
---|
335 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
336 |
|
---|
337 | #----------------------- put svnversion in the build ------------------------------
|
---|
338 | # at every target rebuild, we re-build the oscam.c compilation...
|
---|
339 |
|
---|
340 | # add the needed dependency
|
---|
341 | add_dependencies (${exe_name} svnversion)
|
---|
342 | add_dependencies (${csoscam} svnversion-log)
|
---|
343 |
|
---|
344 | # how to re-build the files which printout the version
|
---|
345 | add_custom_target (
|
---|
346 | svnversion
|
---|
347 | ALL
|
---|
348 | touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
|
---|
349 | )
|
---|
350 | add_custom_target (
|
---|
351 | svnversion-log
|
---|
352 | ALL
|
---|
353 | touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
|
---|
354 | )
|
---|
355 |
|
---|
356 | #if the svnversion program is absent, this will leave the SVN_REVISION string empty,
|
---|
357 | #but won't stop CMake.
|
---|
358 | execute_process (COMMAND "svnversion" "-n" "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE OSCAM_SVN_REVISION)
|
---|
359 |
|
---|
360 | if (OSCAM_SVN_REVISION)
|
---|
361 | string (REGEX REPLACE "[0-9]+:" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
|
---|
362 | string (REPLACE "M" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
|
---|
363 | string (REPLACE "exported" "0" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
|
---|
364 | else (OSCAM_SVN_REVISION)
|
---|
365 | set (OSCAM_SVN_REVISION "0")
|
---|
366 | endif (OSCAM_SVN_REVISION)
|
---|
367 |
|
---|
368 | # pass the version to the compilations as a define
|
---|
369 | add_definitions ("-D'CS_SVN_VERSION=\"${OSCAM_SVN_REVISION}\"'")
|
---|
370 |
|
---|
371 | #----------------------- global compile and link options ------------------------------
|
---|
372 |
|
---|
373 | # some optimisations
|
---|
374 | if (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
375 | add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer -m32")
|
---|
376 | else (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
377 | add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer")
|
---|
378 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
379 |
|
---|
380 | # we don't want the '-rdynamic' in the link command
|
---|
381 | set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
---|
382 |
|
---|
383 | # we want to strip
|
---|
384 | if (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
385 | set (CMAKE_EXE_LINKER_FLAGS "-s -m32")
|
---|
386 | else (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
387 | set (CMAKE_EXE_LINKER_FLAGS "-s")
|
---|
388 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
389 | #----------------------- installation -----------------------------
|
---|
390 |
|
---|
391 | file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
|
---|
392 | file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
|
---|
393 | file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
|
---|
394 | file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
|
---|
395 | file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
|
---|
396 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
|
---|
397 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
|
---|
398 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
|
---|
399 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
|
---|
400 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
|
---|
401 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
|
---|
402 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
|
---|
403 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
|
---|
404 | file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
|
---|
405 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
|
---|
406 |
|
---|
407 | install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
|
---|
408 | install (FILES ${config_files} DESTINATION etc COMPONENT config)
|
---|
409 | install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
|
---|
410 | install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
|
---|
411 | install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
|
---|
412 | install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
|
---|
413 | install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
|
---|
414 |
|
---|
415 | #----------------------- we can use CPack to build pacakges --------------------------
|
---|
416 |
|
---|
417 | # get version from source file
|
---|
418 | execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
|
---|
419 | OUTPUT_VARIABLE CS_VERSION)
|
---|
420 | string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
|
---|
421 | string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
|
---|
422 | string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
|
---|
423 | string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
|
---|
424 | set (CPACK_PACKAGE_VERSION
|
---|
425 | "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
---|
426 |
|
---|
427 | # compute my filename
|
---|
428 | set (CPACK_PACKAGE_FILE_NAME
|
---|
429 | "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
|
---|
430 |
|
---|
431 | # wich archive we want to generate
|
---|
432 | set (CPACK_GENERATOR "TGZ")
|
---|
433 |
|
---|
434 | # what to put in the archive
|
---|
435 | set (CPACK_STRIP_FILES TRUE)
|
---|
436 | set (CPACK_COMPONENTS_ALL bin)# config doc)
|
---|
437 |
|
---|
438 | # ok, we can now use CPack
|
---|
439 | include (CPack)
|
---|
440 |
|
---|
441 | #----------------------- printout resume -----------------------------
|
---|
442 |
|
---|
443 | message (STATUS "")
|
---|
444 | message (STATUS " operating system: ${OSCamOperatingSystem}")
|
---|
445 | message (STATUS " system type: ${CS_OSTYPE}")
|
---|
446 | message (STATUS " system: ${CS_OS_SYS}")
|
---|
447 | message (STATUS " cpu: ${CS_OS_CPU}")
|
---|
448 | message (STATUS " hw: ${CS_OS_HW}")
|
---|
449 | if (HAVE_AES)
|
---|
450 | message (STATUS " use system aes functions")
|
---|
451 | else (HAVE_AES)
|
---|
452 | message (STATUS " use built-in aes functions")
|
---|
453 | endif (HAVE_AES)
|
---|
454 | if (HAVE_SHA)
|
---|
455 | message (STATUS " use system sha functions")
|
---|
456 | else (HAVE_SHA)
|
---|
457 | message (STATUS " use built-in sha functions")
|
---|
458 | endif (HAVE_SHA)
|
---|
459 | if (HAVE_PCSC)
|
---|
460 | message (STATUS " use system pcsc functions")
|
---|
461 | endif (HAVE_PCSC)
|
---|
462 | if (HAVE_PTHREAD)
|
---|
463 | message (STATUS " use system pthread functions")
|
---|
464 | endif (HAVE_PTHREAD)
|
---|
465 | if (HAVE_LIBUSB)
|
---|
466 | message (STATUS " use system libusb functions")
|
---|
467 | endif (HAVE_LIBUSB)
|
---|
468 | message (STATUS "")
|
---|