8000 Merge pull request #6914 from libgit2/ethomson/cmake · libgit2/libgit2@cd9f463 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd9f463

Browse files
authored
Merge pull request #6914 from libgit2/ethomson/cmake
cmake-standard c standards
2 parents 0455346 + 0013a6f commit cd9f463

File tree

14 files changed

+11
-38
lines changed

14 files changed

+11
-38
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
env:
133133
CC: clang
134134
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
135-
CMAKE_OPTIONS: -DC_EXTENSIONS=ON -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
135+
CMAKE_OPTIONS: -DCMAKE_C_EXTENSIONS=ON -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
136136
CMAKE_GENERATOR: Ninja
137137
SKIP_SSH_TESTS: true
138138
SKIP_NEGOTIATE_TESTS: true

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ option(SONAME "Set the (SO)VERSION of the target"
5353
option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
5454

5555
# Compilation options
56+
# Default to c99 on Android Studio for compatibility; c90 everywhere else
57+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
58+
set(CMAKE_C_STANDARD "99" CACHE STRING "The C standard to compile against")
59+
else()
60+
set(CMAKE_C_STANDARD "90" CACHE STRING "The C standard to compile against")
61+
endif()
62+
option(CMAKE_C_EXTENSIONS "Whether compiler extensions are supported" OFF)
5663
option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
5764

5865
if(UNIX)
@@ -91,7 +98,6 @@ endif()
9198
# Modules
9299

93100
include(FeatureSummary)
94-
include(SetCStandard)
95101
include(CheckLibraryExists)
96102
include(CheckFunctionExists)
97103
include(CheckSymbolExists)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ linker. These flags may be useful for cross-compilation or specialized
378378
setups.
379379

380380
- `CMAKE_C_FLAGS`: Set your own compiler flags
381-
- `C_STANDARD`: the C standard to compile against; defaults to `C90`
382-
- `C_EXTENSIONS`: whether compiler extensions are supported; defaults to `OFF`
381+
- `CMAKE_C_STANDARD`: the C standard to compile against; defaults to `C90`
382+
- `CMAKE_C_EXTENSIONS`: whether compiler extensions are supported; defaults to `OFF`
383383
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
384384
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
385385
Tell CMake where to find those specific libraries

cmake/SetCStandard.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

deps/llhttp/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void llhttp_free(llhttp_t* parser) {
9393
free(parser);
9494
}
9595

96-
#endif // defined(__wasm__)
96+
#endif /* defined(__wasm__)< 67F4 span class="x x-first x-last"> */
9797

9898
/* Some getters required to get stuff from the parser */
9999

deps/ntlmclient/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ else()
3737
endif()
3838

3939
add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
40-
set_target_properties(ntlmclient PROPERTIES C_STANDARD 90)

examples/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
file(GLOB SRC_EXAMPLES *.c *.h)
44

55
add_executable(lg2 ${SRC_EXAMPLES})
6-
set_c_standard(lg2)
76

87
# Ensure that we do not use deprecated functions internally
98
add_definitions(-DGIT_DEPRECATE_HARD)

fuzzers/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ foreach(fuzz_target_src ${SRC_FUZZERS})
2020
endif()
2121

2222
add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
23-
set_c_standard(${fuzz_target_name})
2423
target_include_directories(${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
2524
target_include_directories(${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
2625

src/cli/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ add_executable(git2_cli ${CLI_SRC_C} ${CLI_SRC_OS} ${CLI_OBJECTS}
4040
${LIBGIT2_DEPENDENCY_OBJECTS})
4141
target_link_libraries(git2_cli ${CLI_LIBGIT2_LIBRARY} ${LIBGIT2_SYSTEM_LIBS})
4242

43-
set_c_standard(git2_cli)
4443
set_target_properties(git2_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
4544
set_target_properties(git2_cli PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
4645

src/libgit2/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# git library functionality.
33

44
add_library(libgit2 OBJECT)
5-
set_c_standard(libgit2)
65

76
include(PkgBuildConfig)
87

0 commit comments

Comments
 (0)
0