mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
Merge pull request #6914 from libgit2/ethomson/cmake
cmake-standard c standards
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -132,7 +132,7 @@ jobs:
|
||||
env:
|
||||
CC: clang
|
||||
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
|
||||
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
|
||||
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
|
||||
CMAKE_GENERATOR: Ninja
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
|
||||
@@ -53,6 +53,13 @@ option(SONAME "Set the (SO)VERSION of the target"
|
||||
option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
|
||||
|
||||
# Compilation options
|
||||
# Default to c99 on Android Studio for compatibility; c90 everywhere else
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
|
||||
set(CMAKE_C_STANDARD "99" CACHE STRING "The C standard to compile against")
|
||||
else()
|
||||
set(CMAKE_C_STANDARD "90" CACHE STRING "The C standard to compile against")
|
||||
endif()
|
||||
option(CMAKE_C_EXTENSIONS "Whether compiler extensions are supported" OFF)
|
||||
option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
|
||||
if(UNIX)
|
||||
@@ -91,7 +98,6 @@ endif()
|
||||
# Modules
|
||||
|
||||
include(FeatureSummary)
|
||||
include(SetCStandard)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
@@ -378,8 +378,8 @@ linker. These flags may be useful for cross-compilation or specialized
|
||||
setups.
|
||||
|
||||
- `CMAKE_C_FLAGS`: Set your own compiler flags
|
||||
- `C_STANDARD`: the C standard to compile against; defaults to `C90`
|
||||
- `C_EXTENSIONS`: whether compiler extensions are supported; defaults to `OFF`
|
||||
- `CMAKE_C_STANDARD`: the C standard to compile against; defaults to `C90`
|
||||
- `CMAKE_C_EXTENSIONS`: whether compiler extensions are supported; defaults to `OFF`
|
||||
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
|
||||
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
|
||||
Tell CMake where to find those specific libraries
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
if("${C_STANDARD}" STREQUAL "")
|
||||
set(C_STANDARD "90")
|
||||
endif()
|
||||
if("${C_EXTENSIONS}" STREQUAL "")
|
||||
set(C_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
if(${C_STANDARD} MATCHES "^[Cc].*")
|
||||
string(REGEX REPLACE "^[Cc]" "" C_STANDARD ${C_STANDARD})
|
||||
endif()
|
||||
|
||||
if(${C_STANDARD} MATCHES ".*-strict$")
|
||||
string(REGEX REPLACE "-strict$" "" C_STANDARD ${C_STANDARD})
|
||||
set(C_EXTENSIONS OFF)
|
||||
|
||||
add_feature_info("C Standard" ON "C${C_STANDARD} (strict)")
|
||||
else()
|
||||
add_feature_info("C Standard" ON "C${C_STANDARD}")
|
||||
endif()
|
||||
|
||||
function(set_c_standard project)
|
||||
set_target_properties(${project} PROPERTIES C_STANDARD ${C_STANDARD})
|
||||
set_target_properties(${project} PROPERTIES C_EXTENSIONS ${C_EXTENSIONS})
|
||||
endfunction()
|
||||
2
deps/llhttp/api.c
vendored
2
deps/llhttp/api.c
vendored
@@ -93,7 +93,7 @@ void llhttp_free(llhttp_t* parser) {
|
||||
free(parser);
|
||||
}
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
#endif /* defined(__wasm__) */
|
||||
|
||||
/* Some getters required to get stuff from the parser */
|
||||
|
||||
|
||||
1
deps/ntlmclient/CMakeLists.txt
vendored
1
deps/ntlmclient/CMakeLists.txt
vendored
@@ -37,4 +37,3 @@ else()
|
||||
endif()
|
||||
|
||||
add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
|
||||
set_target_properties(ntlmclient PROPERTIES C_STANDARD 90)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
file(GLOB SRC_EXAMPLES *.c *.h)
|
||||
|
||||
add_executable(lg2 ${SRC_EXAMPLES})
|
||||
set_c_standard(lg2)
|
||||
|
||||
# Ensure that we do not use deprecated functions internally
|
||||
add_definitions(-DGIT_DEPRECATE_HARD)
|
||||
|
||||
@@ -20,7 +20,6 @@ foreach(fuzz_target_src ${SRC_FUZZERS})
|
||||
endif()
|
||||
|
||||
add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
|
||||
set_c_standard(${fuzz_target_name})
|
||||
target_include_directories(${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
|
||||
target_include_directories(${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ add_executable(git2_cli ${CLI_SRC_C} ${CLI_SRC_OS} ${CLI_OBJECTS}
|
||||
${LIBGIT2_DEPENDENCY_OBJECTS})
|
||||
target_link_libraries(git2_cli ${CLI_LIBGIT2_LIBRARY} ${LIBGIT2_SYSTEM_LIBS})
|
||||
|
||||
set_c_standard(git2_cli)
|
||||
set_target_properties(git2_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
|
||||
set_target_properties(git2_cli PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# git library functionality.
|
||||
|
||||
add_library(libgit2 OBJECT)
|
||||
set_c_standard(libgit2)
|
||||
|
||||
include(PkgBuildConfig)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# util: a shared library for common utility functions for libgit2 projects
|
||||
|
||||
add_library(util OBJECT)
|
||||
set_c_standard(util)
|
||||
|
||||
configure_file(git2_features.h.in git2_features.h)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# even when they have aggressive C90 warnings enabled.
|
||||
|
||||
add_executable(headertest headertest.c)
|
||||
set_c_standard(headertest)
|
||||
|
||||
target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES})
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ set_source_files_properties(
|
||||
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
|
||||
|
||||
add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
|
||||
set_c_standard(libgit2_tests)
|
||||
|
||||
set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
|
||||
|
||||
@@ -42,7 +42,6 @@ set_source_files_properties(
|
||||
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
|
||||
|
||||
add_executable(util_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
|
||||
set_c_standard(util_tests)
|
||||
|
||||
set_target_properties(util_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user