-
Notifications
You must be signed in to change notification settings - Fork 64
/
CMakeLists.txt
97 lines (79 loc) · 3.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required(VERSION 3.4)
project(ble++)
set(PROJECT_VERSION "1.2")
set(PROJECT_DESCRIPTION "Bluetooth LE interface for C++")
set(CMAKE_CXX_STANDARD 11)
set(TARGET1_NAME ${PROJECT_NAME} CACHE INTERNAL "")
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release")
endif()
option(WITH_EXAMPLES "Build examples" OFF)
include(GNUInstallDirs)
#----------------------- LIBRARY --------------------------------
set(HEADERS
blepp/bledevice.h
blepp/logging.h
blepp/float.h
blepp/uuid.h
blepp/pretty_printers.h
blepp/gap.h
blepp/lescan.h
blepp/xtoa.h
blepp/att.h
blepp/blestatemachine.h
blepp/att_pdu.h)
set(SRC
src/att_pdu.cc
src/float.cc
src/logging.cc
src/uuid.cc
src/blestatemachine.cc
src/bledevice.cc
src/pretty_printers.cc
src/att.cc
src/lescan.cc
${HEADERS})
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
find_package(Bluez REQUIRED)
include_directories(${PROJECT_SOURCE_DIR} ${BLUEZ_INCLUDE_DIRS})
add_library(${PROJECT_NAME} SHARED ${SRC})
target_link_libraries(${PROJECT_NAME} ${BLUEZ_LIBRARIES})
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CMAKE_CXX_STANDARD_REQUIRED YES
SOVERSION 5)
#----------------------- EXAMPLES --------------------------------
if(WITH_EXAMPLES)
set(EXAMPLES
examples/lescan.cc
examples/blelogger.cc
examples/bluetooth.cc
examples/lescan_simple.cc
examples/temperature.cc)
foreach (example_src ${EXAMPLES})
get_filename_component(example_name ${example_src} NAME_WE)
add_executable(${example_name} ${example_src})
target_link_libraries(${example_name} ${BLUEZ_LIBRARIES} ${PROJECT_NAME})
set_target_properties(${example_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY examples)
set_target_properties(${example_name} PROPERTIES
CXX_STANDARD 11
CMAKE_CXX_STANDARD_REQUIRED YES
RUNTIME_OUTPUT_DIRECTORY examples)
endforeach()
endif()
#----------------------- PKG CONFIGURATION --------------------------------
message(STATUS "Package Ble++ for ${CMAKE_BUILD_TYPE} version ${PROJECT_VERSION}")
set(TARGET1 ${TARGET1_NAME})
set(PackagingTemplatesDir "${CMAKE_CURRENT_SOURCE_DIR}/packaging")
# Generate pkg-config file
configure_file("${PackagingTemplatesDir}/libblepp.pc.in" ${CMAKE_CURRENT_BINARY_DIR}/libblepp.pc @ONLY)
#----------------------- INSTALL --------------------------------
install(TARGETS ${TARGET1_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY blepp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libblepp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)