Skip to content

Add applicaton icon for Windows build - #95

Closed
christianhelle wants to merge 4 commits into
masterfrom
windows-icon
Closed

Add applicaton icon for Windows build#95
christianhelle wants to merge 4 commits into
masterfrom
windows-icon

Conversation

@christianhelle

@christianhelle christianhelle commented Nov 19, 2025

Copy link
Copy Markdown
Owner
  • Fix Windows build script for VS preview versions
  • Switch to Ninja as the CMake generator for local builds
  • Update icon.ico with multi-resolution support
  • Add Windows icon resource to executable

Summary by CodeRabbit

  • New Features

    • Added Windows application icon resources to ensure proper icon display on Windows systems.
  • Build & Infrastructure

    • Improved Windows build process with enhanced environment validation and tooling optimization.

- Add -prerelease flag to vswhere to detect preview/insider VS
- Explicitly specify Visual Studio 17 2022 CMake generator
- Add prerequisite validation for VS and Qt installations
- Add error handling after CMake configuration and build steps
- Fix trailing whitespace
Copilot AI review requested due to automatic review settings November 19, 2025 08:48
@christianhelle christianhelle self-assigned this Nov 19, 2025
@coderabbitai

coderabbitai Bot commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Build configuration updated to include Windows-specific icon resources in CMake executable targets. Windows PowerShell build script completely rewritten to implement preflight environment validation (Ninja and Visual Studio detection), use Ninja generator with Visual Studio environment setup via vcvars64.bat, and add packaging steps with windeployqt and Inno Setup support.

Changes

Cohort / File(s) Summary
Windows Icon Resource Configuration
src/project/CMakeLists.txt
Added Windows-specific icon resource inclusion to both Qt and non-Qt executable build paths using generator expressions ($<$<PLATFORM_ID:Windows>:${app_icon_resource_windows}>)
Windows Build Script Rewrite
src/project/build.ps1
Completely restructured Windows build workflow to include: preflight Ninja/Visual Studio validation, vswhere-based VS detection (including prereleases), Qt 6.9.0 MSVC2022 path verification, vcvars64.bat environment setup, Ninja-based CMake configuration with updated prefixes and C++ standard, and packaging phase with windeployqt and Inno Setup invocation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Extra attention needed on src/project/build.ps1:
    • vcvars64.bat path validation and environment variable setup correctness
    • vswhere command syntax for Visual Studio detection (including prerelease handling)
    • CMake configuration flags and their alignment with project requirements
    • Error propagation and messaging in preflight check paths
    • windeployqt invocation and packaging workflow integrity

Suggested labels

build

Poem

🐰 Icons now nest in Windows homes,
With Ninja swift through build-script roams,
Visual Studio detected true,
vcvars dance and preflight flew,
Packaging bundled, clean and bright—
All systems go! The build's just right!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title mentions adding an application icon for Windows, but the actual changes include significant Windows build script rewrites, Ninja generator setup, and multi-resolution icon updates—making the title only partially representative of the scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch windows-icon

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Windows application icon support and improves the Windows build process by integrating Ninja as the CMake generator and adding support for Visual Studio preview versions.

  • Adds multi-resolution icon.ico file with embedded PNG images
  • Updates Windows build script to detect VS preview versions using vswhere with -prerelease flag
  • Switches to Ninja generator for faster Windows builds with proper environment setup via vcvars64.bat

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/resources/icon.ico New multi-resolution icon file with embedded PNG images at various sizes (16x16, 32x32, 48x48, 64x64, 128x128, 256x256)
src/project/build.ps1 Enhanced Windows build with Ninja generator support, VS preview detection via vswhere, improved error handling, and vcvars64.bat environment setup
src/project/CMakeLists.txt Added Windows icon resource (app_icon_resource_windows) to executable compilation

Comment thread src/project/build.ps1
}

if ($Package) {
mkdir .\build\Release

Copilot AI Nov 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mkdir command can fail if the directory already exists. Add -Force parameter to prevent errors on subsequent builds: mkdir .\build\Release -Force

Suggested change
mkdir .\build\Release
mkdir .\build\Release -Force

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/project/build.ps1 (2)

14-20: Verify vswhere.exe availability before use.

The script uses a hardcoded path to vswhere.exe without first verifying it exists. If Visual Studio Installer is missing or in a non-standard location, this will fail with a cryptic error.

Apply this diff to check vswhere existence first:

+    # Check if vswhere is available
+    $vswherePath = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+    if (-not (Test-Path $vswherePath)) {
+        Write-Error "vswhere.exe not found. Visual Studio Installer may not be installed correctly."
+        exit 1
+    }
+    
     # Check if Visual Studio is installed (including preview versions) for compiler
-    $vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -property installationPath 2>$null
+    $vsPath = & $vswherePath -latest -prerelease -property installationPath 2>$null

49-53: LGTM! Consider consolidating vcvars calls.

The build command is correctly implemented with good error handling.

For efficiency, consider running both CMake commands in a single cmd session:

-    # Setup Visual Studio environment and run CMake with Ninja generator
-    & cmd /c "`"$vcvars`" && cmake . -G `"$generator`" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.0\msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=`"/Zc:__cplusplus /permissive-`" -DCMAKE_BUILD_TYPE=Release -B build"
-    if ($LASTEXITCODE -ne 0) {
-        Write-Error "CMake configuration failed"
-        exit $LASTEXITCODE
-    }
-    
-    & cmd /c "`"$vcvars`" && cmake --build build --parallel 32"
+    # Setup Visual Studio environment and run CMake configure + build
+    & cmd /c "`"$vcvars`" && cmake . -G `"$generator`" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.0\msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=`"/Zc:__cplusplus /permissive-`" -DCMAKE_BUILD_TYPE=Release -B build && cmake --build build --parallel 32"
     if ($LASTEXITCODE -ne 0) {
-        Write-Error "Build failed"
+        Write-Error "CMake configuration or build failed"
         exit $LASTEXITCODE
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f589cf and 24eb946.

⛔ Files ignored due to path filters (1)
  • src/resources/icon.ico is excluded by !**/*.ico
📒 Files selected for processing (2)
  • src/project/CMakeLists.txt (1 hunks)
  • src/project/build.ps1 (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (5)
src/project/CMakeLists.txt (2)

65-65: LGTM!

The fallback add_executable path correctly includes the Windows icon resource, maintaining consistency with the qt_add_executable path.


59-59: LGTM. Icon resource file verified to exist.

The Windows icon resource is correctly added using CMake generator expressions, and verification confirms the icon resource file exists at src/resources/icon.rc.

src/project/build.ps1 (3)

7-12: LGTM!

The Ninja preflight check is well-implemented with clear error messages and installation guidance.


35-40: LGTM!

The vcvars64.bat detection and validation is properly implemented with clear error messaging.


42-47: CMake configuration approach is sound, but inherits hardcoded Qt path.

The CMake configuration with Ninja generator and MSVC environment setup is correctly implemented. However, it uses the same hardcoded Qt path flagged earlier.

Note: This comment approves the configuration approach. The hardcoded Qt path issue is addressed in a separate comment (lines 28-33).

Comment thread src/project/build.ps1
Comment thread src/project/build.ps1
Comment on lines +56 to +57
mkdir .\build\Release
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add error handling and safe directory creation.

The packaging steps lack error handling and may fail if the directory already exists.

Apply this diff to improve robustness:

-        mkdir .\build\Release
+        if (-not (Test-Path .\build\Release)) {
+            New-Item -ItemType Directory -Path .\build\Release -Force | Out-Null
+        }
+        
+        if (-not (Test-Path .\build\SQLiteQueryAnalyzer.exe)) {
+            Write-Error "Build output not found: .\build\SQLiteQueryAnalyzer.exe"
+            exit 1
+        }
+        
         Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir .\build\Release
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
if (-not (Test-Path .\build\Release)) {
New-Item -ItemType Directory -Path .\build\Release -Force | Out-Null
}
if (-not (Test-Path .\build\SQLiteQueryAnalyzer.exe)) {
Write-Error "Build output not found: .\build\SQLiteQueryAnalyzer.exe"
exit 1
}
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
🤖 Prompt for AI Agents
In src/project/build.ps1 around lines 56 to 57, the script unconditionally calls
mkdir and Copy-Item which will fail if the directory already exists or if copy
errors occur; update to create the Release folder safely (use Test-Path or
New-Item -ItemType Directory -Force) and wrap the directory creation and
Copy-Item in a try/catch with -ErrorAction Stop so failures are caught; on
error, write a clear error message to stderr (Write-Error or Write-Host with
red) and exit with a non-zero code to fail the build.

Comment thread src/project/build.ps1
@christianhelle
christianhelle deleted the windows-icon branch November 19, 2025 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants