Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cmake build without QtWidgets #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)

add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000 -DUSE_WIDGETS)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)

find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core Widgets OPTIONAL_COMPONENTS LinguistTools)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core Gui OPTIONAL_COMPONENTS Widgets LinguistTools)

get_target_property(QT_QTPATHS_EXECUTABLE Qt6::qtpaths IMPORTED_LOCATION)

Expand Down Expand Up @@ -67,10 +67,12 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/qt6ct-common)

add_link_options(-Wl,--no-undefined)
add_subdirectory(src/qt6ct)
add_subdirectory(src/qt6ct-common)
add_subdirectory(src/qt6ct-qtplugin)
add_subdirectory(src/qt6ct-style)
if(Qt6Widgets_FOUND)
add_subdirectory(src/qt6ct-style)
add_subdirectory(src/qt6ct)
endif()

install(DIRECTORY qss DESTINATION ${CMAKE_INSTALL_DATADIR}/qt6ct)
install(DIRECTORY colors DESTINATION ${CMAKE_INSTALL_DATADIR}/qt6ct)
Expand Down
2 changes: 1 addition & 1 deletion src/qt6ct-qtplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)

add_library(qt6ct-qtplugin MODULE ${app_SRCS})
set_target_properties(qt6ct-qtplugin PROPERTIES OUTPUT_NAME qt6ct)
target_link_libraries(qt6ct-qtplugin PRIVATE Qt6::Widgets Qt6::GuiPrivate qt6ct-common)
target_link_libraries(qt6ct-qtplugin PRIVATE $<TARGET_NAME_IF_EXISTS:Qt6::Widgets> Qt6::GuiPrivate qt6ct-common)
install(TARGETS qt6ct-qtplugin DESTINATION ${PLUGINDIR}/platformthemes)
7 changes: 3 additions & 4 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ Qt6CTPlatformTheme::Qt6CTPlatformTheme()
{
readSettings();
QMetaObject::invokeMethod(this, "applySettings", Qt::QueuedConnection);
#ifdef QT_WIDGETS_LIB
QMetaObject::invokeMethod(this, "createFSWatcher", Qt::QueuedConnection);
#endif
QGuiApplication::setFont(m_generalFont);
}
qCDebug(lqt6ct) << "using qt6ct plugin";
Expand Down Expand Up @@ -169,6 +167,9 @@ void Qt6CTPlatformTheme::applySettings()

QGuiApplication::setFont(m_generalFont); //apply font

if(m_update && m_usePalette)
QGuiApplication::setPalette(m_palette ? *m_palette : *QGenericUnixTheme::palette(QPlatformTheme::SystemPalette));

#ifdef QT_WIDGETS_LIB
if(hasWidgets())
{
Expand Down Expand Up @@ -227,7 +228,6 @@ void Qt6CTPlatformTheme::applySettings()
m_update = true;
}

#ifdef QT_WIDGETS_LIB
void Qt6CTPlatformTheme::createFSWatcher()
{
QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
Expand All @@ -246,7 +246,6 @@ void Qt6CTPlatformTheme::updateSettings()
readSettings();
applySettings();
}
#endif

void Qt6CTPlatformTheme::readSettings()
{
Expand Down
2 changes: 0 additions & 2 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ class Qt6CTPlatformTheme : public QObject, public QGenericUnixTheme

private slots:
void applySettings();
#ifdef QT_WIDGETS_LIB
void createFSWatcher();
void updateSettings();
#endif

private:
void readSettings();
Expand Down
2 changes: 0 additions & 2 deletions src/qt6ct-style/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(qt6ct-style)

add_definitions(-DUSE_WIDGETS)

set(app_SRCS
plugin.cpp
qt6ctproxystyle.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/qt6ct/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if(Qt6LinguistTools_FOUND)
endif()

add_executable(qt6ct ${app_SRCS})
target_link_libraries(qt6ct PRIVATE Qt6::Widgets Qt6::WidgetsPrivate qt6ct-common)
target_link_libraries(qt6ct PRIVATE Qt6::Widgets Qt6::GuiPrivate qt6ct-common)
target_compile_definitions(qt6ct PRIVATE USE_WIDGETS)
install(TARGETS qt6ct DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES qt6ct.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)