diff --git a/qtservice/CMakeLists.txt b/qtservice/CMakeLists.txt index c2cfc25..23fef11 100644 --- a/qtservice/CMakeLists.txt +++ b/qtservice/CMakeLists.txt @@ -13,22 +13,18 @@ set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "verbose") SET(CMAKE_AUTOUIC ON) SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTORCC ON) -SET(CMAKE_VERBOSE_MAKEFILE ON) #需要的QT组件 if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() -SET(QT_COMPONENTS Widgets) +SET(QT_COMPONENTS Core) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS}) message("QT_VERSION:${Qt${QT_VERSION_MAJOR}_VERSION}") -if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS 5.10.0 AND ANDROID) - message(FATAL_ERROR "Qt must great 5.10.0") -endif() if(Qt${QT_VERSION_MAJOR}_FOUND) FOREACH(_COMPONENT ${QT_COMPONENTS}) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt${QT_VERSION_MAJOR}::${_COMPONENT}) + list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::${_COMPONENT}) ENDFOREACH() endif() get_filename_component(QT_INSTALL_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE) @@ -133,7 +129,7 @@ endif() add_subdirectory(src) -option(BUILD_EXAMPLES "Build examples" ON) +option(BUILD_EXAMPLES "Build examples" OFF) if(BUILD_EXAMPLES) add_subdirectory(examples) endif(BUILD_EXAMPLES) diff --git a/qtservice/examples/interactive/CMakeLists.txt b/qtservice/examples/interactive/CMakeLists.txt index 6b34fc2..66784ab 100644 --- a/qtservice/examples/interactive/CMakeLists.txt +++ b/qtservice/examples/interactive/CMakeLists.txt @@ -6,7 +6,8 @@ project(interactive) if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() -SET(QT_COMPONENTS Core Gui Widgets) +SET(QT_LIBRARIES) +SET(QT_COMPONENTS Gui Widgets) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS}) message("QT_VERSION:${Qt${QT_VERSION_MAJOR}_VERSION}") @@ -15,12 +16,12 @@ if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS 5.10.0 AND ANDROID) endif() if(Qt${QT_VERSION_MAJOR}_FOUND) FOREACH(_COMPONENT ${QT_COMPONENTS}) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt${QT_VERSION_MAJOR}::${_COMPONENT}) + LIST(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::${_COMPONENT}) ENDFOREACH() endif() get_filename_component(QT_INSTALL_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE) -message("QT_INSTALL_DIR:${QT_INSTALL_DIR}") -message("QT_LIBRARIES:${QT_LIBRARIES}") +message("${PROJECT_NAME} QT_INSTALL_DIR:${QT_INSTALL_DIR}") +message("${PROJECT_NAME} QT_LIBRARIES:${QT_LIBRARIES}") add_executable(${PROJECT_NAME} main.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE QtService ${QT_LIBRARIES}) diff --git a/qtservice/examples/server/CMakeLists.txt b/qtservice/examples/server/CMakeLists.txt index 7f355a9..2041174 100644 --- a/qtservice/examples/server/CMakeLists.txt +++ b/qtservice/examples/server/CMakeLists.txt @@ -7,25 +7,6 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() -list(APPEND QT_COMPONENTS Core Network) -if(ANDROID) - SET(QT_COMPONENTS ${QT_COMPONENTS} AndroidExtras) -endif() -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS}) -message("QT_VERSION:${Qt${QT_VERSION_MAJOR}_VERSION}") -if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS 5.10.0 AND ANDROID) - message(FATAL_ERROR "Qt must great 5.10.0") -endif() -if(Qt${QT_VERSION_MAJOR}_FOUND) - FOREACH(_COMPONENT ${QT_COMPONENTS}) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt${QT_VERSION_MAJOR}::${_COMPONENT}) - ENDFOREACH() -endif() -get_filename_component(QT_INSTALL_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE) -message("QT_INSTALL_DIR:${QT_INSTALL_DIR}") -message("QT_LIBRARIES:${QT_LIBRARIES}") - add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE QtService ${QT_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE QtService) diff --git a/qtservice/src/CMakeLists.txt b/qtservice/src/CMakeLists.txt index 16130c2..bb189ac 100644 --- a/qtservice/src/CMakeLists.txt +++ b/qtservice/src/CMakeLists.txt @@ -2,39 +2,33 @@ cmake_minimum_required(VERSION 3.5) -project(QtService) - -#需要的QT组件 if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() -SET(QT_COMPONENTS Core) + +project(QtService) + +# Open qt complie tools +SET(CMAKE_AUTOUIC ON) +SET(CMAKE_AUTOMOC ON) +SET(CMAKE_AUTORCC ON) +SET(CMAKE_VERBOSE_MAKEFILE ON) + +# Need qt components if(UNIX) list(APPEND QT_COMPONENTS Network) endif() -if(ANDROID) - SET(QT_COMPONENTS ${QT_COMPONENTS} AndroidExtras) -endif() find_package(QT NAMES Qt6 Qt5 COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS}) message("QT_VERSION:${Qt${QT_VERSION_MAJOR}_VERSION}") -if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS 5.10.0 AND ANDROID) - message(FATAL_ERROR "Qt must great 5.10.0") -endif() if(Qt${QT_VERSION_MAJOR}_FOUND) FOREACH(_COMPONENT ${QT_COMPONENTS}) - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt${QT_VERSION_MAJOR}::${_COMPONENT}) + LIST(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::${_COMPONENT}) ENDFOREACH() endif() get_filename_component(QT_INSTALL_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE) -message("QT_INSTALL_DIR:${QT_INSTALL_DIR}") -message("QT_LIBRARIES:${QT_LIBRARIES}") - -#打开 qt 编译工具 -SET(CMAKE_AUTOUIC ON) -SET(CMAKE_AUTOMOC ON) -SET(CMAKE_AUTORCC ON) -SET(CMAKE_VERBOSE_MAKEFILE ON) +message("${PROJECT_NAME} QT_INSTALL_DIR:${QT_INSTALL_DIR}") +message("${PROJECT_NAME} QT_LIBRARIES:${QT_LIBRARIES}") set(SOURCE_FILES qtservice.cpp