qt-cmake-project-generator
Generate CMake-based Qt project with proper module dependencies, cross-compilation support, and modern Qt6 configuration
What this skill does
# qt-cmake-project-generator
Generate CMake-based Qt project configurations with proper module dependencies and cross-compilation support. This skill handles Qt6 CMake integration, module discovery, and platform-specific build configurations.
## Capabilities
- Generate modern CMake configuration for Qt6 projects
- Configure Qt module dependencies (Core, Widgets, Quick, Network, etc.)
- Set up cross-compilation toolchains
- Configure vcpkg/Conan package management integration
- Generate platform-specific build configurations
- Set up Qt deployment scripts (windeployqt, macdeployqt)
- Configure static vs dynamic linking
- Generate CMake presets for development and CI
## Input Schema
```json
{
"type": "object",
"properties": {
"projectPath": {
"type": "string",
"description": "Path to create/update the Qt project"
},
"projectName": {
"type": "string",
"description": "Project name"
},
"qtVersion": {
"type": "string",
"default": "6.6",
"description": "Target Qt version"
},
"qtModules": {
"type": "array",
"items": {
"enum": ["Core", "Gui", "Widgets", "Quick", "Qml", "Network", "Sql", "Multimedia", "WebEngine", "Charts", "3D"]
},
"default": ["Core", "Gui", "Widgets"]
},
"appType": {
"enum": ["widgets", "quick", "console", "library"],
"default": "widgets"
},
"targetPlatforms": {
"type": "array",
"items": { "enum": ["windows", "macos", "linux", "android", "ios", "wasm"] }
},
"packageManager": {
"enum": ["none", "vcpkg", "conan"],
"default": "none"
},
"cppStandard": {
"enum": ["17", "20", "23"],
"default": "17"
},
"generatePresets": {
"type": "boolean",
"default": true
}
},
"required": ["projectPath", "projectName"]
}
```
## Output Schema
```json
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"description": { "type": "string" }
}
}
},
"buildCommands": {
"type": "object",
"properties": {
"configure": { "type": "string" },
"build": { "type": "string" },
"install": { "type": "string" }
}
},
"warnings": { "type": "array", "items": { "type": "string" } }
},
"required": ["success"]
}
```
## Generated CMakeLists.txt Example
```cmake
cmake_minimum_required(VERSION 3.21)
project(MyQtApp VERSION 1.0.0 LANGUAGES CXX)
# C++ Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Qt Configuration
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# Find Qt packages
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
# Source files
set(SOURCES
src/main.cpp
src/mainwindow.cpp
src/mainwindow.h
src/mainwindow.ui
)
# Resources
set(RESOURCES
resources/resources.qrc
)
# Create executable
qt_add_executable(${PROJECT_NAME}
${SOURCES}
${RESOURCES}
)
# Link Qt libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
)
# Platform-specific settings
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE TRUE
)
elseif(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/platform/macos/Info.plist"
)
endif()
# Installation
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Qt deployment
qt_generate_deploy_app_script(
TARGET ${PROJECT_NAME}
OUTPUT_SCRIPT deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
```
## CMake Presets
```json
{
"version": 6,
"configurePresets": [
{
"name": "default",
"displayName": "Default",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"inherits": "default",
"displayName": "Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows-msvc",
"inherits": "default",
"displayName": "Windows MSVC",
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "macos",
"inherits": "default",
"displayName": "macOS",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "linux",
"inherits": "default",
"displayName": "Linux",
"generator": "Ninja",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "release",
"configurePreset": "release"
}
]
}
```
## Cross-Compilation Toolchain
```cmake
# toolchain-linux-aarch64.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSROOT /opt/sysroots/aarch64-linux-gnu)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
```
## Package Manager Integration
### vcpkg
```cmake
# CMakeLists.txt
if(DEFINED ENV{VCPKG_ROOT})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
endif()
```
### Conan
```python
# conanfile.py
from conan import ConanFile
from conan.tools.cmake import cmake_layout
class MyQtAppConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
def requirements(self):
self.requires("qt/6.6.0")
def layout(self):
cmake_layout(self)
```
## Best Practices
1. **Use qt_add_executable**: Preferred over add_executable for Qt6
2. **Enable AUTOMOC/AUTOUIC/AUTORCC**: Automatic meta-object compilation
3. **Use CMake Presets**: Simplify configuration for different environments
4. **Version your Qt requirement**: `find_package(Qt6 6.4 REQUIRED ...)`
5. **Use modern CMake**: target_* commands over global settings
6. **Generate deploy scripts**: Use Qt's deployment tools
## Related Skills
- `qt-qml-component-generator` - QML component creation
- `qt-installer-framework-config` - Installer configuration
- `qt-test-fixture-generator` - Test setup
## Related Agents
- `qt-cpp-specialist` - Qt/C++ expertise
- `desktop-ci-architect` - CI/CD for Qt projects
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.