xref: /libbtbb/lib/src/CMakeLists.txt (revision 4f840bce6bcf4b888f8aa3a6239132d39ad8a28e)
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# FIXME Set static release version here to avoid pulling from git
22set(RELEASE "")
23
24if ( "${RELEASE}" STREQUAL "" )
25	# automatic git version when working out of git
26	include(GetGitRevisionDescription)
27	get_git_head_revision(GIT_REFSPEC RELEASE)
28endif()
29
30add_definitions( -DRELEASE="${RELEASE}" )
31
32# Source
33set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_packet.c
34              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_piconet.c
35              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_le_packet.c
36              ${CMAKE_CURRENT_SOURCE_DIR}/pcap.c
37              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng.c
38              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng-bt.c
39			  CACHE INTERNAL "List of C sources")
40set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/btbb.h
41			  CACHE INTERNAL "List of C headers")
42
43# For cygwin just force UNIX OFF and WIN32 ON
44if( ${CYGWIN} )
45	SET(UNIX OFF)
46	SET(WIN32 ON)
47endif( ${CYGWIN} )
48
49# FIXME: This may be a hack
50# perhaps there should be separate libbtbb and libbtbb-static targets?
51if( ${WIN32} )
52	# Static library
53	add_library(btbb STATIC ${c_sources})
54	set_target_properties(btbb PROPERTIES OUTPUT_NAME "btbb_static")
55else()
56	# Dynamic library
57	add_library(btbb SHARED ${c_sources})
58	set_target_properties(btbb PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION} SOVERSION 0)
59endif()
60
61set_target_properties(btbb PROPERTIES CLEAN_DIRECT_OUTPUT 1)
62
63# PCAP Support
64if( (NOT DEFINED USE_PCAP) OR USE_PCAP )
65	find_package(PCAP)
66
67	if( USE_PCAP AND NOT ${PCAP_FOUND} )
68		message( FATAL_ERROR
69			"Cannot find libpcap, which is required for USE_PCAP")
70	endif()
71
72	if( ${PCAP_FOUND} )
73		include_directories(${PCAP_INCLUDE_DIRS})
74		target_link_libraries(btbb ${PCAP_LIBRARIES})
75		add_definitions( -DENABLE_PCAP )
76	endif( ${PCAP_FOUND} )
77endif( (NOT DEFINED USE_PCAP) OR USE_PCAP )
78
79if( ${UNIX} )
80   install(TARGETS btbb
81           LIBRARY DESTINATION lib${LIB_SUFFIX}
82           COMPONENT sharedlibs
83           )
84   install(FILES ${c_headers}
85           DESTINATION include
86           COMPONENT headers
87           )
88endif( ${UNIX} )
89
90if( ${WIN32} )
91   install(TARGETS btbb
92           DESTINATION bin
93           COMPONENT staticlibs
94           )
95   install(FILES ${c_headers}
96           DESTINATION include
97           COMPONENT headers
98           )
99endif( ${WIN32} )
100