edrosten / libblepp

Modern clean C++ Bluetooth Low Energy on Linux without the Bluez DBUS API
Other
241 stars 63 forks source link

add a ProjectConfig.cmake ? #42

Open JimmyDaSilva opened 5 years ago

JimmyDaSilva commented 5 years ago

Hi everyone,

Thanks @edrosten for the great package and others for the switch to CMake. To complete this, it would be nice to add a config.cmake file has described here : https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file

Then it could be easy to include this package in another cmake project. Here is my first quick attempt... https://github.com/JimmyDaSilva/libblepp/tree/config.cmake The only issue I saw is that it doesn't not include the bluez required cmake, so I had to include it manually in my other CMake project.

edrosten commented 5 years ago

Did you manage to solve the problem of not including Bluez? If you want you can make a PR to this project.

JimmyDaSilva commented 5 years ago

@JimmyDaSilva I managed to include Bluez, but not to properly add a ProjectConfig.cmake. When I have time I'll make this happen

JimmyDaSilva commented 5 years ago

In case someone tries to do something similar, I have started to do something on my fork: https://github.com/JimmyDaSilva/libblepp/tree/config.cmake

Finding liblepp works, but it doesn't grab bluez with it when finding the package liblepp... I am a not an expert in CMake at all...

Basically I have to do this in my CMakelist.txt:

# search blepp
find_package(blepp REQUIRED)

# look for Bluez...
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(Bluez REQUIRED)

include_directories(
...
    ${BLEPP_INCLUDE_DIRS}
    ${BLUEZ_INCLUDE_DIRS}
)

I feel like dealing with Bluez should not be done here as if you have blepp installed, it should be included with it.

Also, I might have confused libblepp or blepp is some places ... ble++ is not an acceptable name from CMake's perspective by the way.

But if you find this acceptable, I can pull request as is.