xref: /libbtbb/lib/src/CMakeLists.txt (revision ddbdc52a7b13ca1c5e42c5475c3ed2c6395c5b5b)
1#
2# This file is part of Libbtbb.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING.  If not, write to
16# the Free Software Foundation, Inc., 51 Franklin Street,
17# Boston, MA 02110-1301, USA.
18#
19# Based slightly upon the hackrf cmake setup.
20
21# Source
22set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_packet.c
23              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_piconet.c
24              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_le_packet.c
25              ${CMAKE_CURRENT_SOURCE_DIR}/pcap.c
26              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng.c
27              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng-bt.c
28			  CACHE INTERNAL "List of C sources")
29set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/btbb.h
30			  CACHE INTERNAL "List of C headers")
31
32# For cygwin just force UNIX OFF and WIN32 ON
33if( ${CYGWIN} )
34	SET(UNIX OFF)
35	SET(WIN32 ON)
36endif( ${CYGWIN} )
37
38# FIXME: This may be a hack
39# perhaps there should be separate libbtbb and libbtbb-static targets?
40if( ${WIN32} )
41	# Static library
42	add_library(btbb STATIC ${c_sources})
43	set_target_properties(btbb PROPERTIES OUTPUT_NAME "btbb_static")
44else()
45	# Dynamic library
46	add_library(btbb SHARED ${c_sources})
47	set_target_properties(btbb PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION} SOVERSION 0)
48endif()
49
50set_target_properties(btbb PROPERTIES CLEAN_DIRECT_OUTPUT 1)
51
52# Conditional libpcap support
53find_package(PCAP)
54if( ${PCAP_FOUND} )
55	include_directories(${PCAP_INCLUDE_DIRS})
56	target_link_libraries(btbb ${PCAP_LIBRARIES})
57	add_definitions( -DUSE_PCAP )
58endif( ${PCAP_FOUND} )
59
60if( ${UNIX} )
61   install(TARGETS btbb
62           LIBRARY DESTINATION lib${LIB_SUFFIX}
63           COMPONENT sharedlibs
64           )
65   install(FILES ${c_headers}
66           DESTINATION include
67           COMPONENT headers
68           )
69endif( ${UNIX} )
70
71if( ${WIN32} )
72   install(TARGETS btbb
73           DESTINATION bin
74           COMPONENT staticlibs
75           )
76   install(FILES ${c_headers}
77           DESTINATION include
78           COMPONENT headers
79           )
80endif( ${WIN32} )
81