Skip to content

Install pkg-config files for libf3d and libf3d_c_api - #3451

Merged
Meakk merged 7 commits into
f3d-app:masterfrom
AnikethTS:pkgconfig-install
Aug 24, 2026
Merged

Install pkg-config files for libf3d and libf3d_c_api#3451
Meakk merged 7 commits into
f3d-app:masterfrom
AnikethTS:pkgconfig-install

Conversation

@AnikethTS

Copy link
Copy Markdown
Contributor

Describe your changes

  • Adds .pc pkg-config files for libf3d (f3d) and libf3d_c_api (f3d_c_api), installed alongside the existing CMake config files.
  • Adds new cmake/f3d.pc.in and cmake/f3d_c_api.pc.in templates, rendered using configure_file(... @ONLY).
  • Wires the generated files into library/CMakeLists.txt and c/CMakeLists.txt as part of the existing sdk install component.
  • Adds HOMEPAGE_URL to the top-level project() call so PROJECT_HOMEPAGE_URL can be used for the .pc URL: field.
  • Adds Requires.private: f3d to f3d_c_api.pc, matching the private dependency between the two targets.
  • Uses hand-written .pc templates instead of cmake-pcfilegenerator due to its GPL-3.0 license and its generated library name (-llibf3d) not matching F3D's actual OUTPUT_NAME (-lf3d).
  • Tested the templates in a standalone CMake project and validated the generated files with pkg-config --validate and pkg-config --cflags --libs.
  • A full F3D build was not performed since VTK is not available locally.

Issue ticket number and link if any

Closes [#3432]

Checklist for finalizing the PR

  • I have performed a self-review of my code
  • I have added tests for new features and bugfixes
  • I have added documentation for new features
  • If it is a modifying the libf3d API, I have updated bindings
  • If it is a modifying the .github/workflows/versions.json, I have updated docker_timestamp

AI Disclosure

  • I have not used AI to generate any of the content of this pull request

  • I have used AI to generate code in this pull request:

    • I have carefully read and understood the [AI policy](https://f3d.app/dev/AI_POLICY).
    • I have carefully reviewed and completely understood every generated line.
    • I disclose below which parts of the code were generated and with which AI model:

Used Claude (Anthropic, Claude Sonnet 5, via Claude Code) to help write cmake/f3d.pc.in and cmake/f3d_c_api.pc.in, the configure_file()/install() wiring in library/CMakeLists.txt and c/CMakeLists.txt, and the HOMEPAGE_URL line in the top-level CMakeLists.txt.

...

Continuous integration

Please write a comment to run CI, eg: \ci fast.

See here for more info.(https://f3d.app/dev/CONTRIBUTING#continuous-integration) for more info.

@AnikethTS

Copy link
Copy Markdown
Contributor Author

\ci fast

@AnikethTS

Copy link
Copy Markdown
Contributor Author

\ci extended

@AnikethTS
AnikethTS marked this pull request as ready for review August 21, 2026 11:50
@AnikethTS
AnikethTS requested a review from a team as a code owner August 21, 2026 11:50
Comment thread CMakeLists.txt Outdated
@mwestphal

Copy link
Copy Markdown
Member

A full F3D build was not performed since VTK is not available locally.

So how did you test this locally ? Im a bit confused.

@AnikethTS

Copy link
Copy Markdown
Contributor Author

A full F3D build was not performed since VTK is not available locally.

So how did you test this locally ? Im a bit confused.

I didn’t have VTK available locally, so I couldn’t build the full project. What I tested locally was rendering the .pc.in templates with configure_file() in a small standalone CMake project, then validating the generated files with pkg-config --validate, --cflags, and --libs. This confirmed the .pc files themselves. The actual install() wiring in library/CMakeLists.txt and c/CMakeLists.txt was then tested through \ci fast and \ci extended with a real VTK build, and both passed, providing the full end-to-end confirmation.

@mwestphal

Copy link
Copy Markdown
Member

A full F3D build was not performed since VTK is not available locally.

So how did you test this locally ? Im a bit confused.

I didn’t have VTK available locally, so I couldn’t build the full project. What I tested locally was rendering the .pc.in templates with configure_file() in a small standalone CMake project, then validating the generated files with pkg-config --validate, --cflags, and --libs. This confirmed the .pc files themselves. The actual install() wiring in library/CMakeLists.txt and c/CMakeLists.txt was then tested through \ci fast and \ci extended with a real VTK build, and both passed, providing the full end-to-end confirmation.

Not acceptable, here is the guide to build VTK and F3D.
https://f3d.app/dev/GETTING_STARTED

We are not interested by "passing by contributors" by the way.

@AnikethTS

Copy link
Copy Markdown
Contributor Author

A full F3D build was not performed since VTK is not available locally.

So how did you test this locally ? Im a bit confused.

I didn’t have VTK available locally, so I couldn’t build the full project. What I tested locally was rendering the .pc.in templates with configure_file() in a small standalone CMake project, then validating the generated files with pkg-config --validate, --cflags, and --libs. This confirmed the .pc files themselves. The actual install() wiring in library/CMakeLists.txt and c/CMakeLists.txt was then tested through \ci fast and \ci extended with a real VTK build, and both passed, providing the full end-to-end confirmation.

Not acceptable, here is the guide to build VTK and F3D. https://f3d.app/dev/GETTING_STARTED

We are not interested by "passing by contributors" by the way.

Fair enough — I’ll get a proper local build going. I don’t have VTK installed right now, so I’m setting that up first. The repo already has a vcpkg preset that builds VTK from the pinned manifest, so I’ll use that instead of relying on a potentially outdated system package.

Once it’s built, I’ll test the actual pkg-config output locally and report back with the results rather than just relying on CI.

c/CMakeLists.txt calls its own project(f3d_c_api), which resets the
generic PROJECT_DESCRIPTION/PROJECT_HOMEPAGE_URL variables for that
subdirectory scope. Use the name-qualified F3D_DESCRIPTION/F3D_HOMEPAGE_URL
variables instead, which stay tied to the top-level F3D project regardless
of nested project() calls.
@AnikethTS

Copy link
Copy Markdown
Contributor Author

A full F3D build was not performed since VTK is not available locally.

So how did you test this locally ? Im a bit confused.

I didn’t have VTK available locally, so I couldn’t build the full project. What I tested locally was rendering the .pc.in templates with configure_file() in a small standalone CMake project, then validating the generated files with pkg-config --validate, --cflags, and --libs. This confirmed the .pc files themselves. The actual install() wiring in library/CMakeLists.txt and c/CMakeLists.txt was then tested through \ci fast and \ci extended with a real VTK build, and both passed, providing the full end-to-end confirmation.

Not acceptable, here is the guide to build VTK and F3D. https://f3d.app/dev/GETTING_STARTED

We are not interested by "passing by contributors" by the way.

I followed the guide and did a full local build rather than just relying on the earlier template test.

  • Built VTK v9.7.0 from source on Fedora 44, matching the version F3D’s Linux CI uses.
  • Built F3D with -DF3D_BINDINGS_C=ON, so both libf3d and libf3d_c_api were built.
  • Ran the actual install sequence used by CI: cmake --install ., followed by the sdk, mimetypes, configuration, and colormaps components.

This also caught a real issue that the CI and standalone template test didn't catch. c/CMakeLists.txt has its own project(f3d_c_api) call, which resets the generic PROJECT_DESCRIPTION and PROJECT_HOMEPAGE_URL variables. As a result, the generated f3d_c_api.pc had empty Description: and URL: fields.

I fixed this by using the name-qualified F3D_DESCRIPTION and F3D_HOMEPAGE_URL variables instead, which remain tied to the top-level project even with the nested project() call.

The fix is pushed in commit 43056b34.

Reviewer flagged the top-level project() HOMEPAGE_URL addition as unrelated
scope creep for a pkg-config-only change. The URL is a static value, so
hardcode it directly in both .pc.in templates instead of threading it
through a new CMake project() argument.
@mwestphal
mwestphal self-requested a review August 23, 2026 06:22

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

Please add simple c and c++ examples in examples/libf3d in order to be able to test this easily.

Plain Makefile-based examples (no CMake) demonstrating how to build
against libf3d/libf3d_c_api using the new .pc files, matching the
check-engine example's minimal style. Not wired into the CMake example
test suite since they intentionally use pkg-config instead of
find_package(f3d), same as external-glfw/qt6/fltk being standalone.

Built and run locally against a real VTK 9.7.0 + F3D build.
@AnikethTS

Copy link
Copy Markdown
Contributor Author

Looks good!

Please add simple c and c++ examples in examples/libf3d in order to be able to test this easily.

Added both examples/libf3d/c/pkgconfig/ and examples/libf3d/cpp/pkgconfig/ with simple Makefiles, no CMake, keeping them in the same minimal style as check-engine.

I also built and ran both examples locally against a real VTK 9.7.0 + F3D build to make sure they actually work.

One small thing I ran into: VTK doesn't provide a .pc file, so f3d.pc can't list VTK under Requires. If VTK isn't installed somewhere standard, you need -Wl,-rpath-link,/path/to/vtk/lib when linking and LD_LIBRARY_PATH at runtime. I left a note about this in both Makefiles.

Pushed as 8943380a.

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice examples, next please add a step in linux generic ci that configure and build both examples

@mwestphal

Copy link
Copy Markdown
Member

One small thing I ran into: VTK doesn't provide a .pc file, so f3d.pc can't list VTK under Requires. If VTK isn't installed somewhere standard, you need -Wl,-rpath-link,/path/to/vtk/lib when linking and LD_LIBRARY_PATH at runtime. I left a note about this in both Makefiles.

Yes, expected

Adds a step after the existing example tests that discovers the
installed f3d.pc/f3d_c_api.pc and VTK's lib directory, then builds
and runs both pkg-config examples with the sdk component's .pc
files, mirroring what a real downstream user would do.
Comment thread .github/actions/generic-ci/action.yml Outdated
Comment thread .github/actions/generic-ci/action.yml Outdated

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some questions

Reviewer pointed out find is unnecessary since the install and
dependency paths are already known/used elsewhere in this file.
@AnikethTS

Copy link
Copy Markdown
Contributor Author

some questions

Hope that answers your questions above.

Comment thread examples/libf3d/c/pkgconfig/Makefile Outdated
Comment thread examples/libf3d/cpp/pkgconfig/Makefile Outdated

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, ill run CI

@mwestphal

Copy link
Copy Markdown
Member

…docs

.pc files baked in the literal (possibly relative) CMAKE_INSTALL_PREFIX
string, which broke when read from a different working directory than
the build dir - exactly what happened in CI (-DCMAKE_INSTALL_PREFIX=../install).
Resolve it to an absolute path before substitution instead.

Also confirmed LD_LIBRARY_PATH alone (exported before both building and
running) is enough for a non-standard VTK install, since ld also consults
it at link time for transitive symbols - drops the separate
-Wl,-rpath-link LDFLAGS from both example Makefiles and the CI step.
@AnikethTS

Copy link
Copy Markdown
Contributor Author

nevermind, CI is failing already:

https://github.com/f3d-app/f3d/actions/runs/32662549287/job/97250874383?pr=3451

Fixed the root cause: the .pc files were getting the literal relative CMAKE_INSTALL_PREFIX (../install) baked into them. That worked during cmake --install, but broke when pkg-config read the files from a different working directory. I’ve changed it to resolve the install path to an absolute path before generating the .pc files.

Also followed your LD_LIBRARY_PATH suggestion further. Confirmed that exporting it once before both make and running the examples is enough, since the linker also uses it when resolving transitive dependencies. So I removed the separate -Wl,-rpath-link flags from both Makefiles and the CI step.

Verified everything locally with a full rebuild using the same relative install prefix as CI, then ran both pkg-config examples end-to-end successfully.

Pushed in 803c819.

@AnikethTS
AnikethTS requested a review from mwestphal August 23, 2026 21:11
@mwestphal

Copy link
Copy Markdown
Member

\ci full

Comment thread library/CMakeLists.txt

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A question

@AnikethTS

Copy link
Copy Markdown
Contributor Author

Hope that answers your questions above.

Hope that answers your questions above.

@mwestphal
mwestphal requested a review from Meakk August 24, 2026 13:35
@mwestphal

Copy link
Copy Markdown
Member

@Meakk wanna take a look ?

@Meakk
Meakk merged commit 9c3a2cc into f3d-app:master Aug 24, 2026
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants