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