1 | project (Utils 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 | ${OPTIONAL_INCLUDE_DIR}
|
---|
87 | )
|
---|
88 |
|
---|
89 | link_directories (${OPTIONAL_LINK_DIR})
|
---|
90 |
|
---|
91 | #----------------------- global options ------------------------------
|
---|
92 |
|
---|
93 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
94 | add_definitions ("-DOS_LINUX")
|
---|
95 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
96 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
97 | add_definitions ("-DOS_MACOSX -DHAVE_PCSC -DNEED_DAEMON -DCS_NOSHM")
|
---|
98 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
99 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
100 | add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
|
---|
101 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
102 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
103 | add_definitions ("-DOS_LINUX -DTRIPLEDRAGON -DHAVE_DVBAPI -DSTB04SCI -DTUXBOX -DPPC")
|
---|
104 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
105 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
106 | add_definitions ("-DOS_LINUX -DTUXBOX -DCOOL")
|
---|
107 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
108 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
109 | add_definitions ("-DOS_LINUX -DARM")
|
---|
110 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
111 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
112 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
|
---|
113 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
114 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
115 | add_definitions ("-DOS_LINUX -DUCLIBC")
|
---|
116 | set (DEFAULT_CS_CONFDIR "/etc")
|
---|
117 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
118 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
|
---|
119 | set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
|
---|
120 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
121 | add_definitions ("-DOS_LINUX")
|
---|
122 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
123 | elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
124 | add_definitions ("-DOS_CYGWIN32 -static")
|
---|
125 | set (DEFAULT_CS_CONFDIR ".")
|
---|
126 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
127 |
|
---|
128 |
|
---|
129 | set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
---|
130 | set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
|
---|
131 |
|
---|
132 | add_definitions ("-DUSE_CMAKE")
|
---|
133 | add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
|
---|
134 | add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
|
---|
135 | add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
|
---|
136 | add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
|
---|
137 |
|
---|
138 | #----------------------- subdirectories ------------------------------
|
---|
139 |
|
---|
140 | include (CheckIncludeFile)
|
---|
141 |
|
---|
142 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
143 | if (LIBRTDIR)
|
---|
144 | check_include_file ("${LIBRTDIR}/include/time.h" HAVE_LIBRT_STATIC)
|
---|
145 | if (HAVE_LIBRT_STATIC)
|
---|
146 | if (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
147 | message(STATUS " static librt found : ${LIBRTDIR}/lib/librt.a (needed by libusb).")
|
---|
148 | add_definitions ("-I${LIBRTDIR}/include/")
|
---|
149 | add_library(utils_imp_librt STATIC IMPORTED)
|
---|
150 | set_property(TARGET utils_imp_librt PROPERTY IMPORTED_LOCATION ${LIBRTDIR}/lib/librt.a)
|
---|
151 | else (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
152 | message(STATUS " ${LIBRTDIR}/lib/librt.a not found (needed by libusb). No smartreader support)")
|
---|
153 | unset (HAVE_LIBRT_STATIC)
|
---|
154 | endif (EXISTS ${LIBRTDIR}/lib/librt.a)
|
---|
155 | else (HAVE_LIBRT_STATIC)
|
---|
156 | message(STATUS " no librt found (needed by libusb). No smartreader support")
|
---|
157 | endif (HAVE_LIBRT_STATIC)
|
---|
158 | else (LIBRTDIR)
|
---|
159 | check_include_file ("time.h" HAVE_LIBRT)
|
---|
160 | if (HAVE_LIBRT)
|
---|
161 | message(STATUS " librt found (needed by libusb).")
|
---|
162 | else (HAVE_LIBRT)
|
---|
163 | message(STATUS " no librt found (needed by libusb. No smartreader support")
|
---|
164 | endif (HAVE_LIBRT)
|
---|
165 | endif (LIBRTDIR)
|
---|
166 | else (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
167 | set (HAVE_LIBRT True)
|
---|
168 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
169 |
|
---|
170 | check_include_file ("pthread.h" HAVE_PTHREAD)
|
---|
171 | if (HAVE_PTHREAD)
|
---|
172 | message(STATUS "Utils: pthread found. Adding pthread support ")
|
---|
173 | add_definitions ("-DHAVE_PTHREAD_H")
|
---|
174 | elseif (HAVE_PTHREAD)
|
---|
175 | message(STATUS "Utils: no pthread found. No smartreader ")
|
---|
176 | unset (HAVE_LIBRT)
|
---|
177 | unset (HAVE_LIBRT_STATIC)
|
---|
178 | endif (HAVE_PTHREAD)
|
---|
179 |
|
---|
180 |
|
---|
181 | if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
182 | if (LIBUSBDIR)
|
---|
183 | check_include_file ("${LIBUSBDIR}/include/libusb-1.0/libusb.h" HAVE_LIBUSB)
|
---|
184 | if (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
185 | if (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
186 | message(STATUS "Utils: static libusb 1.0 found (${LIBUSBDIR}/lib/libusb-1.0.a). Adding smartreader support ")
|
---|
187 | add_definitions ("-DLIBUSB")
|
---|
188 | add_definitions ("-I${LIBUSBDIR}/include/")
|
---|
189 | add_library(utils_imp_libusb STATIC IMPORTED)
|
---|
190 | set_property(TARGET utils_imp_libusb PROPERTY IMPORTED_LOCATION ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
191 | else (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
192 | message(STATUS "Utils: static libusb 1.0 not found (${LIBUSBDIR}/lib/libusb-1.0.a). No smartreader support ")
|
---|
193 | unset(HAVE_LIBUSB)
|
---|
194 | unset(HAVE_LIBRT)
|
---|
195 | unset(HAVE_LIBRT_STATIC)
|
---|
196 | endif (EXISTS ${LIBUSBDIR}/lib/libusb-1.0.a)
|
---|
197 | else (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
198 | message(STATUS "Utils: no libusb 1.0 found. No smartreader support")
|
---|
199 | endif (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
200 | else (LIBUSBDIR)
|
---|
201 | check_include_file ("libusb-1.0/libusb.h" HAVE_LIBUSB)
|
---|
202 | if (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
203 | if (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
204 | message(STATUS "Utils: static libusb 1.0 found : /usr/local/lib/libusb-1.0.a . Adding smartreader support ")
|
---|
205 | add_definitions ("-DLIBUSB")
|
---|
206 | add_definitions ("-I/usr/local/include")
|
---|
207 | add_library(utils_imp_libusb STATIC IMPORTED)
|
---|
208 | set_property(TARGET utils_imp_libusb PROPERTY IMPORTED_LOCATION /usr/local/lib/libusb-1.0.a)
|
---|
209 | elseif (EXISTS /usr/lib/libusb-1.0.a)
|
---|
210 | message(STATUS "Utils: static libusb 1.0 found : /usr/lib/libusb-1.0.a . Adding smartreader support ")
|
---|
211 | add_definitions ("-DLIBUSB")
|
---|
212 | add_library(utils_imp_libusb STATIC IMPORTED)
|
---|
213 | set_property(TARGET utils_imp_libusb PROPERTY IMPORTED_LOCATION /usr/lib/libusb-1.0.a)
|
---|
214 | else (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
215 | message(STATUS "Utils: static libusb 1.0 not found (not in /usr/local/lib/ or /usr/lib/) . No smartreader support ")
|
---|
216 | unset(HAVE_LIBUSB)
|
---|
217 | unset(HAVE_LIBRT)
|
---|
218 | unset(HAVE_LIBRT_STATIC)
|
---|
219 | endif (EXISTS /usr/local/lib/libusb-1.0.a)
|
---|
220 | else (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
221 | message(STATUS " no libusb 1.0 found. No smartreader support")
|
---|
222 | endif (HAVE_LIBUSB AND HAVE_PTHREAD)
|
---|
223 | endif (LIBUSBDIR)
|
---|
224 | endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
225 |
|
---|
226 |
|
---|
227 | if( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|
228 | #---- are we building ?
|
---|
229 | if (HAVE_LIBUSB)
|
---|
230 |
|
---|
231 | #----------------------- file groups ------------------------------
|
---|
232 |
|
---|
233 | file (GLOB exe_srcs "list_smargo.c")
|
---|
234 | file (GLOB exe_hdrs "*.h")
|
---|
235 | file (GLOB all_srcs ${exe_srcs})
|
---|
236 |
|
---|
237 | #----------------------- the executable ------------------------------
|
---|
238 |
|
---|
239 | set (util_name "list_smargo")
|
---|
240 | add_executable (${util_name} ${exe_srcs} ${exe_hdrs})
|
---|
241 |
|
---|
242 | if(HAVE_LIBRT AND HAVE_LIBUSB)
|
---|
243 | target_link_libraries (${util_name} imp_libusb)
|
---|
244 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
245 | target_link_libraries (${util_name} rt)
|
---|
246 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
247 | endif(HAVE_LIBRT AND HAVE_LIBUSB)
|
---|
248 |
|
---|
249 | if (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
|
---|
250 | target_link_libraries (${util_name} imp_libusb)
|
---|
251 | if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
252 | target_link_libraries (${util_name} imp_librt)
|
---|
253 | endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
254 | endif (HAVE_LIBRT_STATIC AND HAVE_LIBUSB)
|
---|
255 |
|
---|
256 | if (HAVE_PTHREAD)
|
---|
257 | target_link_libraries (${util_name} pthread)
|
---|
258 | endif (HAVE_PTHREAD)
|
---|
259 |
|
---|
260 | #----------------------- specific options ------------------------------
|
---|
261 |
|
---|
262 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
263 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
264 | FIND_LIBRARY (IOKit_LIBRARY IOKit)
|
---|
265 | target_link_libraries ( ${util_name} ${IOKit_LIBRARY})
|
---|
266 | FIND_LIBRARY (CoreFoundation_LIBRARY CoreFoundation)
|
---|
267 | target_link_libraries ( ${util_name} ${CoreFoundation_LIBRARY})
|
---|
268 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
269 | target_link_libraries ( ${util_name} dl)
|
---|
270 | elseif (OSCamOperatingSystem MATCHES "TripleDragon")
|
---|
271 | target_link_libraries ( ${util_name} dl)
|
---|
272 | elseif (OSCamOperatingSystem MATCHES "SlugOS")
|
---|
273 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
274 | elseif (OSCamOperatingSystem MATCHES "agv2+w")
|
---|
275 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
276 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
277 | elseif (OSCamOperatingSystem MATCHES "Windows/cygwin")
|
---|
278 | elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
|
---|
279 | target_link_libraries ( ${util_name} rt nxp )
|
---|
280 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
281 |
|
---|
282 | #----------------------- global compile and link options ------------------------------
|
---|
283 |
|
---|
284 | # some optimisations
|
---|
285 | if (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
286 | add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer -m32")
|
---|
287 | else (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
288 | add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer")
|
---|
289 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
290 |
|
---|
291 | # we don't want the '-rdynamic' in the link command
|
---|
292 | set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
---|
293 |
|
---|
294 | # we want to strip
|
---|
295 | if (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
296 | set (CMAKE_EXE_LINKER_FLAGS "-s -m32")
|
---|
297 | else (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
298 | set (CMAKE_EXE_LINKER_FLAGS "-s")
|
---|
299 | endif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
300 |
|
---|
301 | #----------------------- we can use CPack to build pacakges --------------------------
|
---|
302 |
|
---|
303 | # compute my filename
|
---|
304 | set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CS_OSTYPE}")
|
---|
305 |
|
---|
306 |
|
---|
307 | # wich archive we want to generate
|
---|
308 | set (CPACK_GENERATOR "TGZ")
|
---|
309 |
|
---|
310 | # what to put in the archive
|
---|
311 | set (CPACK_STRIP_FILES TRUE)
|
---|
312 | set (CPACK_COMPONENTS_ALL bin)# config doc)
|
---|
313 |
|
---|
314 | # ok, we can now use CPack
|
---|
315 | include (CPack)
|
---|
316 |
|
---|
317 | #----------------------- printout resume -----------------------------
|
---|
318 |
|
---|
319 | message (STATUS "Utils: operating system: ${OSCamOperatingSystem}")
|
---|
320 | message (STATUS "Utils: system type: ${CS_OSTYPE}")
|
---|
321 | message (STATUS "Utils: system: ${CS_OS_SYS}")
|
---|
322 | message (STATUS "Utils: cpu: ${CS_OS_CPU}")
|
---|
323 | message (STATUS "Utils: hw: ${CS_OS_HW}")
|
---|
324 | message (STATUS "Utils: use system static libusb")
|
---|
325 | message (STATUS "")
|
---|
326 | endif (HAVE_LIBUSB)
|
---|
327 | endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)
|
---|