qt5base-lts/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
Amir Masoud Abdol 7fe2537ce2 Fix Style Plugin Example, and add some CMake Docs
A few things:

- Improved the documentation by adding a CMake section, briefly
  describing the process of adding the plugin, and placing it where it
  should be.
- Write a note about the case where the style may be overwritten at
  launch, and how to set the a new style using a CLI
- Improved the CMake build such that it creates the App Bundle
  correctly, and also works without an App Bundle as well.
- Changed the example, and plugin such that now instead of a QPushButton
  we have a QTextEdit, and change the text color.
- Replaced the application screenshot

Fixes: QTBUG-107842
Fixes: QTBUG-109227
Change-Id: I161a91b27df016ff6230fac3871b79d2dfbdf18a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-18 14:47:12 +01:00

42 lines
1009 B
CMake

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#! [0]
qt_add_plugin(simplestyleplugin
CLASS_NAME SimpleStylePlugin
simplestyle.cpp simplestyle.h
simplestyleplugin.cpp simplestyleplugin.h
)
#! [0]
if(QT_FEATURE_debug AND APPLE)
set_property(simplestyleplugin
APPEND_STRING PROPERTY OUTPUT_NAME "_debug")
endif()
get_target_property(is_bundle styleplugin MACOSX_BUNDLE)
if(APPLE AND is_bundle)
#! [1]
set_target_properties(simplestyleplugin PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "$<TARGET_BUNDLE_CONTENT_DIR:styleplugin>/PlugIns/styles"
)
#! [1]
else()
#! [2]
set_target_properties(simplestyleplugin PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:styleplugin>/styles"
)
#! [2]
endif()
target_link_libraries(simplestyleplugin PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
)
install(TARGETS simplestyleplugin
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)