File tree Expand file tree Collapse file tree 10 files changed +35
-17
lines changed
Expand file tree Collapse file tree 10 files changed +35
-17
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ endif()
9090
9191# Modules
9292
93+ include (FeatureSummary)
94+ include (SetCStandard)
9395include (CheckLibraryExists)
9496include (CheckFunctionExists)
9597include (CheckSymbolExists)
@@ -102,7 +104,6 @@ include(FindStatNsec)
102104include (Findfutimens)
103105include (GNUInstallDirs)
104106include (IdeSplitSources)
105- include (FeatureSummary)
106107include (EnableWarnings)
107108include (DefaultCFlags)
108109include (ExperimentalFeatures)
Original file line number Diff line number Diff line change 1+ if ("${C_STANDARD} " STREQUAL "" )
2+ set (C_STANDARD "90" )
3+ endif ()
4+ if ("${C_EXTENSIONS} " STREQUAL "" )
5+ set (C_EXTENSIONS OFF )
6+ endif ()
7+
8+ if (${C_STANDARD} MATCHES "^[Cc].*" )
9+ string (REGEX REPLACE "^[Cc]" "" C_STANDARD ${C_STANDARD} )
10+ endif ()
11+
12+ if (${C_STANDARD} MATCHES ".*-strict$" )
13+ string (REGEX REPLACE "-strict$" "" C_STANDARD ${C_STANDARD} )
14+ set (C_EXTENSIONS OFF )
15+
16+ add_feature_info("C Standard" ON "C${C_STANDARD} (strict)" )
17+ else ()
18+ add_feature_info("C Standard" ON "C${C_STANDARD} " )
19+ endif ()
20+
21+ function (set_c_standard project)
22+ set_target_properties (${project} PROPERTIES C_STANDARD ${C_STANDARD} )
23+ set_target_properties (${project} PROPERTIES C_EXTENSIONS ${C_EXTENSIONS} )
24+ endfunction ()
Original file line number Diff line number Diff line change 33file (GLOB SRC_EXAMPLES *.c *.h)
44
55add_executable (lg2 ${SRC_EXAMPLES} )
6- set_target_properties (lg2 PROPERTIES C_STANDARD 90)
7- set_target_properties (lg2 PROPERTIES C_EXTENSIONS OFF )
6+ set_c_standard(lg2)
87
98# Ensure that we do not use deprecated functions internally
109add_definitions (-DGIT_DEPRECATE_HARD)
Original file line number Diff line number Diff line change @@ -20,8 +20,7 @@ foreach(fuzz_target_src ${SRC_FUZZERS})
2020 endif ()
2121
2222 add_executable (${fuzz_target_name} ${${fuzz_target_name} _SOURCES})
23- set_target_properties (${fuzz_target_name} PROPERTIES C_STANDARD 90)
24- set_target_properties (${fuzz_target_name} PROPERTIES C_EXTENSIONS OFF )
23+ set_c_standard(${fuzz_target_name} )
2524 target_include_directories (${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} )
2625 target_include_directories (${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES} )
2726
Original file line number Diff line number Diff line change @@ -40,8 +40,7 @@ add_executable(git2_cli ${CLI_SRC_C} ${CLI_SRC_OS} ${CLI_OBJECTS}
4040 ${LIBGIT2_DEPENDENCY_OBJECTS} )
4141target_link_libraries (git2_cli ${CLI_LIBGIT2_LIBRARY} ${LIBGIT2_SYSTEM_LIBS} )
4242
43- set_target_properties (git2_cli PROPERTIES C_STANDARD 90)
44- set_target_properties (git2_cli PROPERTIES C_EXTENSIONS OFF )
43+ set_c_standard(git2_cli)
4544set_target_properties (git2_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR} )
4645set_target_properties (git2_cli PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME} )
4746
Original file line number Diff line number Diff line change 22# git library functionality.
33
44add_library (libgit2 OBJECT)
5- set_target_properties (libgit2 PROPERTIES C_STANDARD 90)
6- set_target_properties (libgit2 PROPERTIES C_EXTENSIONS OFF )
5+ set_c_standard(libgit2)
76
87include (PkgBuildConfig)
98
Original file line number Diff line number Diff line change 11# util: a shared library for common utility functions for libgit2 projects
22
33add_library (util OBJECT)
4- set_target_properties (util PROPERTIES C_STANDARD 90)
5- set_target_properties (util PROPERTIES C_EXTENSIONS OFF )
4+ set_c_standard(util)
65
76configure_file (git2_features.h.in git2_features.h)
87
Original file line number Diff line number Diff line change 33# even when they have aggressive C90 warnings enabled.
44
55add_executable (headertest headertest.c)
6- set_target_properties (headertest PROPERTIES C_STANDARD 90 )
7- set_target_properties (headertest PROPERTIES C_EXTENSIONS OFF )
6+ set_c_standard (headertest)
7+
88target_include_directories (headertest PRIVATE ${LIBGIT2_INCLUDES} )
99
1010if (MSVC )
Original file line number Diff line number Diff line change @@ -39,9 +39,8 @@ set_source_files_properties(
3939 PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /clar.suite)
4040
4141add_executable (libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS} )
42+ set_c_standard(libgit2_tests)
4243
43- set_target_properties (libgit2_tests PROPERTIES C_STANDARD 90)
44- set_target_properties (libgit2_tests PROPERTIES C_EXTENSIONS OFF )
4544set_target_properties (libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
4645target_include_directories (libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} )
4746target_include_directories (libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES} )
Original file line number Diff line number Diff line change @@ -38,9 +38,8 @@ set_source_files_properties(
3838 PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /clar.suite)
3939
4040add_executable (util_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS} )
41+ set_c_standard(util_tests)
4142
42- set_target_properties (util_tests PROPERTIES C_STANDARD 90)
43- set_target_properties (util_tests PROPERTIES C_EXTENSIONS OFF )
4443set_target_properties (util_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR} )
4544
4645target_include_directories (util_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} )
You can’t perform that action at this time.
0 commit comments