xref: /libbtbb/lib/src/CMakeLists.txt (revision 5cf4c9cb441aa735be0ac77081632db31c920700)
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			  CACHE INTERNAL "List of C sources")
26set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_le_packet.h
27              ${CMAKE_CURRENT_SOURCE_DIR}/btbb.h
28			  CACHE INTERNAL "List of C headers")
29
30# For cygwin just force UNIX OFF and WIN32 ON
31if( ${CYGWIN} )
32	SET(UNIX OFF)
33	SET(WIN32 ON)
34endif( ${CYGWIN} )
35
36# FIXME: This may be a hack
37# perhaps there should be separate libbtbb and libbtbb-static targets?
38if( ${WIN32} )
39	# Static library
40	add_library(btbb STATIC ${c_sources})
41	set_target_properties(btbb PROPERTIES OUTPUT_NAME "btbb_static")
42else()
43	# Dynamic library
44	add_library(btbb SHARED ${c_sources})
45	set_target_properties(btbb PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION} SOVERSION 0)
46endif()
47
48set_target_properties(btbb PROPERTIES CLEAN_DIRECT_OUTPUT 1)
49
50# Conditional libpcap support
51find_package(PCAP)
52if( ${PCAP_FOUND} )
53	include_directories(${PCAP_INCLUDE_DIRS})
54	target_link_libraries(btbb ${PCAP_LIBRARIES})
55	add_definitions( -DUSE_PCAP )
56endif( ${PCAP_FOUND} )
57
58if( ${UNIX} )
59   install(TARGETS btbb
60           LIBRARY DESTINATION lib${LIB_SUFFIX}
61           COMPONENT sharedlibs
62           )
63   install(FILES ${c_headers}
64           DESTINATION include
65           COMPONENT headers
66           )
67endif( ${UNIX} )
68
69if( ${WIN32} )
70   install(TARGETS btbb
71           DESTINATION bin
72           COMPONENT staticlibs
73           )
74   install(FILES ${c_headers}
75           DESTINATION include
76           COMPONENT headers
77           )
78endif( ${WIN32} )
79