Changeset View
Changeset View
Standalone View
Standalone View
modules/ECMGenerateExportHeader.cmake
Show All 21 Lines | |||||
22 | # [DEPRECATED_MACRO_NAME <deprecated_macro_name>] | 22 | # [DEPRECATED_MACRO_NAME <deprecated_macro_name>] | ||
23 | # [NO_EXPORT_MACRO_NAME <no_export_macro_name>] | 23 | # [NO_EXPORT_MACRO_NAME <no_export_macro_name>] | ||
24 | # [INCLUDE_GUARD_NAME <include_guard_name>] | 24 | # [INCLUDE_GUARD_NAME <include_guard_name>] | ||
25 | # [STATIC_DEFINE <static_define>] | 25 | # [STATIC_DEFINE <static_define>] | ||
26 | # [PREFIX_NAME <prefix_name>] | 26 | # [PREFIX_NAME <prefix_name>] | ||
27 | # [DEPRECATED_BASE_VERSION <deprecated_base_version>] | 27 | # [DEPRECATED_BASE_VERSION <deprecated_base_version>] | ||
28 | # [DEPRECATION_VERSIONS <deprecation_version> [<deprecation_version2> [...]]] | 28 | # [DEPRECATION_VERSIONS <deprecation_version> [<deprecation_version2> [...]]] | ||
29 | # [EXCLUDE_DEPRECATED_BEFORE_AND_AT <exclude_deprecated_before_and_at_version>] | 29 | # [EXCLUDE_DEPRECATED_BEFORE_AND_AT <exclude_deprecated_before_and_at_version>] | ||
30 | # [NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE] | ||||
30 | # [NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE] | 31 | # [NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE] | ||
31 | # [CUSTOM_CONTENT_FROM_VARIABLE <variable>] | 32 | # [CUSTOM_CONTENT_FROM_VARIABLE <variable>] | ||
32 | # ) | 33 | # ) | ||
33 | # | 34 | # | ||
34 | # ``VERSION`` specifies the version of the library, given in the format | 35 | # ``VERSION`` specifies the version of the library, given in the format | ||
35 | # "<major>.<minor>.<patchlevel>". | 36 | # "<major>.<minor>.<patchlevel>". | ||
36 | # | 37 | # | ||
37 | # ``GROUP_BASE_NAME`` specifies the name to use for the macros defining | 38 | # ``GROUP_BASE_NAME`` specifies the name to use for the macros defining | ||
Show All 14 Lines | |||||
52 | # macro ``<prefix_name><base_name>_DEPRECATED_VERSION(major, minor, text)`` | 53 | # macro ``<prefix_name><base_name>_DEPRECATED_VERSION(major, minor, text)`` | ||
53 | # needs to be listed here, otherwise the macro will fail to work. | 54 | # needs to be listed here, otherwise the macro will fail to work. | ||
54 | # | 55 | # | ||
55 | # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT`` specifies the version for which all API | 56 | # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT`` specifies the version for which all API | ||
56 | # deprecated before and at should be excluded from the build completely. | 57 | # deprecated before and at should be excluded from the build completely. | ||
57 | # Possible values are "0" (default), "CURRENT" (which resolves to <version>) | 58 | # Possible values are "0" (default), "CURRENT" (which resolves to <version>) | ||
58 | # and a version string in the format "<major>.<minor>.<patchlevel>". | 59 | # and a version string in the format "<major>.<minor>.<patchlevel>". | ||
59 | # | 60 | # | ||
61 | # ``NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE`` specifies that the definition | ||||
62 | # ``<prefix_name><uppercase_base_name>_DEPRECATED_WARNINGS_SINCE`` will | ||||
63 | # not be set for the library inside its own build, and thus will be defined | ||||
64 | # by either explicit definition in the build system configuration or by the | ||||
65 | # default value mechanism (see below). | ||||
66 | # The default is that it is set for the build, to the version specified by | ||||
67 | # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT``, so no deprecation warnings are | ||||
68 | # done for any own deprecated API used in the library implementation itself. | ||||
69 | # | ||||
60 | # ``NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE`` specifies that the definition | 70 | # ``NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE`` specifies that the definition | ||
61 | # ``<prefix_name><uppercase_base_name>_DISABLE_DEPRECATED_BEFORE_AND_AT`` will | 71 | # ``<prefix_name><uppercase_base_name>_DISABLE_DEPRECATED_BEFORE_AND_AT`` will | ||
62 | # not be set in the public interface of the library inside its own build. | 72 | # not be set in the public interface of the library inside its own build, and | ||
63 | # The default is that it is set, to the version specified by | 73 | # the same for the definition | ||
74 | # ``<prefix_name><uppercase_base_name>_DEPRECATED_WARNINGS_SINCE`` (if not | ||||
75 | # disabled by ``NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE`` already). | ||||
76 | # The default is that they are set, to the version specified by | ||||
64 | # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT``, so e.g. test and examples part of the | 77 | # ``EXCLUDE_DEPRECATED_BEFORE_AND_AT``, so e.g. test and examples part of the | ||
65 | # project automatically build against the full API included in the build. | 78 | # project automatically build against the full API included in the build and | ||
79 | # without any deprecation warnings for it. | ||||
66 | # | 80 | # | ||
67 | # | 81 | # | ||
68 | # The function ``ecm_generate_export_header`` defines C++ preprocessor macros | 82 | # The function ``ecm_generate_export_header`` defines C++ preprocessor macros | ||
69 | # in the generated export header, some for use in the sources of the library | 83 | # in the generated export header, some for use in the sources of the library | ||
70 | # the header is generated for, other for use by projects linking agsinst the | 84 | # the header is generated for, other for use by projects linking agsinst the | ||
71 | # library. | 85 | # library. | ||
72 | # | 86 | # | ||
73 | # The macros for use in the library C++ sources are these, next to those also | 87 | # The macros for use in the library C++ sources are these, next to those also | ||
▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Line(s) | 415 | if (ARGS_HEXNUMBER_VAR) | |||
406 | set(${ARGS_HEXNUMBER_VAR} ${_hexnumber} PARENT_SCOPE) | 420 | set(${ARGS_HEXNUMBER_VAR} ${_hexnumber} PARENT_SCOPE) | ||
407 | endif() | 421 | endif() | ||
408 | endfunction() | 422 | endfunction() | ||
409 | 423 | | |||
410 | 424 | | |||
411 | function(ecm_generate_export_header target) | 425 | function(ecm_generate_export_header target) | ||
412 | set(options | 426 | set(options | ||
413 | NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE | 427 | NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE | ||
428 | NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE | ||||
414 | ) | 429 | ) | ||
415 | set(oneValueArgs | 430 | set(oneValueArgs | ||
416 | BASE_NAME | 431 | BASE_NAME | ||
417 | GROUP_BASE_NAME | 432 | GROUP_BASE_NAME | ||
418 | EXPORT_FILE_NAME | 433 | EXPORT_FILE_NAME | ||
419 | DEPRECATED_BASE_VERSION | 434 | DEPRECATED_BASE_VERSION | ||
420 | VERSION | 435 | VERSION | ||
421 | EXCLUDE_DEPRECATED_BEFORE_AND_AT | 436 | EXCLUDE_DEPRECATED_BEFORE_AND_AT | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 467 | _version_major "${ARGS_VERSION}") | |||
496 | 511 | | |||
497 | if(NOT IS_ABSOLUTE ${ARGS_EXPORT_FILE_NAME}) | 512 | if(NOT IS_ABSOLUTE ${ARGS_EXPORT_FILE_NAME}) | ||
498 | set(ARGS_EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_EXPORT_FILE_NAME}") | 513 | set(ARGS_EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_EXPORT_FILE_NAME}") | ||
499 | endif() | 514 | endif() | ||
500 | 515 | | |||
501 | set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${ARGS_EXPORT_FILE_NAME}") | 516 | set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${ARGS_EXPORT_FILE_NAME}") | ||
502 | # build with all the API not excluded, ensure all deprecated API is visible in the build itselt | 517 | # build with all the API not excluded, ensure all deprecated API is visible in the build itselt | ||
503 | _ecm_geh_generate_hex_number(_hexnumber ${ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT}) | 518 | _ecm_geh_generate_hex_number(_hexnumber ${ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT}) | ||
504 | set(_disabling_definition "${_macro_base_name}_DISABLE_DEPRECATED_BEFORE_AND_AT=${_hexnumber}") | 519 | set(_disabling_visibility_definition "${_macro_base_name}_DISABLE_DEPRECATED_BEFORE_AND_AT=${_hexnumber}") | ||
505 | target_compile_definitions(${target} PRIVATE "${_disabling_definition}") | 520 | target_compile_definitions(${target} PRIVATE "${_disabling_visibility_definition}") | ||
521 | if (NOT ARGS_NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE) | ||||
522 | target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_disabling_visibility_definition}>") | ||||
523 | endif() | ||||
524 | if(NOT ARGS_NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE) | ||||
525 | set(_enabling_warnings_definition "${_macro_base_name}_DEPRECATED_WARNINGS_SINCE=${_hexnumber}") | ||||
526 | target_compile_definitions(${target} PRIVATE "${_enabling_warnings_definition}") | ||||
506 | if (NOT ARGS_NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE) | 527 | if (NOT ARGS_NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE) | ||
507 | target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_disabling_definition}>") | 528 | target_compile_definitions(${target} INTERFACE "$<BUILD_INTERFACE:${_enabling_warnings_definition}>") | ||
529 | endif() | ||||
508 | endif() | 530 | endif() | ||
509 | 531 | | |||
510 | # for the set of compiler versions supported by ECM/KF we can assume those attributes supported | 532 | # for the set of compiler versions supported by ECM/KF we can assume those attributes supported | ||
511 | # KF6: with C++14 support expected, switch to always use [[deprecated(text)]] | 533 | # KF6: with C++14 support expected, switch to always use [[deprecated(text)]] | ||
512 | if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") | 534 | if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
513 | set(_decl_deprecated_text_definition "__attribute__ ((__deprecated__(text)))") | 535 | set(_decl_deprecated_text_definition "__attribute__ ((__deprecated__(text)))") | ||
514 | elseif(MSVC) | 536 | elseif(MSVC) | ||
515 | set(_decl_deprecated_text_definition "__declspec(deprecated(text))") | 537 | set(_decl_deprecated_text_definition "__declspec(deprecated(text))") | ||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |