PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/build/CMakeLists.txt

http://bdremote-ng.googlecode.com/
CMake | 316 lines | 197 code | 92 blank | 27 comment | 0 complexity | 4451b6ecb7fcc9c5908e377b3477a5ac MD5 | raw file
  1cmake_minimum_required (VERSION 2.6)
  2project (bdremote-ng C)
  3
  4SET(CMAKE_INSTALL_PREFIX "")
  5
  6OPTION(USE_SPLINT "Run splint after compiling" OFF)
  7
  8OPTION(ENABLE_REPEAT "Enable key repeat." OFF)
  9
 10IF(ENABLE_REPEAT)
 11  message(STATUS "Repeat enabled.")
 12  ADD_DEFINITIONS("-DENABLE_REPEAT=1")
 13ELSE(ENABLE_REPEAT)
 14  message(STATUS "Repeat disabled.")
 15  ADD_DEFINITIONS("-DENABLE_REPEAT=0")
 16ENDIF(ENABLE_REPEAT)
 17
 18#
 19# Version check.
 20#
 21
 22IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gen-release.sh)
 23
 24  SET(BDREMOTENGHEADER "")
 25  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../src/bdremoteng.h BDREMOTENGHEADER)
 26  SET(BDREMOTENGHEADER_VERSION "")
 27  string(REGEX MATCH "#define VERSION \"(.+)\"" BDREMOTENGHEADER_VERSION ${BDREMOTENGHEADER})
 28  SET(BDREMOTENGHEADER_VERSION ${CMAKE_MATCH_1})
 29
 30  SET(BDREMOTENGINSTALLSCRIPT "")
 31  file(READ ${CMAKE_CURRENT_SOURCE_DIR}/gen-release.sh BDREMOTENGINSTALLSCRIPT)
 32  SET(BDREMOTENGINSTALLSCRIPT_VERSION "")
 33  string(REGEX MATCH "VER=\"([0-9.]+)\"" BDREMOTENGINSTALLSCRIPT_VERSION ${BDREMOTENGINSTALLSCRIPT})
 34  SET(BDREMOTENGINSTALLSCRIPT_VERSION ${CMAKE_MATCH_1})
 35  
 36  string(COMPARE EQUAL ${BDREMOTENGHEADER_VERSION} ${BDREMOTENGINSTALLSCRIPT_VERSION} VERSION_EQ)
 37
 38  IF(NOT ${VERSION_EQ})
 39    message(FATAL_ERROR "Version in gen-release.sh and src/bdremoteng.h differs! ('${BDREMOTENGHEADER_VERSION}' vs '${BDREMOTENGINSTALLSCRIPT_VERSION}'.)")
 40  ELSE(NOT ${VERSION_EQ})
 41    message(STATUS "Building software version: ${BDREMOTENGHEADER_VERSION}.")
 42  ENDIF(NOT ${VERSION_EQ})
 43ELSE(EXISTS  ${CMAKE_CURRENT_SOURCE_DIR}/gen-release.sh)
 44  message(STATUS "Building software version: check disabled ..")
 45ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gen-release.sh)
 46
 47#
 48# Header file checks:
 49#
 50
 51INCLUDE(CheckIncludeFiles)
 52INCLUDE(CheckLibraryExists)
 53
 54CHECK_INCLUDE_FILES ("malloc.h" HAVE_MALLOC_H)
 55IF(NOT HAVE_MALLOC_H)
 56  message(FATAL_ERROR "Required malloc header not found.")
 57ENDIF(NOT HAVE_MALLOC_H)
 58
 59CHECK_INCLUDE_FILES ("bluetooth/bluetooth.h;bluetooth/hci.h;bluetooth/hci_lib.h;bluetooth/l2cap.h" HAVE_BLUETOOTH_H)
 60IF(NOT HAVE_BLUETOOTH_H)
 61  message(FATAL_ERROR "Required bluetooth headers not found.")
 62ENDIF(NOT HAVE_BLUETOOTH_H)
 63
 64CHECK_INCLUDE_FILES ("pthread.h" HAVE_PTHREAD_H)
 65IF(NOT HAVE_PTHREAD_H)
 66  message(FATAL_ERROR "Required pthread header not found.")
 67ENDIF(NOT HAVE_PTHREAD_H)
 68
 69CHECK_INCLUDE_FILES ("getopt.h" HAVE_GETOPT_H)
 70IF(NOT HAVE_GETOPT_H)
 71  message(FATAL_ERROR "Required getopt(..) header not found.")
 72ENDIF(NOT HAVE_GETOPT_H)
 73
 74
 75
 76#
 77# Link checks:
 78# 
 79
 80CHECK_LIBRARY_EXISTS (bluetooth str2ba "" HAVE_BLUETOOTH_LIB)
 81
 82IF(NOT HAVE_BLUETOOTH_LIB)
 83  message(FATAL_ERROR "Required bluetooth library not found.")
 84ENDIF(NOT HAVE_BLUETOOTH_LIB)
 85
 86CHECK_LIBRARY_EXISTS (pthread pthread_create "" HAVE_PTHREAD_LIB)
 87
 88IF(NOT HAVE_PTHREAD_LIB)
 89  message(FATAL_ERROR "Required pthread library not found.")
 90ENDIF(NOT HAVE_PTHREAD_LIB)
 91
 92include(splint.cmake)
 93
 94# Prefix used for all files.
 95SET(PREFIX "../src/")
 96
 97SET(GENERIC_HEADERS
 98${PREFIX}/bdrcfg.h  
 99${PREFIX}/captureif.h
100${PREFIX}/globaldefs.h
101${PREFIX}/keydef.h
102${PREFIX}/lirc_srv.h
103${PREFIX}/q.h
104${PREFIX}/l.h
105${PREFIX}/event_out.h
106)
107
108SET(GENERIC_SOURCES
109${PREFIX}/bdrcfg.c
110${PREFIX}/captureif.c
111${PREFIX}/globaldefs.c
112${PREFIX}/lirc_callback.c
113${PREFIX}/lirc_srv.c
114${PREFIX}/lirc_thr.c
115${PREFIX}/lirc_util.c
116${PREFIX}/q.c
117${PREFIX}/l.c
118${PREFIX}/event_out.c
119)
120
121include_directories (${PREFIX})
122
123add_library (bdremoteng_generic ${GENERIC_HEADERS} ${GENERIC_SOURCES} )
124
125IF(USE_SPLINT)
126
127  FOREACH(F ${GENERIC_HEADERS})
128    add_splint ("bdremoteng_generic" ${F})  
129  ENDFOREACH(F)
130  
131  FOREACH(F ${GENERIC_SOURCES})
132    add_splint ("bdremoteng_generic" ${F})  
133  ENDFOREACH(F)
134
135ENDIF(USE_SPLINT)
136
137
138install(FILES ${GENERIC_SOURCES} ${GENERIC_HEADERS} DESTINATION src)
139
140SET(BLUEZCAP_HEADERS
141${PREFIX}/capture/capture_bluez.h
142)
143
144SET(BLUEZCAP_SOURCES
145${PREFIX}/capture/capture_bluez.c
146)
147
148add_library (bdremoteng_bluezcap ${BLUEZCAP_HEADERS} ${BLUEZCAP_SOURCES})
149
150IF(USE_SPLINT)
151
152  FOREACH(F ${BLUEZCAP_HEADERS})
153    add_splint ("bdremoteng_bluezcap" ${F})  
154  ENDFOREACH(F)
155  
156  FOREACH(F ${BLUEZCAP_SOURCES})
157    add_splint ("bdremoteng_bluezcap" ${F})  
158  ENDFOREACH(F)
159
160ENDIF(USE_SPLINT)
161
162install(FILES ${BLUEZCAP_SOURCES} ${BLUEZCAP_HEADERS} DESTINATION src/capture)
163
164#
165# Application.
166# 
167
168SET(APP_HEADERS
169${PREFIX}/bdremoteng.h
170${PREFIX}/ug.h
171)
172
173SET(APP_SOURCES
174${PREFIX}/bdremoteng.c
175${PREFIX}/ug.c
176)
177
178add_executable (bdremoteng ${APP_HEADERS} ${APP_SOURCES})
179
180IF(USE_SPLINT)
181
182  FOREACH(F ${APP_HEADERS})
183    add_splint ("bdremoteng" ${F})  
184  ENDFOREACH(F)
185  
186  FOREACH(F ${APP_SOURCES})
187    add_splint ("bdremoteng" ${F})  
188  ENDFOREACH(F)
189
190ENDIF(USE_SPLINT)
191
192install(FILES ${APP_HEADERS} ${APP_SOURCES} DESTINATION src)
193
194target_link_libraries(bdremoteng bdremoteng_bluezcap bdremoteng_generic) 
195target_link_libraries(bdremoteng -lbluetooth)
196target_link_libraries(bdremoteng -lpthread)
197
198#
199# Capture test.
200# 
201
202SET(PREFIX "../test")
203
204SET(TEST_HEADERS
205)
206
207SET(TEST_SOURCES
208${PREFIX}/capture_test.c
209)
210
211add_executable (capturetest ${TEST_HEADERS} ${TEST_SOURCES})
212
213install(FILES ${TEST_HEADERS} ${TEST_SOURCES} DESTINATION test)
214
215target_link_libraries(capturetest bdremoteng_bluezcap bdremoteng_generic) 
216target_link_libraries(capturetest -lbluetooth)
217target_link_libraries(capturetest -lpthread)
218
219# 
220# Queue test.
221# 
222
223SET(PREFIX "../test")
224
225SET(Q_TEST_HEADERS
226)
227
228SET(Q_TEST_SOURCES
229${PREFIX}/qtest.c
230)
231
232add_executable (qtest ${Q_TEST_HEADERS} ${Q_TEST_SOURCES})
233
234install(FILES ${Q_TEST_HEADERS} ${Q_TEST_SOURCES} DESTINATION test)
235
236target_link_libraries(qtest bdremoteng_generic) 
237#target_link_libraries(capturetest -lbluetooth)
238target_link_libraries(qtest -lpthread)
239
240SET(T_TEST_HEADERS
241)
242
243SET(T_TEST_SOURCES
244${PREFIX}/ttest.c
245)
246
247add_executable (ttest ${T_TEST_HEADERS} ${T_TEST_SOURCES})
248
249install(FILES ${T_TEST_HEADERS} ${T_TEST_SOURCES} DESTINATION test)
250
251target_link_libraries(ttest bdremoteng_generic) 
252target_link_libraries(ttest -lpthread)
253
254# Extra build files.
255
256SET(PREFIX ".")
257
258SET(BUILD_FILES
259${PREFIX}/CMakeLists.txt
260${PREFIX}/splint.cmake
261)
262
263install(FILES ${BUILD_FILES} DESTINATION build)
264
265# Make the script used to run cmake executable.
266SET(BUILD_FILES
267${PREFIX}/gen.sh
268)
269
270install(FILES ${BUILD_FILES} 
271        DESTINATION build
272        PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
273)
274
275
276SET(PREFIX "../doc")
277
278SET(DOCS_FILES
279${PREFIX}/keys.txt
280${PREFIX}/README
281${PREFIX}/TODO
282)
283
284install(FILES ${DOCS_FILES} DESTINATION doc)
285
286SET(PREFIX "../")
287
288SET(MISC_FILES
289${PREFIX}/ChangeLog
290${PREFIX}/COPYING
291${PREFIX}/AUTHORS
292)
293
294install(FILES ${MISC_FILES} DESTINATION .)
295
296# 
297# Stuff needed to create a source installation.
298#
299
300# This does not seem to work, and CPack is very badly documented.'
301# And it does not get any better with time.
302
303set(CPACK_PACKAGE_VERSION_MAJOR "0")
304set(CPACK_PACKAGE_VERSION_MINOR "1")
305set(CPACK_PACKAGE_VERSION_PATCH "0")
306set(CPACK_SOURCE_GENERATOR "TBZ2")
307set(CPACK_SOURCE_PACKAGE_FILE_NAME
308  "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
309set(CPACK_SOURCE_IGNORE_FILES
310  "/build/linux;/.svn/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
311
312SET(CPACK_PACKAGE_EXECUTABLES "bdremoteng;bdremoteng")
313
314include(CPack)
315
316