Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,807
    • Issues 3,807
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #23127

Closed
Open
Created Jan 20, 2022 by Gregor Jasny@gjasnyDeveloper

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 Jan 20, 2022 by Gregor Jasny
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking