Can't use libgit2 as a CMake subproject together with googletest
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
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- c, cmake
- Ambito
- build-system
Direzione di ricerca
Riproduci le due configurazioni FetchContent con CMake 3.28.3, quindi esamina cmake/FindStatNsec.cmake e le voci di CMakeConfigureLog.yaml relative al controllo che fallisce. Il lavoro è completato quando libgit2 viene configurato e compilato correttamente aggiungendo prima googletest, senza l’errore errato del controllo -std=c90.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'm using CMake 3.28.3 and GCC 13.3.0 on Ubuntu 24.04 on amd64. I'm trying to use libgit2 1.9.1 as a subproject of my own project.
My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.28.3)
project(myProject VERSION 0.0.1 LANGUAGES C)
include(FetchContent)
FetchContent_Declare(
libgit2
GIT_REPOSITORY https://github.com/libgit2/libgit2.git
GIT_TAG 0060d9cf5666f015b1067129bd874c6cc4c9c7ac # v1.9.1
)
FetchContent_MakeAvailable(libgit2)
add_library(lib)
target_sources(lib PRIVATE lib.c)
target_link_libraries(lib PRIVATE libgit2)
When I run cmake -B build in my project's directory, cmake/FindStatNsec.cmake from libgit2 will call
check_struct_has_member("struct stat" st_mtim "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
CMake will create a C file that references struct stat's st_mtim member variable and compile it with no special compiler flags. On my system, this is successful:
/usr/bin/cc -DHAVE_STRUCT_STAT_ST_MTIM -o CMakeFiles/cmTC_2a383.dir/src.c.o -c /app/build/CMakeFiles/CMakeScratch/TryCompile-3aEPgD/src.c
(taken from build/CMakeFiles/CMakeConfigureLog.yaml)
However when I add googletest before libgit2 like this:
cmake_minimum_required(VERSION 3.28.3)
project(myProject VERSION 0.0.1 LANGUAGES C)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 # v1.17.0
)
FetchContent_MakeAvailable(googletest)
FetchContent_Declare(
libgit2
GIT_REPOSITORY https://github.com/libgit2/libgit2.git
GIT_TAG 0060d9cf5666f015b1067129bd874c6cc4c9c7ac # v1.9.1
)
FetchContent_MakeAvailable(libgit2)
add_library(lib)
target_sources(lib PRIVATE lib.c)
target_link_libraries(lib PRIVATE libgit2)
then the check for st_mtim will fail because the compiler will be called with -std=c90:
/usr/bin/cc -DHAVE_STRUCT_STAT_ST_MTIM -std=c90 -o CMakeFiles/cmTC_99f3b.dir/src.c.o -c /app/build/CMakeFiles/CMakeScratch/TryCompile-df2ogP/src.c
/app/build/CMakeFiles/CMakeScratch/TryCompile-df2ogP/src.c: In function 'main':
/app/build/CMakeFiles/CMakeScratch/TryCompile-df2ogP/src.c:7:36: error: 'struct stat' has no member named 'st_mtim'; did you mean 'st_mtime'?
7 | (void)sizeof(((struct stat *)0)->st_mtim);
| ^~~~~~~
| st_mtime
Building my project with cmake --build build will fail with
[ 1%] Building C object _deps/libgit2-build/src/libgit2/CMakeFiles/libgit2.dir/annotated_commit.c.o
In file included from /app/build/_deps/libgit2-src/src/util/posix.h:157,
from /app/build/_deps/libgit2-src/src/util/git2_util.h:111,
from /app/build/_deps/libgit2-src/src/libgit2/common.h:10,
from /app/build/_deps/libgit2-src/src/libgit2/annotated_commit.h:10,
from /app/build/_deps/libgit2-src/src/libgit2/annotated_commit.c:8:
/app/build/_deps/libgit2-src/src/util/unix/posix.h:35:3: error: #error GIT_USE_NSEC defined but unknown struct stat nanosecond type
35 | # error GIT_USE_NSEC defined but unknown struct stat nanosecond type
| ^~~~~
cc1: note: unrecognized command-line option '-Wno-documentation-deprecated-sync' may have been intended to silence earlier diagnostics
gmake[2]: *** [_deps/libgit2-build/src/libgit2/CMakeFiles/libgit2.dir/build.make:76: _deps/libgit2-build/src/libgit2/CMakeFiles/libgit2.dir/annotated_commit.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:642: _deps/libgit2-build/src/libgit2/CMakeFiles/libgit2.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
I haven't looked further into this yet. It might as well be a googletest bug and not a libgit2 bug.
- Lingua principale
- C
- Stelle
- 10.6k
- Fork
- 2.7k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di libgit2/libgit2
-
hashsig: the similarity heap evicts but never inserts, so the retained set is not the extremes Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Tutte le issue di libgit2/libgit2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NVIDIA/k8s-device-plugin#2061 · 1 commento ·
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vsanthanam/JBird#429 ·