[cpp] Fix root project build and dependencies.
This commit is contained in:
@@ -14,6 +14,7 @@ project(
|
||||
DESCRIPTION "A root project for several small Qt6 practice projects"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
message(STATUS "[Klips] Configuring example: ${PROJECT_NAME}")
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
add_compile_options("-Wall")
|
||||
|
||||
@@ -14,6 +14,9 @@ project(
|
||||
DESCRIPTION "Example of a widget plugin collection for Qt Designer"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
message(STATUS "[Klips] Configuring example: ${PROJECT_NAME}")
|
||||
# Lowercase string to use as a slug for executable names for identification.
|
||||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
|
||||
@@ -51,43 +54,56 @@ endif()
|
||||
set(QT_INSTALL_DIR "${QT_DIR}/6.3.1/gcc_64/" CACHE PATH "Path to Qt6 install")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL_DIR}")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS UiPlugin Core Gui Widgets)
|
||||
find_package(Qt6 COMPONENTS UiPlugin Core Gui Widgets)
|
||||
if (NOT Qt6_FOUND)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"[Klips] Error: CMake was unable to find Qt6 libraries.\n"
|
||||
"The example will not be built until the build is configured with these packages installed.\n"
|
||||
"On Ubuntu 24.04 Qt6 can be installed using apt:\n"
|
||||
" sudo apt-get install qt6-base-dev qt6-tools-dev\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Creating a library with two plugins for the collection.
|
||||
qt_add_library(widget-plugin-library
|
||||
set(WIDGET_PLUGIN_LIBRARY widget-plugin-library_${PROJECT_NAME_LOWER})
|
||||
qt_add_library(${WIDGET_PLUGIN_LIBRARY}
|
||||
textview.cpp textview.h
|
||||
widgetplugin.cpp widgetplugin.h
|
||||
)
|
||||
target_sources(widget-plugin-library PRIVATE
|
||||
target_sources(${WIDGET_PLUGIN_LIBRARY} PRIVATE
|
||||
textview.cpp textview.h
|
||||
treeview.cpp treeview.h
|
||||
widgetplugin.cpp widgetplugin.h
|
||||
)
|
||||
set_target_properties(widget-plugin-library PROPERTIES
|
||||
set_target_properties(${WIDGET_PLUGIN_LIBRARY} PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
target_link_libraries(widget-plugin-library
|
||||
target_link_libraries(${WIDGET_PLUGIN_LIBRARY}
|
||||
PUBLIC Qt::UiPlugin Qt::Core Qt::Gui Qt::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS widget-plugin-library
|
||||
install(TARGETS ${WIDGET_PLUGIN_LIBRARY}
|
||||
RUNTIME DESTINATION "${QT_PLUGIN_LIBRARY_DIR}"
|
||||
BUNDLE DESTINATION "${QT_PLUGIN_LIBRARY_DIR}"
|
||||
LIBRARY DESTINATION "${QT_PLUGIN_LIBRARY_DIR}"
|
||||
)
|
||||
|
||||
generate_export_header(widget-plugin-library)
|
||||
generate_export_header(${WIDGET_PLUGIN_LIBRARY}
|
||||
BASE_NAME widget_plugin_library
|
||||
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/widget-plugin-library_export.h"
|
||||
)
|
||||
|
||||
# Creating the collection
|
||||
|
||||
qt_add_library(widget-plugin-collection
|
||||
set(WIDGET_PLUGIN_COLLECTION widget-plugin-collection_${PROJECT_NAME_LOWER})
|
||||
qt_add_library(${WIDGET_PLUGIN_COLLECTION}
|
||||
widgetplugincollection.cpp widgetplugincollection.h
|
||||
)
|
||||
target_link_libraries(widget-plugin-collection
|
||||
Qt6::Widgets Qt6::UiPlugin widget-plugin-library
|
||||
target_link_libraries(${WIDGET_PLUGIN_COLLECTION}
|
||||
Qt6::Widgets Qt6::UiPlugin ${WIDGET_PLUGIN_LIBRARY}
|
||||
)
|
||||
install(TARGETS widget-plugin-collection
|
||||
install(TARGETS ${WIDGET_PLUGIN_COLLECTION}
|
||||
RUNTIME DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
BUNDLE DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
@@ -101,10 +117,11 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/app-dir.h.in"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
qt_add_executable(widget-app
|
||||
set(WIDGET_APP widget-app_${PROJECT_NAME_LOWER})
|
||||
qt_add_executable(${WIDGET_APP}
|
||||
widgetapp.cpp widgetapp.h widgetapp.ui
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(widget-app
|
||||
PRIVATE Qt::Widgets widget-plugin-library
|
||||
target_link_libraries(${WIDGET_APP}
|
||||
PRIVATE Qt::Widgets ${WIDGET_PLUGIN_LIBRARY}
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef APPDIR_H_IN
|
||||
#define APPDIR_H_IN
|
||||
|
||||
#define APP_DIR "/home/kapper/Code/klips/cpp/qt/designer-plugin-collection"
|
||||
#define APP_DIR "/media/shaun/Storage/Code/klips/cpp/qt/designer-plugin-collection"
|
||||
|
||||
#endif // APPDIR_H_IN
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
################################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## Legal: All Content (c) 2025 Shaun Reed, all rights reserved ##
|
||||
## About: Example of making widget plugins for Qt Designer ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
@@ -14,6 +14,9 @@ project(
|
||||
DESCRIPTION "Example of a widget plugin for Qt Designer"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
message(STATUS "[Klips] Configuring example: ${PROJECT_NAME}")
|
||||
# Lowercase string to use as a slug for executable names for identification.
|
||||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
|
||||
@@ -42,35 +45,44 @@ endif()
|
||||
set(QT_INSTALL_DIR "${QT_DIR}/6.3.1/gcc_64/" CACHE PATH "Path to Qt6 install")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL_DIR}")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS UiPlugin Core Gui Widgets)
|
||||
find_package(Qt6 COMPONENTS UiPlugin Core Gui Widgets)
|
||||
if (NOT Qt6_FOUND)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"[Klips] Error: CMake was unable to find Qt6 libraries.\n"
|
||||
"The example will not be built until the build is configured with these packages installed.\n"
|
||||
"On Ubuntu 24.04 Qt6 can be installed using apt:\n"
|
||||
" sudo apt-get install qt6-base-dev qt6-tools-dev\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Creating the plugin
|
||||
|
||||
qt_add_library(widget-plugin)
|
||||
target_sources(widget-plugin PRIVATE
|
||||
set(WIDGET_PLUGIN widget-plugin_${PROJECT_NAME_LOWER})
|
||||
qt_add_library(${WIDGET_PLUGIN})
|
||||
target_sources(${WIDGET_PLUGIN} PRIVATE
|
||||
text-view.cpp text-view.h
|
||||
widget-plugin.cpp widget-plugin.h
|
||||
)
|
||||
set_target_properties(widget-plugin PROPERTIES
|
||||
set_target_properties(${WIDGET_PLUGIN} PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
target_link_libraries(widget-plugin PUBLIC
|
||||
target_link_libraries(${WIDGET_PLUGIN} PUBLIC
|
||||
Qt::UiPlugin Qt::Core Qt::Gui Qt::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS widget-plugin
|
||||
install(TARGETS ${WIDGET_PLUGIN}
|
||||
RUNTIME DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
BUNDLE DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${QT_PLUGIN_INSTALL_DIR}"
|
||||
)
|
||||
|
||||
# Application that will use the widget plugin
|
||||
|
||||
qt_add_executable(widget-app
|
||||
set(WIDGET_APP widget-app_${PROJECT_NAME_LOWER})
|
||||
qt_add_executable(${WIDGET_APP}
|
||||
widget-app.cpp widget-app.h widget-app.ui
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(widget-app PRIVATE
|
||||
Qt::Widgets widget-plugin
|
||||
target_link_libraries(${WIDGET_APP} PRIVATE
|
||||
Qt::Widgets ${WIDGET_PLUGIN}
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
################################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## Legal: All Content (c) 2025 Shaun Reed, all rights reserved ##
|
||||
## About: Practice project for using Qt Designer with custom C++ widgets ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
@@ -14,6 +14,7 @@ project(
|
||||
DESCRIPTION "Practice using Qt designer for desktop applications"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
message(STATUS "[Klips] Configuring example: ${PROJECT_NAME}")
|
||||
|
||||
add_compile_options(-Wall)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
@@ -28,7 +29,16 @@ set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6")
|
||||
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_DIR}")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
find_package(Qt6 COMPONENTS Core Gui Widgets)
|
||||
if (NOT Qt6_FOUND)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"[Klips] Error: CMake was unable to find Qt6 libraries.\n"
|
||||
"The example will not be built until the build is configured with these packages installed.\n"
|
||||
"On Ubuntu 24.04 Qt6 can be installed using apt:\n"
|
||||
" sudo apt-get install qt6-base-dev qt6-tools-dev\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_add_executable(designer
|
||||
designer.cpp designer.h designer.ui
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
################################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## Legal: All Content (c) 2025 Shaun Reed, all rights reserved ##
|
||||
## About: Practice project for using signals and slots in Qt ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
@@ -14,6 +14,7 @@ project(
|
||||
DESCRIPTION "Practice using signals and slots in Qt 6"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
message(STATUS "[Klips] Configuring example: ${PROJECT_NAME}")
|
||||
|
||||
add_compile_options(-Wall)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
@@ -28,7 +29,16 @@ set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6")
|
||||
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_DIR}")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
|
||||
find_package(Qt6 COMPONENTS Core Gui Widgets)
|
||||
if (NOT Qt6_FOUND)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"[Klips] Error: CMake was unable to find Qt6 libraries.\n"
|
||||
"The example will not be built until the build is configured with these packages installed.\n"
|
||||
"On Ubuntu 24.04 Qt6 can be installed using apt:\n"
|
||||
" sudo apt-get install qt6-base-dev qt6-tools-dev\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_add_executable(slots
|
||||
text-view.cpp text-view.h
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
public:
|
||||
signals:
|
||||
void sendTest()QWidget;
|
||||
void sendTest();
|
||||
|
||||
private:
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user