diff options
| author | Timo Röhling <roehling@debian.org> | 2021-10-22 15:47:14 +0200 |
|---|---|---|
| committer | Timo Röhling <roehling@debian.org> | 2021-10-22 15:48:51 +0200 |
| commit | 1ab7c3cd28b27ca162c4559e1026e5cad1898ade (patch) | |
| tree | 47eea29a594e89ed481780d320cb8b1483d1e377 /Tests/CMakeOnly | |
| parent | ca3e83250f43285fa3c9a0f5e062a3fd94a097e0 (diff) | |
| download | cmake-1ab7c3cd28b27ca162c4559e1026e5cad1898ade.tar.gz | |
CheckSymbolExists: Work around GCC failure with -pedantic-errors option
GCC mistakenly issues the pedantic warning "ISO C forbids conversion of
function pointer to object pointer type". With -pedantic-errors in the
compile flags, that diagnostic prevents check_symbol_exists() from
detecting function symbols.
The solution is to filter out -pedantic-errors (and -Werror, just to be
future proof) before invoking try_compile().
Fixes: #13208
Diffstat (limited to 'Tests/CMakeOnly')
| -rw-r--r-- | Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt index 9a9bb2a395..3d65b7ab18 100644 --- a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt @@ -48,4 +48,15 @@ if (CMAKE_COMPILER_IS_GNUCC) if (CSE_RESULT_O3) message(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing with optimization -O3") endif () + + string(APPEND CMAKE_C_FLAGS " -pedantic-errors") + unset(CS_RESULT_PEDANTIC_ERRORS CACHE) + message(STATUS "Testing with -pedantic-errors") + + check_symbol_exists(fopen "stdio.h" CSE_RESULT_PEDANTIC_ERRORS) + + if(NOT CSE_RESULT_PEDANTIC_ERRORS) + message(SEND_ERROR "CheckSymbolExists reported an existing symbol as nonexisting with -pedantic-errors") + endif() + endif () |
