Add `top-level-guard` check: the project can be consumed as a subproject

Offen
#25 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
cmake, python
Bereich
tooling

Rechercherichtung

Start by reading the check implementations and tests in the project validator, then compare their conventions with the referenced CMakeLists.txt and ProjectOptions.cmake. Add a warning-level top-level-guard check that recognizes both stated guard idioms and reports when tests or developer-only options lack a guard; done when the check passes and fails as described.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Check

New check top-level-guard.

Passes when tests and developer-only options (warnings as errors, sanitizers, static analysis) are conditioned on PROJECT_IS_TOP_LEVEL (or the older CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR idiom), so the project works with FetchContent / CPM / add_subdirectory.
Fails otherwise. (Warning-level.)

Reference

if(NOT PROJECT_IS_TOP_LEVEL) in CMakeLists.txt and ProjectOptions.cmake.


Part of #9. Reference implementation: cpp-best-practices/cmake_template.


Triage (language-neutral review): still valid for C/C++. Add a Meson rule: tests and developer-only options guarded by meson.is_subproject(). Python and Rust: SKIP. Unblocked: build-system rules exist now (#59); this is a rule on the CMake (and Meson) BuildSystem.

Vorherrschende Sprache
Python
Sterne
4
Forks
1
Ø Merge
10 Std. 41 Min.
Gemergte PRs (30 T.)
79

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus cpp-best-practices/project_validator

Alle Issues in cpp-best-practices/project_validator

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.