xref: /btstack/port/qt-h4/CMakeLists.txt (revision 31437b52049f7a1b5a54d9c71f935fe16cc0e09d)
1cmake_minimum_required(VERSION 3.5)
2
3project(qt-h4 LANGUAGES C CXX)
4
5set(CMAKE_INCLUDE_CURRENT_DIR ON)
6
7set(CMAKE_AUTOUIC ON)
8set(CMAKE_AUTOMOC ON)
9set(CMAKE_AUTORCC ON)
10
11set(CMAKE_CXX_STANDARD 11)
12set(CMAKE_CXX_STANDARD_REQUIRED ON)
13
14message("${Qt5_DIR}")
15
16find_package(Qt5Core)
17find_package(FindPython3)
18
19# BTstack Root
20set(BTSTACK_ROOT "${PROJECT_SOURCE_DIR}/../..")
21message("BTSTACK_ROOT: ${BTSTACK_ROOT}")
22
23# BTstack include
24include_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc)
25include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include)
26include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include)
27include_directories(${BTSTACK_ROOT}/3rd-party/md5)
28include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player)
29include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod)
30include_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include)
31include_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server)
32include_directories(${BTSTACK_ROOT}/3rd-party/rijndael)
33include_directories(${BTSTACK_ROOT}/3rd-party/yxml)
34include_directories(${BTSTACK_ROOT}/3rd-party/tinydir)
35include_directories(${BTSTACK_ROOT}/chipset/bcm)
36include_directories(${BTSTACK_ROOT}/chipset/cc256x)
37include_directories(${BTSTACK_ROOT}/chipset/csr)
38include_directories(${BTSTACK_ROOT}/src)
39include_directories(${BTSTACK_ROOT}/platform/posix)
40include_directories(${BTSTACK_ROOT}/platform/embedded)
41include_directories(${BTSTACK_ROOT}/platform/lwip)
42include_directories(${BTSTACK_ROOT}/platform/lwip/port)
43include_directories(${BTSTACK_ROOT}/platform/qt)
44include_directories(.)
45
46# BTstack sources
47file(GLOB SOURCES_SRC       "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c")
48file(GLOB SOURCES_BLE       "${BTSTACK_ROOT}/src/ble/*.c")
49file(GLOB SOURCES_GATT      "${BTSTACK_ROOT}/src/ble/gatt-service/*.c")
50file(GLOB SOURCES_CLASSIC   "${BTSTACK_ROOT}/src/classic/*.c")
51file(GLOB SOURCES_MESH      "${BTSTACK_ROOT}/src/mesh/*.c")
52file(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c")
53file(GLOB SOURCES_MD5       "${BTSTACK_ROOT}/3rd-party/md5/md5.c")
54file(GLOB SOURCES_UECC      "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c")
55file(GLOB SOURCES_YXML      "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c")
56file(GLOB SOURCES_HXCMOD    "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c"  "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c")
57file(GLOB SOURCES_RIJNDAEL  "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c")
58
59set(SOURCES_POSIX
60    ${BTSTACK_ROOT}/platform/posix/btstack_audio_portaudio.c
61    ${BTSTACK_ROOT}/platform/posix/btstack_tlv_posix.c
62    ${BTSTACK_ROOT}/platform/posix/hci_dump_posix_fs.c
63    ${BTSTACK_ROOT}/platform/posix/wav_util.c
64)
65
66set(SOURCES_CHIPSET
67    ${BTSTACK_ROOT}/chipset/bcm/btstack_chipset_bcm.c
68    ${BTSTACK_ROOT}/chipset/cc256x/btstack_chipset_cc256x.c
69    bluetooth_init_cc2564C_1.4.c
70    ${BTSTACK_ROOT}/chipset/csr/btstack_chipset_csr.c
71)
72
73set(LWIP_CORE_SRC
74        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c
75        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c
76        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c
77        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c
78        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c
79        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c
80        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c
81        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c
82        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c
83        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c
84        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c
85        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c
86        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c
87)
88set (LWIP_IPV4_SRC
89        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c
90        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c
91        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c
92        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c
93        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c
94        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c
95        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c
96)
97set (LWIP_NETIF_SRC
98        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c
99)
100set (LWIP_HTTPD
101        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c
102        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c
103        ${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c
104)
105set (LWIP_DHCPD
106        ${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c
107)
108set (LWIP_PORT
109        ${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c
110        ${BTSTACK_ROOT}/platform/lwip/bnep_lwip.c
111)
112
113set (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT})
114
115file(GLOB SOURCES_BLE_OFF   "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c")
116list(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF})
117
118
119# select POSIX vs Windows versions
120IF (WIN32)
121    message("Building for Windows using WinUSB")
122    set(SOURCES_HCI_USB ${BTSTACK_ROOT}/platform/windows/hci_transport_h2_winusb.c)
123    set(SOURCES_STDIN   ${BTSTACK_ROOT}/platform/windows/btstack_stdin_windows.c)
124    link_libraries( winusb setupapi)
125ELSE()
126    message("Building for POSIX using libusb")
127
128    set(SOURCES_HCI_USB ${BTSTACK_ROOT}/platform/libusb/hci_transport_h2_libusb.c)
129    set(SOURCES_STDIN   ${BTSTACK_ROOT}/platform/posix/btstack_stdin_posix.c)
130
131    list(APPEND SOURCES_POSIX ${BTSTACK_ROOT}/platform/posix/btstack_network_posix.c)
132    list(APPEND SOURCES_POSIX ${BTSTACK_ROOT}/platform/posix/btstack_block_posix.c)
133ENDIF()
134
135set(SOURCES
136        ${SOURCES_MD5}
137        ${SOURCES_YXML}
138        ${SOURCES_BLUEDROID}
139        ${SOURCES_POSIX}
140        ${SOURCES_RIJNDAEL}
141        ${SOURCES_HCI_USB}
142        ${SOURCES_STDIN}
143        ${SOURCES_SRC}
144        ${SOURCES_BLE}
145        ${SOURCES_GATT}
146        ${SOURCES_MESH}
147        ${SOURCES_CLASSIC}
148        ${SOURCES_UECC}
149        ${SOURCES_HXCMOD}
150        ${SOURCES_CHIPSET}
151)
152list(SORT SOURCES)
153
154# create static lib
155add_library(btstack-lib STATIC ${SOURCES})
156
157# create targets for all examples
158file(GLOB EXAMPLES_C    "${BTSTACK_ROOT}/example/*.c")
159list(SORT EXAMPLES_C)
160file(GLOB EXAMPLES_GATT "${BTSTACK_ROOT}/example/*.gatt")
161
162# remove some
163file(GLOB EXAMPLES_OFF  "${BTSTACK_ROOT}/example/panu_demo.c" "${BTSTACK_ROOT}/example/sco_demo_util.c" "${BTSTACK_ROOT}/example/ant_test.c" "${BTSTACK_ROOT}/example/avrcp_browsing_client.c")
164list(REMOVE_ITEM EXAMPLES_C ${EXAMPLES_OFF})
165
166# on Mac 10.14, adding lwip to libstack results in a yet not understood link error
167# workaround: add lwip sources only to lwip_examples
168set (LWIP_EXAMPLES pan_lwip_http_server)
169
170# create targets
171foreach(EXAMPLE_FILE ${EXAMPLES_C})
172        get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE)
173        set (SOURCE_FILES ${EXAMPLE_FILE})
174
175        # add qt main.cpp and run loop
176        list(APPEND SOURCE_FILES ${BTSTACK_ROOT}/platform/qt/btstack_run_loop_qt.cpp main.cpp)
177
178        # add lwip sources for lwip examples
179        if ( "${LWIP_EXAMPLES}" MATCHES ${EXAMPLE} )
180                list(APPEND SOURCE_FILES ${SOURCES_LWIP})
181        endif()
182
183        # add GATT DB creation
184        if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} )
185                message("example ${EXAMPLE} -- with GATT DB")
186                add_custom_command(
187                    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
188                        COMMAND  ${PYTHON_EXECUTABLE}
189                        ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
190                )
191                list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
192
193                # generated file does not need AUTOMOC and AUOUIC processing
194                set_property(SOURCE {CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h PROPERTY SKIP_AUTOGEN ON)
195        else()
196                message("example ${EXAMPLE}")
197        endif()
198        add_executable(${EXAMPLE} ${SOURCE_FILES} )
199        target_link_libraries(${EXAMPLE} btstack-lib Qt5::Core)
200endforeach(EXAMPLE_FILE)
201