Skip to content

Commit

Permalink
Work around -Werror problems when detecting qsort variants
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DimitryAndric committed May 9, 2023
1 parent 251408c commit 3d9cb5e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -58,6 +58,13 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")

# qsort

# for these tests, temporarily save CMAKE_C_FLAGS and disable warnings about
# unused functions and parameters, otherwise they will always fail if
# ENABLE_WERROR is on
set(SAVED_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
disable_warnings(unused-function)
disable_warnings(unused-parameter)

# old-style FreeBSD qsort_r() has the 'context' parameter as the first argument
# of the comparison function:
check_prototype_definition(qsort_r
Expand All @@ -82,6 +89,9 @@ check_prototype_definition(qsort_s
"void (qsort_s)(void *base, size_t num, size_t width, int (*compare )(void *, const void *, const void *), void *context)"
"" "stdlib.h" GIT_QSORT_S_MSC)

# restore CMAKE_C_FLAGS
set(CMAKE_C_FLAGS "${SAVED_CMAKE_C_FLAGS}")

# random / entropy data

check_function_exists(getentropy GIT_RAND_GETENTROPY)
Expand Down

0 comments on commit 3d9cb5e

Please sign in to comment.