Skip to content

fix: restore application icon and suppress console window on Windows#354

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/windows-icon-and-console
Mar 5, 2026
Merged

fix: restore application icon and suppress console window on Windows#354
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/windows-icon-and-console

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

Fixes two regressions in the Windows build introduced by the autotools-to-CMake migration.

1. Missing application icon

The Windows resource file src/gerbv.rc was not being compiled into the executable. The old autotools build used WINDRES to compile it and link the resulting object, but the CMake build never added it to the target sources.

Fix: Add gerbv.rc to gerbv-app sources when building for Windows. Updated the .rc file to use the correct relative path to desktop/gerbv_icon.ico.

2. Unwanted console window

The -mwindows linker flag was not set in the CMake build. Without it, Windows creates a console window for every process. The existing attach_console_for_win() function in main.c was written assuming -mwindows is active — it re-attaches to the parent console when gerbv is launched from a terminal, but that only works when the default console is suppressed.

Fix: Add -mwindows to the linker options for gerbv-app on Windows.

Changes

  • src/CMakeLists.txt — Add WIN32 block with target_sources for the .rc file and target_link_options for -mwindows
  • src/gerbv.rc — Update icon path from gerbv_icon.ico to ../desktop/gerbv_icon.ico

Ref #333

The CMake build was missing two things that the old autotools build
had for Windows:

1. The Windows resource file (gerbv.rc) was not compiled into the
   executable, so the application icon was missing — Windows showed
   the default GTK icon instead.  Add gerbv.rc to the gerbv-app
   target sources and update the icon path to reference the existing
   desktop/gerbv_icon.ico.

2. The -mwindows linker flag was not set, so Windows always created
   a console window for the process.  The existing
   attach_console_for_win() function in main.c handles re-attaching
   to the parent console when launched from a terminal, but it
   requires -mwindows to suppress the default console.

Ref gerbv#333
@spe-ciellt spe-ciellt added fix Solution for a potential problem or omission. buildsystem Updates to the buildsystem (CMake/CTest/CPack) labels Mar 5, 2026
@spe-ciellt spe-ciellt merged commit f7f1c95 into gerbv:develop Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildsystem Updates to the buildsystem (CMake/CTest/CPack) fix Solution for a potential problem or omission.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants