-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
256 lines (229 loc) · 8.57 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
cmake_minimum_required (VERSION 2.8.12)
project (joker_tv)
set (joker_tv_VERSION_MAJOR 1)
set (joker_tv_VERSION_MINOR 12)
set (joker_tv_VERSION_PATCH 0)
set (joker_tv_VERSION
${joker_tv_VERSION_MAJOR}.${joker_tv_VERSION_MINOR}.${joker_tv_VERSION_PATCH})
set(CMAKE_MACOSX_RPATH 1)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release
RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
find_package( Threads REQUIRED)
find_package( PkgConfig )
find_package( LibXml2 )
add_subdirectory("3party/libdvben50221/")
# under OSx we need some system libs for libusb functionality
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_library(LIBIOKit IOKit)
find_library(LIBCoreFoundation CoreFoundation)
find_library(LIBICONV iconv)
find_library(LIBobjc objc)
set(PTHREADS_LIB "pthread")
set(LINUXLIB -Wl,-force_load,${CMAKE_CURRENT_BINARY_DIR}/libjokertv_linux.a)
set(EN50221LIB -Wl,-force_load,${CMAKE_CURRENT_BINARY_DIR}/3party/libdvben50221/libdvben50221.a)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_library(LIBICONV libiconv.a REQUIRED)
set(LIBWS2 "-lws2_32")
set(PTHREADS_LIB "-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
set(LINUXLIB -Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/libjokertv_linux.a -Wl,--no-whole-archive)
set(EN50221LIB -Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/3party/libdvben50221/libdvben50221.a -Wl,--no-whole-archive)
set(INCLUDE_PLATFORM "include/win")
set(EXT_LIBS ${PC_LIBXML_STATIC_LIBRARIES})
set(CFLAGS_USER "${CFLAGS_USER} -DIN_LIBXML")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUXLIB -Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/libjokertv_linux.a -Wl,--no-whole-archive)
set(EN50221LIB -Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/3party/libdvben50221/libdvben50221.a -Wl,--no-whole-archive)
find_library(LIBUDEV udev)
endif()
# build libdvbpsi for TS processing
include(ExternalProject)
ExternalProject_Add(libdvbpsi
GIT_REPOSITORY https://code.videolan.org/videolan/libdvbpsi.git
GIT_TAG "1.3.0"
CONFIGURE_COMMAND ./bootstrap COMMAND ./configure --enable-static
--with-pic
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_COMMAND MACOSX_DEPLOYMENT_TARGET=10.6 make
BUILD_IN_SOURCE 1
)
set(PC_LIBDVBPSI_INCLUDE_DIR
"${CMAKE_CURRENT_BINARY_DIR}/libdvbpsi-prefix/src/libdvbpsi/src/"
"${CMAKE_CURRENT_BINARY_DIR}/libdvbpsi-prefix/src/libdvbpsi/src/descriptors/"
"${CMAKE_CURRENT_BINARY_DIR}/libdvbpsi-prefix/src/libdvbpsi/src/tables/")
set(PC_LIBDVBPSI_LIBRARIES
"${CMAKE_CURRENT_BINARY_DIR}/libdvbpsi-prefix/src/libdvbpsi/src/.libs/libdvbpsi${CMAKE_STATIC_LIBRARY_SUFFIX}")
# Add libusb
# we should build our own libusb with patches for Isoc transfers
# until it not accepted to mainline
include(ExternalProject)
ExternalProject_Add(libusb
GIT_REPOSITORY https://github.com/philemonf/libusb.git
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --enable-static --with-pic
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_COMMAND MACOSX_DEPLOYMENT_TARGET=10.6 make
BUILD_IN_SOURCE 1
)
set(PC_LIBUSB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libusb-prefix/src/libusb//libusb")
set(PC_LIBUSB_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/libusb-prefix/src/libusb/libusb/.libs/libusb-1.0${CMAKE_STATIC_LIBRARY_SUFFIX}")
#set sources list
SET (LINUX_SRC linux/drivers/media/dvb-frontends/helene.c
linux/drivers/media/dvb-frontends/lgdt3306a.c
linux/drivers/media/dvb-frontends/cxd2841er.c
linux/drivers/media/dvb-frontends/cxd2841er_blind_scan.c
linux/drivers/media/dvb-frontends/tps65233.c
linux/drivers/media/dvb-frontends/atbm888x.c
linux/drivers/media/dvb-core/dvb_math.c
src/u_drv_tune.c
src/joker_blind_scan.c)
SET (JOKERTV_SRC src/u_drv_data.c
src/joker_i2c.c
src/joker_fpga.c
src/joker_spi.c
src/joker_ci.c
src/joker_utils.c
src/joker_en50221.c
src/joker_en50221_server.c
3party/libucsi/mpeg/pmt_section.c
3party/libucsi/crc32.c
3party/libucsi/dvb/types.c
src/joker_xml.c
src/joker_ts.c
src/joker_ts_filter.c)
set(KOPTIONS "-include ${CMAKE_SOURCE_DIR}/linux/include/linux/types.h")
set(KINCLUDE_DIRS
${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/linux/
${CMAKE_SOURCE_DIR}/linux/include/
${CMAKE_SOURCE_DIR}/linux/include/uapi
${CMAKE_SOURCE_DIR}/linux/include/uapi/linux/dvb/
${CMAKE_SOURCE_DIR}/linux/drivers/media/dvb-core/)
set(CFLAGS_USER "${CFLAGS_USER} ${PC_LIBUSB_CFLAGS} -D_FILE_OFFSET_BITS=64")
set(INCLUDE_USER
${INCLUDE_PLATFORM}
${LIBXML2_INCLUDE_DIR}
$<BUILD_INTERFACE:include ${PC_LIBDVBPSI_INCLUDE_DIR}>
3party)
set(EXT_LIBS ${EXT_LIBS} ${CMAKE_THREAD_LIBS_INIT}
${PC_LIBDVBPSI_LIBRARIES}
${LIBXML2_LIBRARIES}
${LIBIOKit}
${LIBCoreFoundation}
${LIBobjc}
${LIBUDEV}
${LIBICONV}
${LIBWS2})
#install header files
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include
FILES_MATCHING PATTERN "*.h")
#static lib with kernel stuff
add_library (jokertv_linux STATIC ${LINUX_SRC})
target_include_directories(jokertv_linux PRIVATE ${KINCLUDE_DIRS})
set_source_files_properties(${LINUX_SRC} PROPERTIES COMPILE_FLAGS ${KOPTIONS})
set_target_properties(jokertv_linux PROPERTIES COMPILE_FLAGS "-fPIC")
#combined shared lib
add_library (jokertv SHARED ${JOKERTV_SRC})
set_property(TARGET jokertv PROPERTY VERSION ${joker_tv_VERSION})
set_target_properties(jokertv PROPERTIES COMPILE_FLAGS "${CFLAGS_USER}")
add_dependencies(jokertv libusb libdvbpsi jokertv_linux dvben50221)
target_link_libraries(jokertv
PRIVATE ${LINUXLIB}
PRIVATE ${EN50221LIB}
PRIVATE ${PC_LIBUSB_LIBRARIES}
PRIVATE ${PC_LIBDVBPSI_LIBRARIES}
PRIVATE ${LIBICONV}
PRIVATE ${LIBWS2}
PRIVATE ${PTHREADS_LIB}
PRIVATE ${EXT_LIBS}
)
target_include_directories(jokertv PRIVATE
$<BUILD_INTERFACE:include ${PC_LIBUSB_INCLUDE_DIR}>
#$<BUILD_INTERFACE:include ${PC_LIBDVBPSI_INCLUDE_DIR}/dvbpsi>
${INCLUDE_USER}
"3party/libdvben50221/"
)
#simple program: tune and save TS to file
add_executable(joker-tv src/joker-tv.cc)
set_target_properties(joker-tv PROPERTIES COMPILE_FLAGS "${CFLAGS_USER}")
target_link_libraries(joker-tv jokertv ${EXT_LIBS})
target_include_directories(joker-tv PUBLIC ${INCLUDE_USER} ${PC_LIBUSB_INCLUDE_DIR})
install(TARGETS joker-tv DESTINATION bin)
#simple program to scan i2c bus
add_executable(i2c-scan src/i2c-scan.c)
set_target_properties(i2c-scan PROPERTIES COMPILE_FLAGS "${CFLAGS_USER}")
target_include_directories(i2c-scan PUBLIC ${INCLUDE_USER})
target_link_libraries(i2c-scan jokertv ${EXT_LIBS})
install(TARGETS i2c-scan DESTINATION bin)
# TS stream generate/validate utilities
add_executable(tsgen src/tsgen.c)
target_include_directories(tsgen PUBLIC ${INCLUDE_USER})
target_link_libraries(tsgen ${PC_LIBDVBPSI_LIBRARIES})
add_dependencies(tsgen libdvbpsi)
install(TARGETS tsgen DESTINATION bin)
add_executable(tscheck src/tscheck.c)
target_include_directories(tscheck PUBLIC ${INCLUDE_USER})
install(TARGETS tscheck DESTINATION bin)
##############################################
# prepare cmake files for downstream projects
##############################################
install(TARGETS jokertv EXPORT jokertvTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/jokertv/jokertvConfigVersion.cmake"
VERSION ${joker_tv_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT jokertvTargets
FILE
"${CMAKE_CURRENT_BINARY_DIR}/jokertv/jokertvTargets.cmake"
)
configure_file(cmake/jokertvConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/jokertv/jokertvConfig.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/jokertv)
install(EXPORT jokertvTargets
FILE
jokertvTargets.cmake
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/jokertvConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/jokertv/jokertvConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
######################
# Installers generator
######################
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Joker TV")
SET(CPACK_PACKAGE_VENDOR "Joker Systems Inc.")
SET(CPACK_PACKAGE_VERSION_MAJOR ${joker_tv_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${joker_tv_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${joker_tv_VERSION_PATCH})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CPACK_GENERATOR "DragNDrop;TGZ")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CPACK_GENERATOR "TGZ")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CPACK_GENERATOR "NSIS;ZIP")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
INSTALL(TARGETS jokertv DESTINATION "bin")
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION programs COMPONENT applications)
endif()
INCLUDE(CPack)