diff options
author | Friedrich W. H. Kossebau <kossebau@kde.org> | 2019-11-28 13:48:45 +0100 |
---|---|---|
committer | Friedrich W. H. Kossebau <kossebau@kde.org> | 2019-12-02 00:04:38 +0100 |
commit | 23d868a0771224c844513ab16ae423e5302d139b (patch) | |
tree | f9ca6671cd0b7283c42a63b4abc721dfb43f8313 /modules | |
parent | bfdcec82d926416ac2eb3657b903414b52f72e31 (diff) | |
download | extra-cmake-modules-23d868a0771224c844513ab16ae423e5302d139b.tar.gz extra-cmake-modules-23d868a0771224c844513ab16ae423e5302d139b.tar.bz2 |
ECMGenerateExportHeader: add NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE flag
Summary:
The original intention has been that by default during the build of a
library no warnings should be emitted on using own deprecated API,
as for one that has to be implemented as well as often deprecated API
is implemented using other deprecated API, so the warnings are not
helpful, and having to add lots of push/pop warnings instructions
in the code for the compiler harms readability more than it helps
ensuring to only use deprecated API where one has to.
The original intention was satisfied due to the default mechanism in the
generated export header code, where DEPRECATED_WARNINGS_SINCE if not set
defaults to DISABLE_DEPRECATED_BEFORE_AND_AT. That though breaks once
the group version of DEPRECATED_WARNINGS_SINCE is set in the build, as
this default has higher priority by design, even if the usage here only
wants to target dependency libs of the same group, not the current library.
To restore the intented default behaviour, by default
DEPRECATED_WARNINGS_SINCE is now explicitely set for the library build
itself to the EXCLUDE_DEPRECATED_BEFORE_AND_AT value, and a new macro
option allows to disable this.
Reviewers: #build_system, #frameworks, dfaure
Reviewed By: dfaure
Subscribers: kde-frameworks-devel, kde-buildsystem
Tags: #frameworks, #build_system
Differential Revision: https://phabricator.kde.org/D25589
Diffstat (limited to 'modules')
-rw-r--r-- | modules/ECMGenerateExportHeader.cmake | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/modules/ECMGenerateExportHeader.cmake b/modules/ECMGenerateExportHeader.cmake index 81bf33e3..7de9aa69 100644 --- a/modules/ECMGenerateExportHeader.cmake +++ b/modules/ECMGenerateExportHeader.cmake @@ -27,6 +27,7 @@ # [DEPRECATED_BASE_VERSION <deprecated_base_version>] # [DEPRECATION_VERSIONS <deprecation_version> [<deprecation_version2> [...]]] # [EXCLUDE_DEPRECATED_BEFORE_AND_AT <exclude_deprecated_before_and_at_version>] +# [NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE] # [NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE] # [CUSTOM_CONTENT_FROM_VARIABLE <variable>] # ) @@ -57,12 +58,25 @@ # Possible values are "0" (default), "CURRENT" (which resolves to <version>) # and a version string in the format "<major>.<minor>.<patchlevel>". # +# ``NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE`` specifies that the definition +# ``<prefix_name><uppercase_base_name>_DEPRECATED_WARNINGS_SINCE`` will +# not be set for the library inside its own build, and thus will be defined +# by either explicit definition in the build system configuration or by the +# default value mechanism (see below). +# The default is that it is set for the build, to the version specified by +# ``EXCLUDE_DEPRECATED_BEFORE_AND_AT``, so no deprecation warnings are +# done for any own deprecated API used in the library implementation itself. +# # ``NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE`` specifies that the definition # ``<prefix_name><uppercase_base_name>_DISABLE_DEPRECATED_BEFORE_AND_AT`` will -# not be set in the public interface of the library inside its own build. -# The default is that it is set, to the version specified by +# not be set in the public interface of the library inside its own build, and +# the same for the definition +# ``<prefix_name><uppercase_base_name>_DEPRECATED_WARNINGS_SINCE`` (if not +# disabled by ``NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE`` already). +# The default is that they are set, to the version specified by # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT``, so e.g. test and examples part of the -# project automatically build against the full API included in the build. +# project automatically build against the full API included in the build and +# without any deprecation warnings for it. # # # The function ``ecm_generate_export_header`` defines C++ preprocessor macros @@ -411,6 +425,7 @@ endfunction() function(ecm_generate_export_header target) set(options NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE + NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE ) set(oneValueArgs BASE_NAME @@ -501,10 +516,17 @@ function(ecm_generate_export_header target) set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${ARGS_EXPORT_FILE_NAME}") # build with all the API not excluded, ensure all deprecated API is visible in the build itselt _ecm_geh_generate_hex_number(_hexnumber ${ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT}) - set(_disabling_definition "${_macro_base_name}_DISABLE_DEPRECATED_BEFORE_AND_AT=${_hexnumber}") - target_compile_definitions(${target} PRIVATE "${_disabling_definition}") + set(_disabling_visibility_definition "${_macro_base_name}_DISABLE_DEPRECATED_BEFORE_AND_AT=${_hexnumber}") + target_compile_definitions(${target} PRIVATE "${_disabling_visibility_definition}") if (NOT ARGS_NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE) - target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_disabling_definition}>") + target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_disabling_visibility_definition}>") + endif() + if(NOT ARGS_NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE) + set(_enabling_warnings_definition "${_macro_base_name}_DEPRECATED_WARNINGS_SINCE=${_hexnumber}") + target_compile_definitions(${target} PRIVATE "${_enabling_warnings_definition}") + if (NOT ARGS_NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE) + target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_enabling_warnings_definition}>") + endif() endif() # for the set of compiler versions supported by ECM/KF we can assume those attributes supported |