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

Aperta
#25 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cmake, python
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
4
Fork
1
Merge medio
10h 41m
PR unite (30g)
79

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cpp-best-practices/project_validator

Tutte le issue di cpp-best-practices/project_validator

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.