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