Library Targets Include Directories Broken

Aperta
#1,016 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cmake, cpp
Ambito
build-system

Direzione di ricerca

Inizia in cmake/draco_targets.cmake, nella definizione di draco_add_library e nelle chiamate a target_include_directories intorno alle righe 226, 319 e 323. Esamina come viene generato draco/draco_features.h e come vengono utilizzati i target come sottoprogetti o librerie installate. Il lavoro è completato quando i percorsi di inclusione funzionano correttamente sia in fase di compilazione sia in fase di installazione e le macro delle funzionalità sono disponibili per gli utenti della libreria.

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

Descrizione

bug cmake

Hi folks, when using the draco library as a subproject, or with CMake's FetchContent/ExternalProject machinery, the draco includes are broken. This stems from the definition of the draco_add_library macro. Specifically, on line 226, the library target has the INSTALL_INTERFACE set at the include directory of the install folder. This works as intended. However, the BUILD_INTERFACE is not set at any point. Instead on lines 319 and 323 target_include_directories is called again to provide private and public directories, those these are not restricted to build time.

Now, my CMake experience does not include using macro wrappers around the typical target oriented machinery. Instead I am used to the modern CMake style of generator expressions. I worry that producing a large pull request reworking the CMake would not be accepted as it would be difficult to review.

So here is how I would address the issue: All of the library targets use the same build and install include directories. I would replace the referenced lines by the singular block:

target_include_directories(${lib_NAME} PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src/>
    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
)

Now this doesn't address the generated draco/draco_features.h header, at least at build time. This CMake generated header defines a set of macros describing which features are supported. Instead this should be handled using the target_compile_definitions machinery. By setting these values publicly on the targets, both consumers of the installed library and the build time library will have those macros defined. The header can still be generated for backwards compatibility purposes as well.

Lingua principale
C++
Stelle
7.5k
Fork
1.1k
Merge medio
23h 57m
PR unite (30g)
3

Preparare l'ambiente

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 google/draco

Tutte le issue di google/draco

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.