source: branches/merlin/CMakeLists.txt@ 1269

Last change on this file since 1269 was 433, checked in by C.H.A.D.o, 12 years ago

CMake on Windows/Cygwin could not find conf files in "/usr/local/etc"

File size: 10.8 KB
Line 
1project (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
9cmake_minimum_required (VERSION 2.4)
10if(COMMAND cmake_policy)
11 cmake_policy(SET CMP0005 OLD)
12 cmake_policy(SET CMP0003 NEW)
13endif(COMMAND cmake_policy)
14
15#----------------------- detect system ------------------------------
16
17if (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")
40else (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")
60endif (CMAKE_CROSSCOMPILING)
61
62#----------------------- some paths ------------------------------
63
64set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
65set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
66
67include_directories (
68 ${CMAKE_CURRENT_SOURCE_DIR}/include
69 ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
70 ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
71 ${OPTIONAL_INCLUDE_DIR}
72 )
73link_directories (${OPTIONAL_LINK_DIR})
74
75#----------------------- global options ------------------------------
76
77if (OSCamOperatingSystem MATCHES "Linux")
78 add_definitions ("-DOS_LINUX")
79 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
80elseif (OSCamOperatingSystem MATCHES "Mac OS X")
81 add_definitions ("-DOS_MACOSX -DNEED_DAEMON -DCS_NOSHM -DHAVE_PTHREAD_H -DUSE_PTHREAD")
82 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
83elseif (OSCamOperatingSystem MATCHES "Tuxbox")
84 add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
85 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
86elseif (OSCamOperatingSystem MATCHES "Fonera2")
87 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
88 set (DEFAULT_CS_CONFDIR "/var/etc")
89elseif (OSCamOperatingSystem MATCHES "WRT54G")
90 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
91 set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
92elseif (OSCamOperatingSystem MATCHES "Amino")
93 add_definitions ("-DOS_LINUX")
94 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
95elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
96 add_definitions ("-DOS_CYGWIN32")
97 set (DEFAULT_CS_CONFDIR ".")
98endif (OSCamOperatingSystem MATCHES "Linux")
99
100set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
101add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
102
103set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
104set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
105
106add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
107add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
108add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
109add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
110
111#----------------------- subdirectories ------------------------------
112
113include (CheckIncludeFile)
114check_include_file ("openssl/aes.h" HAVE_AES)
115if (HAVE_AES)
116 add_definitions ("-DHAVE_AES")
117endif (HAVE_AES)
118
119#----------------------- subdirectories ------------------------------
120
121add_subdirectory (csctapi)
122add_subdirectory (cscrypt)
123
124#----------------------- file groups ------------------------------
125
126file (GLOB cscam_srcs "src/CAM/*.c")
127file (GLOB cscam_hdrs "include/CAM/*.h")
128
129file (GLOB csreader_srcs "src/reader/*.c")
130file (GLOB csreader_hdrs "include/reader/*.h")
131
132file (GLOB cssharing_srcs "src/sharing/*.c")
133file (GLOB cssharing_hdrs "include/sharing/*.h")
134
135file (GLOB csoscam_srcs "src/*.c")
136file (GLOB csoscam_hdrs "include/*.h")
137
138file (GLOB exe_srcs "src/oscam.c")
139file (GLOB exe_hdrs "include/globals.h")
140
141file (GLOB all_srcs ${cscam_srcs} ${cssharing_srcs} ${csreader_srcs} ${csoscam_srcs} ${exe_srcs})
142
143#----------------------- CAM ----------------------------------
144
145set (cscam "cscam")
146add_library (${cscam} STATIC ${cscam_srcs} ${cscam_hdrs})
147
148#----------------------- reader -------------------------------
149
150set (csreader "csreader")
151add_library (${csreader} STATIC ${csreader_srcs} ${csreader_hdrs})
152
153#----------------------- sharing ------------------------------
154
155set (cssharing "cssharing")
156add_library (${cssharing} STATIC ${cssharing_srcs} ${cssharing_hdrs})
157
158#----------------------- other oscam files ------------------------------
159
160set (csoscam "csoscam")
161add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
162
163#----------------------- the executable ------------------------------
164
165set (exe_name "oscam")
166add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
167target_link_libraries (${exe_name} ${csoscam} ${cscam} ${csreader} ${cssharing} csctapi cscrypt pthread)
168if (HAVE_AES)
169 target_link_libraries (${exe_name} crypto)
170endif (HAVE_AES)
171add_dependencies (${exe_name} ${csoscam} ${cscam} ${csreader} ${cssharing})
172
173#----------------------- specific options ------------------------------
174
175if (OSCamOperatingSystem MATCHES "Linux")
176elseif (OSCamOperatingSystem MATCHES "Mac OS X")
177elseif (OSCamOperatingSystem MATCHES "Tuxbox")
178 target_link_libraries ( ${exe_name} dl)
179elseif (OSCamOperatingSystem MATCHES "Fonera2")
180elseif (OSCamOperatingSystem MATCHES "WRT54G")
181elseif (OSCamOperatingSystem MATCHES "Amino")
182elseif (OSCamOperatingSystem MATCHES "Windows/cygwin")
183endif (OSCamOperatingSystem MATCHES "Linux")
184
185#----------------------- some compile option to better check the code ---------------
186
187set (CMAKE_C_FLAGS_CODECHECK "-Wall -Werror -Wno-strict-aliasing -Wmissing-declarations -Wnested-externs -Wredundant-decls -Wundef -Winline -Waggregate-return -Wbad-function-cast -Wmissing-field-initializers -Wcast-align")
188
189#----------------------- global compile and link options ------------------------------
190
191# some optimisations
192add_definitions ("-O3 -Winline -Werror -finline-functions -fomit-frame-pointer")
193
194# we don't want the '-rdynamic' in the link command
195set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
196
197# we want to strip
198set (CMAKE_EXE_LINKER_FLAGS "-s")
199
200#----------------------- installation -----------------------------
201
202file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
203file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/txt/*.txt")
204file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/man/*.1")
205file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/man/*.5")
206file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.ac"
207 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.cert"
208 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.conf"
209 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.guess"
210 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.ird"
211 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.server"
212 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.services"
213 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.srvid"
214 "${CMAKE_CURRENT_SOURCE_DIR}/Documentation/example/oscam.user")
215file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/monitor/mpcs*.sh"
216 "${CMAKE_CURRENT_SOURCE_DIR}/monitor/mpcs*.tar")
217
218install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
219install (FILES ${config_files} DESTINATION etc COMPONENT config)
220install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
221install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
222install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
223install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
224install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
225
226#----------------------- we can use CPack to build pacakges --------------------------
227
228# get version from source file
229execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/include/globals.h
230 OUTPUT_VARIABLE CS_VERSION)
231string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
232string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
233string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
234string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
235set (CPACK_PACKAGE_VERSION
236 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
237
238# compute my filename
239set (CPACK_PACKAGE_FILE_NAME
240 "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
241
242# wich archive we want to generate
243set (CPACK_GENERATOR "TGZ")
244
245# what to put in the archive
246set (CPACK_STRIP_FILES TRUE)
247set (CPACK_COMPONENTS_ALL bin)# config doc)
248
249# ok, we can now use CPack
250include (CPack)
251
252#----------------------- printout resume -----------------------------
253
254message (STATUS "")
255if (CMAKE_BUILD_TYPE)
256 message (STATUS " build type: ${CMAKE_BUILD_TYPE}")
257else (CMAKE_BUILD_TYPE)
258 message (STATUS " build type: unspecified")
259endif (CMAKE_BUILD_TYPE)
260message (STATUS " operating system: ${OSCamOperatingSystem}")
261message (STATUS " system type: ${CS_OSTYPE}")
262message (STATUS " system: ${CS_OS_SYS}")
263message (STATUS " cpu: ${CS_OS_CPU}")
264message (STATUS " hw: ${CS_OS_HW}")
265if (HAVE_AES)
266 message (STATUS " use system aes functions")
267else (HAVE_AES)
268 message (STATUS " use built-in aes functions")
269endif (HAVE_AES)
270message (STATUS "")
Note: See TracBrowser for help on using the repository browser.