Skip to content

cmake: make the repo consumable via add_subdirectory / FetchContent#146

Merged
UnsignedChad merged 1 commit into
mainfrom
cmake/install-export
Jun 9, 2026
Merged

cmake: make the repo consumable via add_subdirectory / FetchContent#146
UnsignedChad merged 1 commit into
mainfrom
cmake/install-export

Conversation

@UnsignedChad

Copy link
Copy Markdown
Owner

groundwork for the kicad plugin repos (pdnkit-kicad etc): they pin circuitcore via FetchContent/submodule instead of copying code, which means this repo has to work as an embedded subproject. it did not -- six CMAKE_SOURCE_DIR uses resolved into the parent project, the GUI/CLI11/tests/VTK were unconditional, and CMAKE_BUILD_TYPE got FORCE-cached into the parents cache.

changes:

  • ${CMAKE_SOURCE_DIR} -> ${circuitcore_SOURCE_DIR} in the 6 places it leaked: third_party includes on circuitcore_ui / pdnkit_pi / sikit_si, the repo-root PUBLIC include on pdnkit_widgets / sikit_widgets, and the two vtk patch-script include()s in mpkit/widgets (those were a fatal configure error under embedding).
  • new option CIRCUITCORE_BUILD_APPS gating pdnkit/sikit/emikit/studio exes + the CLI11 find_package. APPS, TESTS and MPKIT_WIDGETS all default to ON when top-level, OFF when embedded. standalone builds see zero change.
  • CMAKE_BUILD_TYPE only force-defaulted to Release when we own the build.
  • engine aliases so consumers get namespaced targets: pdnkit::pi, sikit::si, emikit::emi (widgets already had them).
  • remaining bare PUBLIC include dirs wrapped in $<BUILD_INTERFACE:> (field, emikit, mpkit, both kits) -- keeps install(EXPORT) on the table later without behavior change now.
  • tests/consumer/: standalone smoke project that embeds the repo, links circuitcore::kicad + pdnkit::widgets + emikit::emi, exercises all three include styles (circuitcore/..., bare pi/..., repo-root pdnkit/...), parses tiny_pdn and checks target-z. new ci step runs it and asserts the apps/tests targets did not get built.

deliberately NOT in scope: install()/export()/find_package support. the kits bare header layout (pdnkit/render/ vs sikit/render/) collides under a shared install prefix; FetchContent consumption doesnt need it and the plugin repos dont either. that can come later if the headers ever get namespaced.

verified on the box: embedded consumer configures in 0.4s with no CLI11/Catch2/VTK, 129 lib targets, smoke binary runs green, apps+tests confirmed absent. full top-level build + suite also green (see ci).

the kicad plugin repos will pin circuitcore as a dependency instead of
copying code, so the build has to behave as a guest:

- CMAKE_SOURCE_DIR leaked the parent projects root in 6 places
  (third_party includes on ui/pdnkit_pi/sikit_si, the repo-root include
  on both widgets libs, the vtk patch script includes in mpkit/widgets).
  all now use circuitcore_SOURCE_DIR.
- new CIRCUITCORE_BUILD_APPS option gates the four executables + CLI11.
  apps, tests and mpkit widgets (vtk) default OFF when circuitcore is
  not the top-level project, ON as before when it is.
- stop FORCE-caching CMAKE_BUILD_TYPE when embedded.
- aliases for the engines: pdnkit::pi, sikit::si, emikit::emi.
- bare PUBLIC include dirs wrapped in BUILD_INTERFACE (field, emikit,
  mpkit, kits) so install(EXPORT) stays possible later.
- tests/consumer: standalone project that add_subdirectory()s the repo,
  links circuitcore::kicad + pdnkit::widgets + emikit::emi, parses the
  tiny_pdn fixture and checks a target-z number. wired into ci after
  the test step, including asserts that apps/tests stayed off.
- readme: short section on consuming the repo + target list.

no source changes, no behavior change for the standalone build.
@UnsignedChad UnsignedChad enabled auto-merge (squash) June 9, 2026 22:34
@UnsignedChad UnsignedChad merged commit 3062bb0 into main Jun 9, 2026
1 check passed
@UnsignedChad UnsignedChad deleted the cmake/install-export branch June 9, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant