CMakeLists.txt: Add support to specifying Bluez version at build time

pull/118/head
Olivier Martin 2019-07-14 12:43:37 +02:00 committed by Olivier Martin
parent 4f8625cedf
commit e5daed3484
2 changed files with 25 additions and 12 deletions

View File

@ -42,10 +42,12 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
# Expose 'gattlib.h' to all sub-directories # Expose 'gattlib.h' to all sub-directories
include_directories(include) include_directories(include)
# Check version of Bluez to know which backend we use (ie: Bluez code or DBus) if (NOT BLUEZ_VERSION)
pkg_search_module(BLUEZ bluez) # Check version of Bluez to know which backend we use (ie: Bluez code or DBus)
if (NOT BLUEZ_FOUND) pkg_search_module(BLUEZ bluez)
message(FATAL_ERROR "Please install 'libbluetooth-dev'") if (NOT BLUEZ_FOUND)
message(FATAL_ERROR "Please install 'libbluetooth-dev'")
endif()
endif() endif()
# Extract Bluez version # Extract Bluez version

View File

@ -3,14 +3,7 @@
GattLib is a library used to access Generic Attribute Profile (GATT) protocol of BLE (Bluetooth Low Energy) devices. GattLib is a library used to access Generic Attribute Profile (GATT) protocol of BLE (Bluetooth Low Energy) devices.
It has been introduced to allow to build applications that could easily communicate with BLE devices. It has been introduced to allow to build applications that could easily communicate with BLE devices.
It supports Bluez v4 and v5. On Bluez versions prior to v5.42, gattlib used Bluez source code while it uses D-Bus API It supports Bluez v4 and v5.
from v5.42. D-Bus API can be used on version prior to Bluez v5.42 by using the CMake flag `-DGATTLIB_FORCE_DBUS=TRUE`:
```
mkdir build && cd build
cmake -DGATTLIB_FORCE_DBUS=TRUE ..
make
```
Latest GattLib Release packages Latest GattLib Release packages
=============================== ===============================
@ -51,6 +44,24 @@ cmake ..
make make
``` ```
* Gattlib can also be built for a specific version of Bluez by specifying its version at build time:
```
mkdir build && cd build
cmake -DBLUEZ_VERSION=TRUE ..
make
```
* **On Bluez versions prior to v5.42**, gattlib used Bluez source code while it uses D-Bus API
from v5.42. D-Bus API can be used on version prior to Bluez v5.42 by using the CMake flag `-DGATTLIB_FORCE_DBUS=TRUE`:
```
mkdir build && cd build
cmake -DGATTLIB_FORCE_DBUS=TRUE ..
make
```
### Cross-Compilation ### Cross-Compilation
To cross-compile GattLib, you must provide the following environment variables: To cross-compile GattLib, you must provide the following environment variables: