GenerateExportHeader: Should ignore -Werror
The following testcase:
cmake_minimum_required(VERSION 3.22)
project(testcase LANGUAGES CXX)
string(APPEND CMAKE_CXX_FLAGS " -Werror")
add_library(testcase testcase.cpp)
include(GenerateExportHeader)
generate_export_header(testcase)
results in false-negative check for deprecation attributes:
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
-- Performing Test COMPILER_HAS_DEPRECATED
-- Performing Test COMPILER_HAS_DEPRECATED - Failed
The reason is that the -Werror
flags gets propagated into the test and the provoked deprecation warning is turned into an error:
/Users/gregorj/src/cmake-deprecated-attr/_build/CMakeFiles/CMakeTmp/src.cxx:2:25: error: 'somefunc' is deprecated [-Werror,-Wdeprecated-declarations]
int main() { return somefunc();}
^
I'm wondering if the attribute check really needs to invoke the deprecated function or if the successful parsing of the deprecation attribute would be sufficient (see)
Another option would be to filter -Werror
like CheckSymbolExists
does.
Edited by Gregor Jasny