1 | project (OSCam C)
|
---|
2 |
|
---|
3 | cmake_minimum_required (VERSION 2.6)
|
---|
4 |
|
---|
5 | #----------------------- detect system ------------------------------
|
---|
6 |
|
---|
7 | if (CMAKE_CROSSCOMPILING)
|
---|
8 | if (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
9 | set (OSCamOperatingSystem "Tuxbox")
|
---|
10 | set (CS_OS_HW "tuxbox")
|
---|
11 | set (CS_OS_SYS "linux")
|
---|
12 | elseif (OSCAM_SYSTEM_NAME MATCHES "Fonera2")
|
---|
13 | set (OSCamOperatingSystem "Fonera2")
|
---|
14 | set (CS_OS_HW "fonera2")
|
---|
15 | set (CS_OS_SYS "linux")
|
---|
16 | elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
|
---|
17 | set (OSCamOperatingSystem "Amino")
|
---|
18 | set (CS_OS_HW "amino")
|
---|
19 | set (CS_OS_SYS "linux")
|
---|
20 | else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
21 | set (OSCamOperatingSystem "Unknown")
|
---|
22 | set (CS_OS_HW "unknown")
|
---|
23 | set (CS_OS_SYS "unknown")
|
---|
24 | endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
|
---|
25 | else (CMAKE_CROSSCOMPILING)
|
---|
26 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
27 | set (OSCamOperatingSystem "Linux")
|
---|
28 | set (CS_OS_HW "pc")
|
---|
29 | set (CS_OS_SYS "linux")
|
---|
30 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
---|
31 | set (OSCamOperatingSystem "Mac OS X")
|
---|
32 | set (CS_OS_HW "mac")
|
---|
33 | set (CS_OS_SYS "macosx")
|
---|
34 | else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
35 | set (OSCamOperatingSystem "Unknown")
|
---|
36 | set (CS_OS_HW "unknown")
|
---|
37 | set (CS_OS_SYS "unknown")
|
---|
38 | endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
---|
39 | endif (CMAKE_CROSSCOMPILING)
|
---|
40 |
|
---|
41 | #----------------------- some paths ------------------------------
|
---|
42 |
|
---|
43 | set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
|
---|
44 | set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
|
---|
45 |
|
---|
46 | include_directories (
|
---|
47 | ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
|
---|
48 | ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
|
---|
49 | ${OPTIONAL_INCLUDE_DIR}
|
---|
50 | )
|
---|
51 | link_directories (${OPTIONAL_LINK_DIR})
|
---|
52 |
|
---|
53 | #----------------------- global options ------------------------------
|
---|
54 |
|
---|
55 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
56 | add_definitions ("-DOS_LINUX")
|
---|
57 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
58 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
59 | add_definitions ("-DOS_MACOSX -DNEED_DAEMON -DCS_NOSHM -DHAVE_PTHREAD_H -DUSE_PTHREAD")
|
---|
60 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
61 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
62 | add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
|
---|
63 | set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
|
---|
64 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
65 | add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
|
---|
66 | set (DEFAULT_CS_CONFDIR "/var/etc")
|
---|
67 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
68 | add_definitions ("-DOS_LINUX")
|
---|
69 | set (DEFAULT_CS_CONFDIR "/usr/local/etc")
|
---|
70 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
71 |
|
---|
72 | set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
|
---|
73 | add_definitions ("-DCS_CONFDIR=\"${CS_CONFDIR}\"")
|
---|
74 |
|
---|
75 | set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
---|
76 | set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
|
---|
77 |
|
---|
78 | add_definitions ("-DUSE_CMAKE")
|
---|
79 | add_definitions ("-DCS_OSTYPE=\"${CS_OSTYPE}\"")
|
---|
80 | add_definitions ("-DCS_OS_CPU=\"${CS_OS_CPU}\"")
|
---|
81 | add_definitions ("-DCS_OS_HW=\"${CS_OS_HW}\"")
|
---|
82 | add_definitions ("-DCS_OS_SYS=\"${CS_OS_SYS}\"")
|
---|
83 |
|
---|
84 | #----------------------- subdirectories ------------------------------
|
---|
85 |
|
---|
86 | include (CheckIncludeFile)
|
---|
87 | check_include_file ("openssl/aes.h" HAVE_AES)
|
---|
88 | if (HAVE_AES)
|
---|
89 | add_definitions ("-DHAVE_AES")
|
---|
90 | endif (HAVE_AES)
|
---|
91 |
|
---|
92 | #----------------------- subdirectories ------------------------------
|
---|
93 |
|
---|
94 | add_subdirectory (csctapi)
|
---|
95 | add_subdirectory (cscrypt)
|
---|
96 |
|
---|
97 | #----------------------- file groups ------------------------------
|
---|
98 |
|
---|
99 | file (GLOB csmodules_srcs "module-*.c")
|
---|
100 | file (GLOB csmodules_hdrs "module-*.h")
|
---|
101 | file (GLOB csreaders_srcs "reader-*.c")
|
---|
102 | file (GLOB csreaders_hdrs "reader-*.h")
|
---|
103 | file (GLOB csoscam_srcs "oscam-*.c")
|
---|
104 | file (GLOB csoscam_hdrs "oscam-*.h")
|
---|
105 | file (GLOB exe_srcs "oscam.c")
|
---|
106 | file (GLOB exe_hdrs "globals.h")
|
---|
107 | file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
|
---|
108 |
|
---|
109 | #----------------------- modules ------------------------------
|
---|
110 |
|
---|
111 | set (csmodules "csmodules")
|
---|
112 | add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
|
---|
113 |
|
---|
114 | #----------------------- readers ------------------------------
|
---|
115 |
|
---|
116 | set (csreaders "csreaders")
|
---|
117 | add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
|
---|
118 |
|
---|
119 | #----------------------- other oscam files ------------------------------
|
---|
120 |
|
---|
121 | set (csoscam "csoscam")
|
---|
122 | add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
|
---|
123 |
|
---|
124 | #----------------------- the executable ------------------------------
|
---|
125 |
|
---|
126 | set (exe_name "oscam")
|
---|
127 | add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
|
---|
128 | if (HAVE_AES)
|
---|
129 | target_link_libraries (${exe_name} crypto)
|
---|
130 | endif (HAVE_AES)
|
---|
131 | target_link_libraries (${exe_name} pthread ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt)
|
---|
132 | add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
|
---|
133 |
|
---|
134 | #----------------------- specific options ------------------------------
|
---|
135 |
|
---|
136 | if (OSCamOperatingSystem MATCHES "Linux")
|
---|
137 | elseif (OSCamOperatingSystem MATCHES "Mac OS X")
|
---|
138 | elseif (OSCamOperatingSystem MATCHES "Tuxbox")
|
---|
139 | target_link_libraries ( ${exe_name} dl)
|
---|
140 | elseif (OSCamOperatingSystem MATCHES "Fonera2")
|
---|
141 | elseif (OSCamOperatingSystem MATCHES "Amino")
|
---|
142 | endif (OSCamOperatingSystem MATCHES "Linux")
|
---|
143 |
|
---|
144 | set_source_files_properties (${all_srcs} PROPERTIES COMPILE_FLAGS "-O3 -Winline -Werror -finline-functions -fomit-frame-pointer")
|
---|
145 |
|
---|
146 | #----------------------- installation -----------------------------
|
---|
147 |
|
---|
148 | file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
|
---|
149 | file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/*.txt")
|
---|
150 |
|
---|
151 | install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name} DESTINATION bin COMPONENT bin)
|
---|
152 | install (FILES ${config_files} DESTINATION etc COMPONENT config)
|
---|
153 | install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
|
---|
154 |
|
---|
155 | #----------------------- printout resume -----------------------------
|
---|
156 |
|
---|
157 | message (STATUS "")
|
---|
158 | message (STATUS " operating system: ${OSCamOperatingSystem}")
|
---|
159 | message (STATUS " system type: ${CS_OSTYPE}")
|
---|
160 | message (STATUS " system: ${CS_OS_SYS}")
|
---|
161 | message (STATUS " cpu: ${CS_OS_CPU}")
|
---|
162 | message (STATUS " hw: ${CS_OS_HW}")
|
---|
163 | if (HAVE_AES)
|
---|
164 | message (STATUS " use system aes functions")
|
---|
165 | else (HAVE_AES)
|
---|
166 | message (STATUS " use built-in aes functions")
|
---|
167 | endif (HAVE_AES)
|
---|
168 | message (STATUS "")
|
---|