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# Conditional libpcap support 69find_package(PCAP) 70if( ${PCAP_FOUND} ) 71 include_directories(${PCAP_INCLUDE_DIRS}) 72 target_link_libraries(btbb ${PCAP_LIBRARIES}) 73 add_definitions( -DUSE_PCAP ) 74endif( ${PCAP_FOUND} ) 75 76if( ${UNIX} ) 77 install(TARGETS btbb 78 LIBRARY DESTINATION lib${LIB_SUFFIX} 79 COMPONENT sharedlibs 80 ) 81 install(FILES ${c_headers} 82 DESTINATION include 83 COMPONENT headers 84 ) 85endif( ${UNIX} ) 86 87if( ${WIN32} ) 88 install(TARGETS btbb 89 DESTINATION bin 90 COMPONENT staticlibs 91 ) 92 install(FILES ${c_headers} 93 DESTINATION include 94 COMPONENT headers 95 ) 96endif( ${WIN32} ) 97