Skip to content

Commit 3d9cb5e

Browse files
committed
Work around -Werror problems when detecting qsort variants
If `ENABLE_WERROR` is on, the CMake configure tests for the `qsort_r` and `qsort_s` variants may fail due to warnings about unused functions or unused parameters. These warnings can be ignored, so disable them specifically for running those tests.
1 parent 251408c commit 3d9cb5e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
5858

5959
# qsort
6060

61+
# for these tests, temporarily save CMAKE_C_FLAGS and disable warnings about
62+
# unused functions and parameters, otherwise they will always fail if
63+
# ENABLE_WERROR is on
64+
set(SAVED_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
65+
disable_warnings(unused-function)
66+
disable_warnings(unused-parameter)
67+
6168
# old-style FreeBSD qsort_r() has the 'context' parameter as the first argument
6269
# of the comparison function:
6370
check_prototype_definition(qsort_r
@@ -82,6 +89,9 @@ check_prototype_definition(qsort_s
8289
"void (qsort_s)(void *base, size_t num, size_t width, int (*compare )(void *, const void *, const void *), void *context)"
8390
"" "stdlib.h" GIT_QSORT_S_MSC)
8491

92+
# restore CMAKE_C_FLAGS
93+
set(CMAKE_C_FLAGS "${SAVED_CMAKE_C_FLAGS}")
94+
8595
# random / entropy data
8696

8797
check_function_exists(getentropy GIT_RAND_GETENTROPY)

0 commit comments

Comments
 (0)