diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,11 @@ set(REQUIRED_QT_VERSION 5.6.0) -find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui Xml) +find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) +option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) +if(KCONFIG_USE_GUI) + find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) +endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -52,6 +52,7 @@ target_include_directories(test_kconf_update PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src/kconf_update) +if(TARGET Qt5::Gui) ecm_add_tests( kconfigguitest.cpp kconfigloadertest.cpp @@ -67,4 +68,4 @@ set_tests_properties(kconfiggui-kconfigguitest PROPERTIES RUN_SERIAL TRUE) add_subdirectory(kconfig_compiler) - +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,7 @@ add_subdirectory(core) -add_subdirectory(gui) +if(TARGET Qt5::Gui) + add_subdirectory(gui) +endif() add_subdirectory(kconfig_compiler) add_subdirectory(kconf_update) add_subdirectory(kreadconfig) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,6 +1,3 @@ - -find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) - set(libkconfigcore_SRCS kconfig.cpp kconfigbase.cpp diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,7 +1,3 @@ - -find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) -find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) - set(libkconfiggui_SRCS kconfiggui.cpp kconfiggroupgui.cpp diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) - remove_definitions(-DQT_NO_CAST_FROM_ASCII) ########### next target ############### diff --git a/src/kconfig_compiler/CMakeLists.txt b/src/kconfig_compiler/CMakeLists.txt --- a/src/kconfig_compiler/CMakeLists.txt +++ b/src/kconfig_compiler/CMakeLists.txt @@ -16,8 +16,6 @@ add_executable(KF5::kconfig_compiler ALIAS kconfig_compiler) endif() -find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) - target_link_libraries(kconfig_compiler Qt5::Xml) ecm_mark_nongui_executable(kconfig_compiler)