Skip to content

cmake: fix tarball builds and generated path handling#303

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
chenrui333:fix-homebrew-2-11-0-cmake
Mar 1, 2026
Merged

cmake: fix tarball builds and generated path handling#303
spe-ciellt merged 1 commit intogerbv:developfrom
chenrui333:fix-homebrew-2-11-0-cmake

Conversation

@chenrui333
Copy link
Copy Markdown
Contributor

@chenrui333 chenrui333 commented Mar 1, 2026

Fix CMake tarball builds used by downstream packaging.

  • fall back to PROJECT_VERSION when Git metadata is unavailable
  • fix generated-source path handling for gettext inputs
  • avoid configure-time manpage compression failure by installing the configured manpage directly
  • keep Homebrew-specific compile/rpath adjustments in-tree for macOS/Linux

Ref: Homebrew/homebrew-core#269931

@chenrui333 chenrui333 force-pushed the fix-homebrew-2-11-0-cmake branch from d76e8c1 to 5c3e522 Compare March 1, 2026 06:11
@chenrui333 chenrui333 changed the title cmake: fix tarball version fallback and generated deps cmake: fix tarball builds and generated path handling Mar 1, 2026
@chenrui333 chenrui333 force-pushed the fix-homebrew-2-11-0-cmake branch from 5c3e522 to 6121699 Compare March 1, 2026 06:13
@chenrui333 chenrui333 marked this pull request as draft March 1, 2026 06:14
@chenrui333 chenrui333 force-pushed the fix-homebrew-2-11-0-cmake branch from 6121699 to 758321e Compare March 1, 2026 06:15
Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333 chenrui333 force-pushed the fix-homebrew-2-11-0-cmake branch from 758321e to 13e73c2 Compare March 1, 2026 06:17
@chenrui333 chenrui333 marked this pull request as ready for review March 1, 2026 06:40
@spe-ciellt spe-ciellt self-assigned this Mar 1, 2026
@spe-ciellt spe-ciellt added the buildsystem Updates to the buildsystem (CMake/CTest/CPack) label Mar 1, 2026
@spe-ciellt
Copy link
Copy Markdown
Contributor

Thank you for this pull request, looks relevant. I will double check this and merge if OK in a couple of days.

@rampageservices
Copy link
Copy Markdown
Contributor

Reviewed for security and consistency. Looks good overall — no security concerns, sensible packaging fixes. A few notes:

GetGitVersion.cmake — The PROJECT_VERSION fallback and moving the dirty check inside the else (successful git describe) branch are both correct. Previously, a failed git describe would still run the dirty check against a potentially absent HEAD, which could produce confusing errors in tarball builds.

config/CMakeLists.txt — Changing generated from add_library(INTERFACE) to add_custom_target(DEPENDS ...) is the right call. The old target_sources(generated PRIVATE bugs.c authors.c) on an INTERFACE library is questionable CMake — INTERFACE libraries shouldn't own source files. A custom target purely expressing the dependency is cleaner.

locale/CMakeLists.txt — Using get_filename_component() to resolve absolute path and adding add_dependencies(${GETTEXT_TARGET} generated) fixes the build order issue where gettext might try to scan authors.c/bugs.c before they're generated. Correct.

man/CMakeLists.txt — Removing the file(ARCHIVE_CREATE) gzip step and installing the uncompressed .1 file directly. This delegates compression to the packaging system (dpkg, rpm, etc.) which is the standard approach. Clean.

src/CMakeLists.txt — Replacing target_link_libraries(... generated) with add_dependencies(gerbv-app generated) is consistent with the config/ change. The macOS INSTALL_RPATH addition is correct for Homebrew's lib layout.

CMakeLists.txtQUARTZ define on APPLE is needed — callbacks.c and render.c use #if defined(QUARTZ) for macOS-specific paths, and the CMake build was not defining it (commit ae525ba changed the checks from #if QUARTZ to #if defined(QUARTZ) in anticipation of this). _GNU_SOURCE on Linux is used by lrealpath.c for canonicalize_file_name.

No issues found. LGTM.

@rampageservices
Copy link
Copy Markdown
Contributor

Additional note: the _GNU_SOURCE define on Linux also fixes pre-existing undeclared-identifier errors for M_PI_2 and M_1_PI.

These are POSIX/XSI math constants (not C standard), and the project sets CMAKE_C_EXTENSIONS OFF which produces -std=c23 instead of -std=gnu23. Without a feature-test macro, <math.h> on glibc won't expose them.

Constant Where used
M_PI_2 draw-gdk.c, draw.c, gerb_image.c, interface.c, gerber.c (15 uses total)
M_1_PI gerbv.h:118 via RAD2DEG() — propagates to every file including the public header
M_PI gerbv.h:117 via DEG2RAD(), draw-gdk.c

_GNU_SOURCE implies _XOPEN_SOURCE on glibc, which gates all three constants in <math.h>. On macOS they're available by default, so the Linux-only scope is correct. This PR effectively fixes the build on strict-C toolchains.

@spe-ciellt spe-ciellt merged commit 750aa35 into gerbv:develop Mar 1, 2026
2 checks passed
chenrui333 added a commit to chenrui333/gerbv that referenced this pull request Mar 1, 2026
Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333 chenrui333 mentioned this pull request Mar 1, 2026
@chenrui333
Copy link
Copy Markdown
Contributor Author

Thanks for the merge, also log a pr to add macos CI, #327.

@chenrui333 chenrui333 deleted the fix-homebrew-2-11-0-cmake branch March 1, 2026 19:12
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants