-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add working example and fix README for CMake.
- Loading branch information
1 parent
12bb954
commit 163b93c
Showing
4 changed files
with
103 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
cmake_policy(SET CMP0128 NEW) | ||
|
||
project(testing) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
set(QT_VERSION Qt5 CACHE STRING "The Qt version framework to use (Qt5 or Qt6).") | ||
set(BREEZE_EXTENSIONS all CACHE STRING "The extensions to include in our stylesheets.") | ||
set(BREEZE_STYLES all CACHE STRING "The styles to include in our stylesheets.") | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/breeze.cmake) | ||
set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_qt.cpp) | ||
add_executable(testing ${SOURCE_FILES}) | ||
target_link_libraries(testing PRIVATE Qt${QT_VERSION_MAJOR}::Widgets breeze) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Setup Qt: this works with both Qt5 and Qt6 | ||
# NOTE: We use cached strings to specify the options for these. | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
set(CMAKE_AUTOUIC ON) | ||
|
||
find_package( | ||
${QT_VERSION} | ||
COMPONENTS Core Gui Widgets | ||
REQUIRED) | ||
# ------------------- | ||
|
||
# Get Python to compile the stylesheets. | ||
# Fetch the repository, configure, compile the stylesheets. | ||
find_package(Python COMPONENTS Interpreter) | ||
|
||
include(FetchContent) | ||
|
||
set(FETCHCONTENT_QUIET OFF CACHE BOOL "Silence fetch content" FORCE) | ||
|
||
FetchContent_Declare( | ||
breeze_stylesheets | ||
GIT_REPOSITORY https://github.com/Alexhuszagh/BreezeStyleSheets.git | ||
GIT_TAG origin/main | ||
GIT_PROGRESS ON | ||
USES_TERMINAL_DOWNLOAD TRUE) | ||
|
||
FetchContent_GetProperties(breeze_stylesheets) | ||
if(NOT breeze_stylesheets_POPULATED) | ||
FetchContent_Populate(breeze_stylesheets) | ||
|
||
add_library(breeze STATIC "${breeze_stylesheets_SOURCE_DIR}/dist/breeze.qrc") | ||
|
||
add_custom_target( | ||
run_python_breeze ALL | ||
COMMAND ${Python_EXECUTABLE} configure.py --extensions=${BREEZE_EXTENSIONS} | ||
--styles=${BREEZE_STYLES} --resource breeze.qrc | ||
WORKING_DIRECTORY ${breeze_stylesheets_SOURCE_DIR} | ||
BYPRODUCTS "${breeze_stylesheets_SOURCE_DIR}/dist/breeze.qrc" | ||
COMMENT "Generating themes") | ||
|
||
add_dependencies(breeze run_python_breeze) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <QApplication> | ||
#include <QFile> | ||
#include <QTextStream> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication app(argc, argv); | ||
|
||
// Need to initialize the resource, since we're using an external | ||
// build system and this isn't automatically handled by CMake. | ||
Q_INIT_RESOURCE(breeze); | ||
QFile file(":/dark/stylesheet.qss"); | ||
file.open(QFile::ReadOnly | QFile::Text); | ||
QTextStream stream(&file); | ||
app.setStyleSheet(stream.readAll()); | ||
|
||
// code goes here | ||
|
||
return app.exec(); | ||
} |