x-tools/cmake/x_qt_serialport.cmake
2025-08-23 23:57:31 +08:00

14 lines
588 B
CMake

find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS SerialPort)
set(X_ENABLE_SERIALPORT ${Qt${QT_VERSION_MAJOR}SerialPort_FOUND})
if(X_ENABLE_SERIALPORT)
add_compile_definitions(X_ENABLE_SERIALPORT)
list(APPEND X_LIBS Qt${QT_VERSION_MAJOR}::SerialPort)
else()
message(STATUS "SerialPort module is disable, SerialPort files will be removed.")
file(GLOB_RECURSE SERIAL_PORT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/serialport*")
foreach(file ${SERIAL_PORT_FILES})
list(REMOVE_ITEM X_SOURCES ${file})
message(STATUS "[SerialPort]Remove file: ${file}")
endforeach()
endif()