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 "Fonera2")
|
---|
23 | set (OSCamOperatingSystem "Fonera2")
|
---|
24 | set (CS_OS_HW "fonera2")
|
---|
25 | set (CS_OS_SYS "linux")
|
---|
26 | elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
|
---|
27 | set (OSCamOperatingSystem "WRT54G")
|
---|
28 | set (CS_OS_HW "wrt54g")
|
---|
29 | set (CS_OS_SYS "linux")
|
---|
30 | elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
|
---|
31 | set (OSCamOperatingSystem "Amino")
|
---|
32 | set (CS_OS_HW "amino")
|
---|
33 | set (CS_OS_SYS "linux")
|
---|
34 | else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
35 | message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
|
---|
36 | set (OSCamOperatingSystem "Unknown")
|
---|
37 | set (CS_OS_HW "unknown")
|
---|
38 | set (CS_OS_SYS "unknown")
|
---|
39 | endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
40 | else (CMAKE_CROSSCOMPILING)
|
---|
41 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
42 | set (OSCamOperatingSystem "Linux")
|
---|
43 | set (CS_OS_HW "pc")
|
---|
44 | set (CS_OS_SYS "linux")
|
---|
45 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
---|
46 | set (OSCamOperatingSystem "Mac OS X")
|
---|
47 | set (CS_OS_HW "mac")
|
---|
48 | set (CS_OS_SYS "macosx")
|
---|
49 | elseif (${CYGWIN})
|
---|
50 | set (OSCamOperatingSystem "Windows/Cygwin")
|
---|
51 | set (CS_OS_HW "pc")
|
---|
52 | set (CS_OS_SYS "cygwin")
|
---|
53 | set (CMAKE_SYSTEM_PROCESSOR "i386")
|
---|
54 | else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
55 | message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
|
---|
56 | set (OSCamOperatingSystem "Unknown")
|
---|
57 | set (CS_OS_HW "unknown")
|
---|
58 | set (CS_OS_SYS "unknown")
|
---|
59 | endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
60 | endif (CMAKE_CROSSCOMPILING)
|
---|
61 |
|
---|
62 | #----------------------- some paths ------------------------------
|
---|
63 |
|
---|
64 | set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
|
---|
65 | set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
|
---|
66 |
|
---|
67 | include_directories (
|
---|
68 | ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
|
---|
69 | ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
|
---|
70 | ${OPTIONAL_INCLUDE_DIR}
|
---|
71 | )
|
---|
72 | link_directories (${OPTIONAL_LINK_DIR})
|
---|
73 |
|
---|
74 | #----------------------- global options ------------------------------
|
---|
75 |
|
---|
76 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
77 | add_definitions ("-DOS_LINUX")
|
---|
78 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
79 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
80 | add_definitions ("-DOS_MACOSX -DNEED_DAEMON -DCS_NOSHM -DHAVE_PTHREAD_H -DUSE_PTHREAD")
|
---|
81 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
82 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
83 | add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
|
---|
84 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
85 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
86 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
|
---|
87 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
88 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
89 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
|
---|
90 | set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
|
---|
91 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
92 | add_definitions ("-DOS_LINUX")
|
---|
93 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
94 | elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
|
---|
95 | add_definitions ("-DOS_CYGWIN32 -static")
|
---|
96 | set (DEFAULT_CS_CONFDIR ".")
|
---|
97 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
98 |
|
---|
99 | set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
|
---|
100 | add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
|
---|
101 |
|
---|
102 | set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
---|
103 | set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
|
---|
104 |
|
---|
105 | add_definitions ("-DUSE_CMAKE")
|
---|
106 | add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
|
---|
107 | add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
|
---|
108 | add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
|
---|
109 | add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
|
---|
110 |
|
---|
111 | #----------------------- subdirectories ------------------------------
|
---|
112 |
|
---|
113 | include (CheckIncludeFile)
|
---|
114 | check_include_file ("openssl/aes.h" HAVE_AES)
|
---|
115 | if (HAVE_AES)
|
---|
116 | add_definitions ("-DHAVE_AES")
|
---|
117 | endif (HAVE_AES)
|
---|
118 |
|
---|
119 | #----------------------- subdirectories ------------------------------
|
---|
120 |
|
---|
121 | add_subdirectory (csctapi)
|
---|
122 | add_subdirectory (cscrypt)
|
---|
123 |
|
---|
124 | #----------------------- file groups ------------------------------
|
---|
125 |
|
---|
126 | file (GLOB csmodules_srcs "module-*.c")
|
---|
127 | file (GLOB csmodules_hdrs "module-*.h")
|
---|
128 | file (GLOB csreaders_srcs "reader-*.c")
|
---|
129 | file (GLOB csreaders_hdrs "reader-*.h")
|
---|
130 | file (GLOB csoscam_srcs "oscam-*.c")
|
---|
131 | file (GLOB csoscam_hdrs "oscam-*.h")
|
---|
132 | file (GLOB exe_srcs "oscam.c")
|
---|
133 | file (GLOB exe_hdrs "globals.h")
|
---|
134 | file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
|
---|
135 |
|
---|
136 | #----------------------- modules ------------------------------
|
---|
137 |
|
---|
138 | set (csmodules "csmodules")
|
---|
139 | add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
|
---|
140 |
|
---|
141 | #----------------------- readers ------------------------------
|
---|
142 |
|
---|
143 | set (csreaders "csreaders")
|
---|
144 | add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
|
---|
145 |
|
---|
146 | #----------------------- other oscam files ------------------------------
|
---|
147 |
|
---|
148 | set (csoscam "csoscam")
|
---|
149 | add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
|
---|
150 |
|
---|
151 | #----------------------- the executable ------------------------------
|
---|
152 |
|
---|
153 | set (exe_name "oscam")
|
---|
154 | add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
|
---|
155 | target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt pthread)
|
---|
156 | if (HAVE_AES)
|
---|
157 | target_link_libraries (${exe_name} crypto)
|
---|
158 | endif (HAVE_AES)
|
---|
159 | add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
|
---|
160 |
|
---|
161 | #----------------------- specific options ------------------------------
|
---|
162 |
|
---|
163 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
164 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
165 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
166 | target_link_libraries ( ${exe_name} dl)
|
---|
167 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
168 | elseif (OSCamOperatingSystem MATCHES "WRT54G")
|
---|
169 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
170 | elseif (OSCamOperatingSystem MATCHES "Windows/cygwin")
|
---|
171 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
172 |
|
---|
173 | #----------------------- global compile and link options ------------------------------
|
---|
174 |
|
---|
175 | # some optimisations
|
---|
176 | add_definitions ("-O3 -Winline -Werror -finline-functions -fomit-frame-pointer")
|
---|
177 |
|
---|
178 | # we don't want the '-rdynamic' in the link command
|
---|
179 | set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
---|
180 |
|
---|
181 | # we want to strip
|
---|
182 | set (CMAKE_EXE_LINKER_FLAGS "-s")
|
---|
183 |
|
---|
184 | #----------------------- installation -----------------------------
|
---|
185 |
|
---|
186 | file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
|
---|
187 | file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
|
---|
188 | file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
|
---|
189 | file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
|
---|
190 | file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
|
---|
191 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
|
---|
192 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
|
---|
193 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
|
---|
194 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
|
---|
195 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
|
---|
196 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
|
---|
197 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
|
---|
198 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
|
---|
199 | file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
|
---|
200 | "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
|
---|
201 |
|
---|
202 | install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
|
---|
203 | install (FILES ${config_files} DESTINATION etc COMPONENT config)
|
---|
204 | install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
|
---|
205 | install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
|
---|
206 | install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
|
---|
207 | install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
|
---|
208 | install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
|
---|
209 |
|
---|
210 | #----------------------- we can use CPack to build pacakges --------------------------
|
---|
211 |
|
---|
212 | # get version from source file
|
---|
213 | execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
|
---|
214 | OUTPUT_VARIABLE CS_VERSION)
|
---|
215 | string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
|
---|
216 | string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
|
---|
217 | string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
|
---|
218 | string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
|
---|
219 | set (CPACK_PACKAGE_VERSION
|
---|
220 | "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
---|
221 |
|
---|
222 | # compute my filename
|
---|
223 | set (CPACK_PACKAGE_FILE_NAME
|
---|
224 | "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
|
---|
225 |
|
---|
226 | # wich archive we want to generate
|
---|
227 | set (CPACK_GENERATOR "TGZ")
|
---|
228 |
|
---|
229 | # what to put in the archive
|
---|
230 | set (CPACK_STRIP_FILES TRUE)
|
---|
231 | set (CPACK_COMPONENTS_ALL bin)# config doc)
|
---|
232 |
|
---|
233 | # ok, we can now use CPack
|
---|
234 | include (CPack)
|
---|
235 |
|
---|
236 | #----------------------- printout resume -----------------------------
|
---|
237 |
|
---|
238 | message (STATUS "")
|
---|
239 | message (STATUS " operating system: ${OSCamOperatingSystem}")
|
---|
240 | message (STATUS " system type: ${CS_OSTYPE}")
|
---|
241 | message (STATUS " system: ${CS_OS_SYS}")
|
---|
242 | message (STATUS " cpu: ${CS_OS_CPU}")
|
---|
243 | message (STATUS " hw: ${CS_OS_HW}")
|
---|
244 | if (HAVE_AES)
|
---|
245 | message (STATUS " use system aes functions")
|
---|
246 | else (HAVE_AES)
|
---|
247 | message (STATUS " use built-in aes functions")
|
---|
248 | endif (HAVE_AES)
|
---|
249 | message (STATUS "")
|
---|