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 68if( (NOT DEFINED USE_PCAP) OR USE_PCAP ) 69 find_package(PCAP) 70 71 if( USE_PCAP AND NOT ${PCAP_FOUND} ) 72 message( FATAL_ERROR 73 "Cannot find libpcap, which is required for USE_PCAP") 74 endif() 75 76 if( ${PCAP_FOUND} ) 77 include_directories(${PCAP_INCLUDE_DIRS}) 78 target_link_libraries(btbb ${PCAP_LIBRARIES}) 79 add_definitions( -DUSE_PCAP ) 80 endif( ${PCAP_FOUND} ) 81endif( (NOT DEFINED USE_PCAP) OR USE_PCAP ) 82 83if( ${UNIX} ) 84 install(TARGETS btbb 85 LIBRARY DESTINATION lib${LIB_SUFFIX} 86 COMPONENT sharedlibs 87 ) 88 install(FILES ${c_headers} 89 DESTINATION include 90 COMPONENT headers 91 ) 92endif( ${UNIX} ) 93 94if( ${WIN32} ) 95 install(TARGETS btbb 96 DESTINATION bin 97 COMPONENT staticlibs 98 ) 99 install(FILES ${c_headers} 100 DESTINATION include 101 COMPONENT headers 102 ) 103endif( ${WIN32} ) 104