try to move to cmake from qmake

This commit is contained in:
tianxu 2024-02-23 16:05:17 +08:00
parent 3a0e226597
commit 5914e76c5a
8 changed files with 88 additions and 223 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*.pro.user *.pro.user
build
.cache

6
CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
project(qt-material-widgets)
cmake_minimum_required(VERSION 3.22)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(examples)
add_subdirectory(components)

30
components/CMakeLists.txt Normal file
View File

@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.5)
project(
components
VERSION 0.1
LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5 REQUIRED COMPONENTS Core)
find_package(Qt5 REQUIRED COMPONENTS Widgets)
file(GLOB THELIB "lib/*")
file(GLOB LAYOUT "layouts/*")
file(GLOB COMPONENTSHEADER "*.h")
file(GLOB COMPONENTSSOURCE "*.cpp")
set(RCC_FILES resources.qrc)
add_library(${PROJECT_NAME} STATIC ${THELIB} ${LAYOUT} ${COMPONENTSHEADER}
${COMPONENTSSOURCE} ${RCC_FILES})
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets)
target_link_directories(${PROJECT_NAME} PUBLIC .)

View File

@ -1,130 +0,0 @@
TEMPLATE = lib
CONFIG += staticlib
SOURCES = \
qtmaterialavatar.cpp \
lib/qtmaterialstyle.cpp \
lib/qtmaterialtheme.cpp \
qtmaterialbadge.cpp \
lib/qtmaterialoverlaywidget.cpp \
qtmaterialcheckbox.cpp \
lib/qtmaterialcheckable_internal.cpp \
lib/qtmaterialcheckable.cpp \
lib/qtmaterialripple.cpp \
lib/qtmaterialrippleoverlay.cpp \
qtmaterialfab.cpp \
qtmaterialraisedbutton.cpp \
qtmaterialflatbutton_internal.cpp \
qtmaterialflatbutton.cpp \
lib/qtmaterialstatetransition.cpp \
qtmaterialiconbutton.cpp \
qtmaterialprogress_internal.cpp \
qtmaterialprogress.cpp \
qtmaterialcircularprogress_internal.cpp \
qtmaterialcircularprogress.cpp \
qtmaterialslider_internal.cpp \
qtmaterialslider.cpp \
qtmaterialsnackbar_internal.cpp \
qtmaterialsnackbar.cpp \
qtmaterialradiobutton.cpp \
qtmaterialtoggle_internal.cpp \
qtmaterialtoggle.cpp \
qtmaterialtextfield_internal.cpp \
qtmaterialtextfield.cpp \
qtmaterialtabs_internal.cpp \
qtmaterialtabs.cpp \
qtmaterialscrollbar_internal.cpp \
qtmaterialscrollbar.cpp \
qtmaterialdialog_internal.cpp \
qtmaterialdialog.cpp \
qtmaterialdrawer_internal.cpp \
qtmaterialdrawer.cpp \
qtmaterialappbar.cpp \
qtmaterialautocomplete.cpp \
qtmaterialpaper.cpp \
qtmaterialtable.cpp \
layouts/qtmaterialsnackbarlayout.cpp \
qtmaterialautocomplete_internal.cpp \
qtmaterialmenu.cpp \
qtmaterialmenu_internal.cpp \
qtmateriallist.cpp \
qtmateriallistitem.cpp
HEADERS = \
qtmaterialavatar_p.h \
qtmaterialavatar.h \
lib/qtmaterialstyle_p.h \
lib/qtmaterialstyle.h \
lib/qtmaterialtheme_p.h \
lib/qtmaterialtheme.h \
qtmaterialbadge_p.h \
qtmaterialbadge.h \
lib/qtmaterialoverlaywidget.h \
qtmaterialcheckbox_p.h \
qtmaterialcheckbox.h \
lib/qtmaterialcheckable_internal.h \
lib/qtmaterialcheckable_p.h \
lib/qtmaterialripple.h \
lib/qtmaterialrippleoverlay.h \
lib/qtmaterialcheckable.h \
qtmaterialfab_p.h \
qtmaterialfab.h \
qtmaterialraisedbutton_p.h \
qtmaterialraisedbutton.h \
qtmaterialflatbutton_internal.h \
qtmaterialflatbutton_p.h \
qtmaterialflatbutton.h \
lib/qtmaterialstatetransition.h \
lib/qtmaterialstatetransitionevent.h \
qtmaterialiconbutton_p.h \
qtmaterialiconbutton.h \
qtmaterialprogress_internal.h \
qtmaterialprogress_p.h \
qtmaterialprogress.h \
qtmaterialcircularprogress_internal.h \
qtmaterialcircularprogress_p.h \
qtmaterialcircularprogress.h \
qtmaterialslider_internal.h \
qtmaterialslider_p.h \
qtmaterialslider.h \
qtmaterialsnackbar_internal.h \
qtmaterialsnackbar_p.h \
qtmaterialsnackbar.h \
qtmaterialradiobutton_p.h \
qtmaterialradiobutton.h \
qtmaterialtoggle_internal.h \
qtmaterialtoggle_p.h \
qtmaterialtoggle.h \
qtmaterialtextfield_internal.h \
qtmaterialtextfield_p.h \
qtmaterialtextfield.h \
qtmaterialtabs_internal.h \
qtmaterialtabs_p.h \
qtmaterialtabs.h \
qtmaterialscrollbar_internal.h \
qtmaterialscrollbar_p.h \
qtmaterialscrollbar.h \
qtmaterialdialog_internal.h \
qtmaterialdialog_p.h \
qtmaterialdialog.h \
qtmaterialdrawer_internal.h \
qtmaterialdrawer_p.h \
qtmaterialdrawer.h \
qtmaterialappbar.h \
qtmaterialappbar_p.h \
qtmaterialautocomplete.h \
qtmaterialautocomplete_p.h \
qtmaterialpaper.h \
qtmaterialpaper_p.h \
qtmaterialtable.h \
qtmaterialtable_p.h \
layouts/qtmaterialsnackbarlayout.h \
layouts/qtmaterialsnackbarlayout_p.h \
qtmaterialautocomplete_internal.h \
qtmaterialmenu.h \
qtmaterialmenu_p.h \
qtmaterialmenu_internal.h \
qtmateriallist.h \
qtmateriallist_p.h \
qtmateriallistitem.h \
qtmateriallistitem_p.h
RESOURCES += \
resources.qrc

View File

@ -234,7 +234,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
QRect r = rect(); QRect r = rect();
const qreal hs = d->size/2; const qreal hs = d->size/2.0;
if (!isEnabled()) if (!isEnabled())
{ {

49
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.5)
project(examples VERSION 0.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
file(GLOB HEADER "*.h")
file(GLOB RSOURCE "*.cpp")
file(GLOB UI "*.ui")
SET(RCC_FILES examples.qrc)
add_executable(
${PROJECT_NAME}
${HEADER}
${RSOURCE}
${UI}
${RCC_FILES}
)
target_include_directories(${PROJECT_NAME} PUBLIC
../components/
)
target_link_libraries(
${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Core
components
)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
)

View File

@ -1,75 +0,0 @@
QT += core gui widgets
TEMPLATE = app
CONFIG += c++11
SOURCES = mainwindow.cpp \
main.cpp \
avatarsettingseditor.cpp \
badgesettingseditor.cpp \
checkboxsettingseditor.cpp \
fabsettingseditor.cpp \
raisedbuttonsettingseditor.cpp \
flatbuttonsettingseditor.cpp \
iconbuttonsettingseditor.cpp \
progresssettingseditor.cpp \
circularprogresssettingseditor.cpp \
slidersettingseditor.cpp \
radiobuttonsettingseditor.cpp \
togglesettingseditor.cpp \
textfieldsettingseditor.cpp \
tabssettingseditor.cpp \
snackbarsettingseditor.cpp \
dialogsettingseditor.cpp \
drawersettingseditor.cpp \
scrollbarsettingseditor.cpp \
appbarsettingseditor.cpp \
autocompletesettingseditor.cpp \
menusettingseditor.cpp
HEADERS = mainwindow.h \
avatarsettingseditor.h \
badgesettingseditor.h \
checkboxsettingseditor.h \
fabsettingseditor.h \
raisedbuttonsettingseditor.h \
flatbuttonsettingseditor.h \
iconbuttonsettingseditor.h \
progresssettingseditor.h \
circularprogresssettingseditor.h \
slidersettingseditor.h \
radiobuttonsettingseditor.h \
togglesettingseditor.h \
textfieldsettingseditor.h \
tabssettingseditor.h \
snackbarsettingseditor.h \
dialogsettingseditor.h \
drawersettingseditor.h \
scrollbarsettingseditor.h \
appbarsettingseditor.h \
autocompletesettingseditor.h \
menusettingseditor.h
LIBS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a
INCLUDEPATH += $$top_srcdir/components/
TARGET = examples-exe
PRE_TARGETDEPS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a
RESOURCES += \
examples.qrc
FORMS += \
avatarsettingsform.ui \
badgesettingsform.ui \
checkboxsettingsform.ui \
fabsettingsform.ui \
flatbuttonsettingsform.ui \
iconbuttonsettingsform.ui \
progresssettingsform.ui \
circularprogresssettingsform.ui \
slidersettingsform.ui \
snackbarsettingsform.ui \
radiobuttonsettingsform.ui \
togglesettingsform.ui \
textfieldsettingsform.ui \
tabssettingsform.ui \
dialogsettingsform.ui \
drawersettingsform.ui \
scrollbarsettingsform.ui \
appbarsettingsform.ui

View File

@ -1,17 +0,0 @@
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qt-material-widgets
TEMPLATE = subdirs
SUBDIRS = components examples
CONFIG += ordered
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0