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