xref: /libbtbb/lib/src/CMakeLists.txt (revision 1b6084db537fc44a8544216a62d67e015d1605c9)
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
21include(${PROJECT_SOURCE_DIR}/../cmake/set_release.cmake)
22add_definitions( -DRELEASE="${RELEASE_STRING}" )
23message(STATUS "Setting version string ${RELEASE_STRING}")
24
25# Source
26set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_packet.c
27              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_piconet.c
28              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_le_packet.c
29              ${CMAKE_CURRENT_SOURCE_DIR}/companies.c
30              ${CMAKE_CURRENT_SOURCE_DIR}/pcap.c
31              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng.c
32              ${CMAKE_CURRENT_SOURCE_DIR}/pcapng-bt.c
33			  CACHE INTERNAL "List of C sources")
34set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/btbb.h
35			  CACHE INTERNAL "List of C headers")
36
37if( NOT ${BUILD_SHARED_LIB} AND NOT ${BUILD_STATIC} )
38	message( FATAL_ERROR "Not building static or shared library - at least one must be built")
39endif( NOT ${BUILD_SHARED_LIB} AND NOT ${BUILD_STATIC} )
40
41set(CMAKE_MACOSX_RPATH 1)
42
43if( ${BUILD_SHARED_LIB} )
44    # Shared library
45    message(STATUS "Building shared library")
46    add_library(btbb SHARED ${c_sources})
47    set_target_properties(btbb PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION} SOVERSION 1)
48    set_target_properties(btbb PROPERTIES CLEAN_DIRECT_OUTPUT 1)
49    install(TARGETS btbb
50            LIBRARY DESTINATION lib${LIB_SUFFIX}
51            COMPONENT sharedlibs)
52endif( ${BUILD_SHARED_LIB} )
53
54if( ${BUILD_STATIC_LIB} )
55    # Static library
56    message(STATUS "Building static library")
57    add_library(btbb-static STATIC ${c_sources})
58    set_target_properties(btbb-static PROPERTIES OUTPUT_NAME "btbb")
59    set_target_properties(btbb-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
60    install(TARGETS btbb-static
61            DESTINATION lib${LIB_SUFFIX}
62            COMPONENT staticlibs)
63endif( ${BUILD_STATIC_LIB} )
64
65install(FILES ${c_headers}
66        DESTINATION include
67        COMPONENT headers
68        )
69