chore: do something make bluetooth happy

This commit is contained in:
Qsaker 2023-11-22 00:05:56 +08:00
parent c9f00bdd91
commit 3aff276100
2 changed files with 23 additions and 7 deletions

View File

@ -22,13 +22,13 @@ set(SAK_QT_COMPONENTS
SerialBus)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${SAK_QT_COMPONENTS})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${SAK_QT_COMPONENTS})
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Bluetooth QUIET)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Bluetooth)
if(Qt${QT_VERSION_MAJOR}Bluetooth_FOUND)
message(STATUS "Qt${QT_VERSION_MAJOR}::Bluetooth found.")
option(SAK_IMPORT_MODULE_BLUETOOTH "Import Bluetooth module." ON)
add_compile_definitions(SAK_IMPORT_MODULE_BLUETOOTH)
else()
message(STATUS "QtBluetooth not found.")
message(STATUS "Qt${QT_VERSION_MAJOR}::Bluetooth not found.")
endif()
set(BUILD_TESTING OFF)
@ -143,10 +143,11 @@ endif()
list(APPEND SAK_APP_SOURCES ${SAK_ASSISTANT_SOURCES} ${SAK_SRC_SOURCES} ${APP_SOURCES})
list(APPEND SAK_APP_SOURCES qtswissarmyknife.qrc windows.rc)
if(DEFINED SAK_IMPORT_MODULE_BLUETOOTH)
file(GLOB APP_BLUETOOTH_SOURCES "src/optional/bluetooth/*.h" "src/optional/bluetooth/*.cc"
if(SAK_IMPORT_MODULE_BLUETOOTH)
file(GLOB SAK_BLUETOOTH_SOURCES "src/optional/bluetooth/*.h" "src/optional/bluetooth/*.cc"
"src/optional/bluetooth/*.ui")
list(APPEND SAK_APP_SOURCES ${APP_BLUETOOTH_SOURCES})
list(APPEND SAK_APP_SOURCES ${SAK_BLUETOOTH_SOURCES})
include_directories(src/optional/bluetooth)
endif()
sak_add_executable("SwissArmyKnife" ${SAK_APP_SOURCES})
@ -157,7 +158,7 @@ target_link_libraries(
PRIVATE glog::glog Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebSockets
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::SerialPort
Qt${QT_VERSION_MAJOR}::SerialBus)
if(DEFINED SAK_IMPORT_MODULE_BLUETOOTH)
if(SAK_IMPORT_MODULE_BLUETOOTH)
target_link_libraries(SwissArmyKnife PRIVATE Qt${QT_VERSION_MAJOR}::Bluetooth)
endif()

View File

@ -23,6 +23,18 @@ endif()
set(EASY_DEBUG_APP_SOURCES ${EASY_DEBUG_SOURCES})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sak/EasyDebug")
if(SAK_IMPORT_MODULE_BLUETOOTH)
message(STATUS "EasyDebug: Bluetooth is supportted")
include_directories(${CMAKE_SOURCE_DIR}/src/optional/bluetooth)
set(EASY_DEBUG_BLUETOOTH_SOURCES
${CMAKE_SOURCE_DIR}/src/optional/bluetooth/sakblecentraltool.h
${CMAKE_SOURCE_DIR}/src/optional/bluetooth/sakblecentraltool.cc
${CMAKE_SOURCE_DIR}/src/optional/bluetooth/sakblescanner.h
${CMAKE_SOURCE_DIR}/src/optional/bluetooth/sakblescanner.cc)
list(APPEND EASY_DEBUG_APP_SOURCES ${EASY_DEBUG_BLUETOOTH_SOURCES})
endif()
sak_add_executable(EasyDebug ${EASY_DEBUG_APP_SOURCES})
sak_set_target_properties(EasyDebug)
sak_auto_execute_windeployqt(EasyDebug)
@ -36,3 +48,6 @@ target_link_libraries(
Qt${QT_VERSION_MAJOR}::QuickControls2
Qt${QT_VERSION_MAJOR}::WebSockets
Qt${QT_VERSION_MAJOR}::Widgets)
if(SAK_IMPORT_MODULE_BLUETOOTH)
target_link_libraries(EasyDebug PRIVATE Qt${QT_VERSION_MAJOR}::Bluetooth)
endif()