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