aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2019-09-04 19:19:27 +0200
committerFriedrich W. H. Kossebau <kossebau@kde.org>2019-10-10 22:50:03 +0200
commit7b15c20dafc9133f93bbc65354ec3a36af168fd3 (patch)
treeb61228f0bfb4cc4a50c70ccce67a69b273dc8d10 /tests
parentf3f4893b5bd20a32dd48b147fdd243c3226a06f3 (diff)
downloadextra-cmake-modules-7b15c20dafc9133f93bbc65354ec3a36af168fd3.tar.gz
extra-cmake-modules-7b15c20dafc9133f93bbc65354ec3a36af168fd3.tar.bz2
Add ECMGenerateExportHeader, for improved handling of deprecated API
Summary: Generates additional macros in the export header which can be used for fine-grained disabling of warnings & visibility as well as excluding from the build. Reviewers: #frameworks, #build_system Subscribers: chehrlic, dfaure, cgiboudeaux, kde-frameworks-devel, kde-buildsystem Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D23789
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/ECMGenerateExportHeaderTest/CMakeLists.txt120
-rw-r--r--tests/ECMGenerateExportHeaderTest/consumer/CMakeLists.txt50
-rw-r--r--tests/ECMGenerateExportHeaderTest/consumer/main.cpp4
-rw-r--r--tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake71
-rw-r--r--tests/ECMGenerateExportHeaderTest/consumer/testAPI_NO_DEPRECATED.cmake50
-rw-r--r--tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt50
-rw-r--r--tests/ECMGenerateExportHeaderTest/format_version/main.cpp4
-rw-r--r--tests/ECMGenerateExportHeaderTest/library/CMakeLists.txt40
-rw-r--r--tests/ECMGenerateExportHeaderTest/library/library.cpp33
-rw-r--r--tests/ECMGenerateExportHeaderTest/library/library.hpp35
-rw-r--r--tests/ECMGenerateExportHeaderTest/library/main.cpp4
12 files changed, 462 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9df03eb9..72ae57dc 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -53,6 +53,7 @@ set_package_properties(
)
add_subdirectory(ECMAddTests)
+add_subdirectory(ECMGenerateExportHeaderTest)
add_subdirectory(ECMGenerateHeadersTest)
add_subdirectory(ECMSetupVersionTest)
add_subdirectory(ECMGeneratePkgConfigFile)
diff --git a/tests/ECMGenerateExportHeaderTest/CMakeLists.txt b/tests/ECMGenerateExportHeaderTest/CMakeLists.txt
new file mode 100644
index 00000000..5b25a7df
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/CMakeLists.txt
@@ -0,0 +1,120 @@
+set(installation_path "${CMAKE_CURRENT_BINARY_DIR}/installation/")
+
+macro(add_generate_export_header_library_test _exclude_deprecated_before_and_at)
+ if("${ARGV1}" STREQUAL "WITH_GROUP")
+ set(_set_group_option "-DSET_GROUP=TRUE")
+ set(_library_buildname "library-${_exclude_deprecated_before_and_at}-group")
+ else()
+ set(_library_buildname "library-${_exclude_deprecated_before_and_at}")
+ endif()
+ add_test(NAME ecm_generate_export_header-build-${_library_buildname}
+ COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/library"
+ "${CMAKE_CURRENT_BINARY_DIR}/${_library_buildname}"
+ --build-two-config
+ --build-generator "${CMAKE_GENERATOR}"
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project library
+ --build-target install
+ --build-options
+ "-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=${_exclude_deprecated_before_and_at}"
+ "-DCMAKE_INSTALL_PREFIX:PATH=${installation_path}/${_library_buildname}"
+ ${_set_group_option}
+ --test-command dummy
+ )
+endmacro()
+
+macro(add_generate_export_header_consumer_test _test_variant _exclude_deprecated_before_and_at _group_test_mode _consumer_build)
+ set(_extra_build_options ${ARGN})
+ if(_group_test_mode STREQUAL "GROUPLESS")
+ set(_library "library-${_exclude_deprecated_before_and_at}")
+ else()
+ set(_library "library-${_exclude_deprecated_before_and_at}-group")
+ endif()
+ add_test(NAME ecm_generate_export_header-${_consumer_build}
+ COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer"
+ "${CMAKE_CURRENT_BINARY_DIR}/${_consumer_build}"
+ --build-two-config
+ --build-generator "${CMAKE_GENERATOR}"
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project consumer
+ --build-options
+ "-DTEST_VARIANT:STRING=${_test_variant}"
+ "-DDEPRECATED_EXCLUDED_BEFORE_AND_AT:STRING=${_exclude_deprecated_before_and_at}"
+ "-DLIBRARY:STRING=${_library}"
+ "-DGROUP_MODE:STRING=${_group_test_mode}"
+ ${_extra_build_options}
+ --test-command dummy
+ )
+endmacro()
+
+macro(add_generate_export_header_consumer_disable_deprecated_before_and_at_test
+ _disable_deprecated_before_and_at
+ _exclude_deprecated_before_and_at
+ _group_test_mode
+ )
+ set(_consumer_build "consumer-${_disable_deprecated_before_and_at}-${_exclude_deprecated_before_and_at}-${_group_test_mode}")
+ set(_extra_build_options
+ "-DLIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT:STRING=${_disable_deprecated_before_and_at}"
+ )
+ add_generate_export_header_consumer_test(DISABLE_DEPRECATED_BEFORE_AND_AT
+ ${_exclude_deprecated_before_and_at}
+ ${_group_test_mode}
+ ${_consumer_build}
+ ${_extra_build_options}
+ )
+endmacro()
+
+macro(add_generate_export_header_consumer_no_deprecated_test _exclude_deprecated_before_and_at _group_test_mode)
+ set(_consumer_build "consumer-NO-DEPRECATED-${_exclude_deprecated_before_and_at}-${_group_test_mode}")
+ add_generate_export_header_consumer_test(NO_DEPRECATED
+ ${_exclude_deprecated_before_and_at}
+ ${_group_test_mode}
+ ${_consumer_build}
+ )
+endmacro()
+
+# prepare list of versions
+set(library_versions 0 2.0.0 CURRENT)
+list(LENGTH library_versions library_versions_count)
+math(EXPR _last_index ${library_versions_count}-1)
+
+# test generating the library with different EXCLUDE_DEPRECATED_BEFORE_AND_AT values
+# als install the generated libraries together incl. exported cmake targets, for use in tests below
+# TODO: wariant with DEPRECATED_BASE_VERSION
+foreach(_group_arg "" "WITH_GROUP")
+ foreach(_index RANGE ${_last_index})
+ list(GET library_versions ${_index} _exclude_deprecated_before_and_at)
+ add_generate_export_header_library_test(${_exclude_deprecated_before_and_at} ${_group_arg})
+ endforeach()
+endforeach()
+
+
+set(group_test_modes "GROUPLESS" "GROUP_USE_DIRECT" "GROUP_USE_GROUP")
+
+# test using the library, built with different EXCLUDE_DEPRECATED_BEFORE_AND_AT values,
+# while using different DISABLE_DEPRECATED_BEFORE_AND_AT values
+# TODO: test DEPRECATED_WARNINGS_SINCE
+foreach(_group_test_mode ${group_test_modes})
+ foreach(_exclude_index RANGE ${_last_index})
+ list(GET library_versions ${_exclude_index} _exclude_deprecated_before_and_at)
+ # using disabled API limit below the excluded API limit is not supported and
+ # catched by the code generated from the ecm_generate_export_header,
+ # so testing those combination will not work, so start from the excluded API limit
+ foreach(_disable_index RANGE ${_exclude_index} ${_last_index})
+ list(GET library_versions ${_disable_index} _disable_deprecated_before_and_at)
+ add_generate_export_header_consumer_disable_deprecated_before_and_at_test(${_disable_deprecated_before_and_at} ${_exclude_deprecated_before_and_at} ${_group_test_mode})
+ endforeach()
+ endforeach()
+endforeach()
+
+# test with NO_DEPRECATED
+foreach(_group_test_mode ${group_test_modes})
+ foreach(_exclude_index RANGE ${_last_index})
+ list(GET library_versions ${_exclude_index} _exclude_deprecated_before_and_at)
+ add_generate_export_header_consumer_no_deprecated_test(${_exclude_deprecated_before_and_at} ${_group_test_mode})
+ endforeach()
+endforeach()
diff --git a/tests/ECMGenerateExportHeaderTest/consumer/CMakeLists.txt b/tests/ECMGenerateExportHeaderTest/consumer/CMakeLists.txt
new file mode 100644
index 00000000..ba5940cd
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/consumer/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(consumer)
+
+include(CheckCXXSourceCompiles)
+include(CMakeParseArguments)
+
+include(../../test_helpers.cmake)
+
+include("${CMAKE_CURRENT_BINARY_DIR}/../installation/${LIBRARY}/lib/library/LibraryTargets.cmake")
+
+# map any "CURRENT" value to library version string
+# keep version in sync with the one used in library/CMakeLists.txt
+set(library_version 2.40.0)
+if(LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT STREQUAL "CURRENT")
+ set(LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT ${library_version})
+endif()
+if(DEPRECATED_EXCLUDED_BEFORE_AND_AT STREQUAL "CURRENT")
+ set(DEPRECATED_EXCLUDED_BEFORE_AND_AT ${library_version})
+endif()
+
+# load the test variant specific testAPI method
+include(testAPI_${TEST_VARIANT}.cmake)
+
+# for each API element test their visibility to the compiler and if a warning is emitted
+set(_code "Enum enumerator = Enumerator_deprecatedAt2_0;")
+testAPI(_code DEPRECATED_AT 2.0 BUILD_TIME_ONLY_DISABLABLE NO_WARNING)
+
+set(_code "Enum enumerator = Enumerator_not_deprecated;")
+testAPI(_code)
+
+set(_code "function_deprecatedAt2_0();")
+testAPI(_code DEPRECATED_AT 2.0)
+
+set(_code "function_deprecatedAt2_12();")
+testAPI(_code DEPRECATED_AT 2.12)
+
+set(_code "function_not_deprecated();")
+testAPI(_code)
+
+set(_code "Class().method_deprecatedAt2_0();")
+testAPI(_code DEPRECATED_AT 2.0 BUILD_TIME_ONLY_DISABLABLE)
+
+set(_code "Class().method_deprecatedAt2_12();")
+testAPI(_code DEPRECATED_AT 2.12 BUILD_TIME_ONLY_DISABLABLE)
+
+set(_code "Class().method_not_deprecated();")
+testAPI(_code)
+
+add_executable(dummy main.cpp)
diff --git a/tests/ECMGenerateExportHeaderTest/consumer/main.cpp b/tests/ECMGenerateExportHeaderTest/consumer/main.cpp
new file mode 100644
index 00000000..0f45ea60
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/consumer/main.cpp
@@ -0,0 +1,4 @@
+int main(int, char**)
+{
+ return 0;
+}
diff --git a/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake
new file mode 100644
index 00000000..fac51d53
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake
@@ -0,0 +1,71 @@
+function(generate_hex_number _var_name _version)
+ set(_hexnumber 0)
+
+ set(version_regex "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
+ string(REGEX REPLACE ${version_regex} "\\1" _version_major "${_version}")
+ string(REGEX REPLACE ${version_regex} "\\2" _version_minor "${_version}")
+ string(REGEX REPLACE ${version_regex} "\\3" _version_patch "${_version}")
+ set(_outputformat)
+ if (NOT CMAKE_VERSION VERSION_LESS 3.13)
+ set(_outputformat OUTPUT_FORMAT HEXADECIMAL)
+ endif()
+ math(EXPR _hexnumber "${_version_major}*65536 + ${_version_minor}*256 + ${_version_patch}" ${_outputformat})
+ set(${_var_name} ${_hexnumber} PARENT_SCOPE)
+endfunction()
+
+
+generate_hex_number(disable_deprecated_before_and_at_hexnumber ${LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT})
+
+if(GROUP_MODE STREQUAL "GROUP_USE_GROUP")
+ set(_deprecation_macros_base_name "LIBGROUP")
+else()
+ set(_deprecation_macros_base_name "LIBRARY")
+endif()
+
+function(testAPI code_var_name)
+ set(options BUILD_TIME_ONLY_DISABLABLE NO_WARNING)
+ set(oneValueArgs DEPRECATED_AT)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if((NOT ARGS_DEPRECATED_AT) OR
+ (ARGS_BUILD_TIME_ONLY_DISABLABLE AND ARGS_DEPRECATED_AT VERSION_GREATER DEPRECATED_EXCLUDED_BEFORE_AND_AT) OR
+ (ARGS_DEPRECATED_AT VERSION_GREATER LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT))
+ set(_build_result_expected TRUE)
+ else()
+ set(_build_result_expected FALSE)
+ endif()
+
+ set(CMAKE_REQUIRED_LIBRARIES library)
+ set(CMAKE_REQUIRED_DEFINITIONS "-D${_deprecation_macros_base_name}_DISABLE_DEPRECATED_BEFORE_AND_AT=${disable_deprecated_before_and_at_hexnumber}")
+
+ set(_code "
+#include <library.hpp>
+int main(int, char**)
+{
+ ${${code_var_name}}
+}
+")
+
+ unset(_result CACHE) # clear out as check_cxx_source_compiles caches the result
+ check_cxx_source_compiles("${_code}" _result)
+
+ assert_var_bool_value(_result ${_build_result_expected})
+
+ # check warning
+ if(_build_result_expected)
+ if((ARGS_BUILD_TIME_ONLY_DISABLABLE AND NOT ARGS_NO_WARNING) OR
+ (NOT ARGS_BUILD_TIME_ONLY_DISABLABLE AND ARGS_DEPRECATED_AT AND
+ ARGS_DEPRECATED_AT VERSION_GREATER LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT))
+ set(_dep_warning_result_expected FALSE)
+ else()
+ set(_dep_warning_result_expected TRUE)
+ endif()
+
+ set(CMAKE_REQUIRED_FLAGS "-Werror=deprecated-declarations")
+ set(CMAKE_REQUIRED_DEFINITIONS) # unset LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT, as LIBRARY_DEPRECATED_WARNINGS_SINCE defaults to it
+ unset(_dep_warning_result CACHE) # clear out as check_cxx_source_compiles caches the result
+ check_cxx_source_compiles("${_code}" _dep_warning_result)
+ assert_var_bool_value(_dep_warning_result ${_dep_warning_result_expected})
+ endif()
+endfunction()
diff --git a/tests/ECMGenerateExportHeaderTest/consumer/testAPI_NO_DEPRECATED.cmake b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_NO_DEPRECATED.cmake
new file mode 100644
index 00000000..190ccecc
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_NO_DEPRECATED.cmake
@@ -0,0 +1,50 @@
+if(GROUP_MODE STREQUAL "GROUP_USE_GROUP")
+ set(_deprecation_macros_base_name "LIBGROUP")
+else()
+ set(_deprecation_macros_base_name "LIBRARY")
+endif()
+
+function(testAPI code_var_name)
+ set(options BUILD_TIME_ONLY_DISABLABLE NO_WARNING)
+ set(oneValueArgs DEPRECATED_AT)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if((NOT ARGS_DEPRECATED_AT) OR
+ (ARGS_BUILD_TIME_ONLY_DISABLABLE AND ARGS_DEPRECATED_AT VERSION_GREATER DEPRECATED_EXCLUDED_BEFORE_AND_AT))
+ set(_build_result_expected TRUE)
+ else()
+ set(_build_result_expected FALSE)
+ endif()
+
+ set(CMAKE_REQUIRED_LIBRARIES library)
+ set(CMAKE_REQUIRED_DEFINITIONS "-D${_deprecation_macros_base_name}_NO_DEPRECATED")
+
+ set(_code "
+#include <library.hpp>
+int main(int, char**)
+{
+ ${${code_var_name}}
+}
+")
+
+ unset(_result CACHE) # clear out as check_cxx_source_compiles caches the result
+ check_cxx_source_compiles("${_code}" _result)
+
+ assert_var_bool_value(_result ${_build_result_expected})
+
+ # check warning
+ if(_build_result_expected)
+ if(ARGS_BUILD_TIME_ONLY_DISABLABLE AND NOT ARGS_NO_WARNING)
+ set(_dep_warning_result_expected FALSE)
+ else()
+ set(_dep_warning_result_expected TRUE)
+ endif()
+
+ set(CMAKE_REQUIRED_FLAGS "-Werror=deprecated-declarations")
+ set(CMAKE_REQUIRED_DEFINITIONS) # unset LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT, as LIBRARY_DEPRECATED_WARNINGS_SINCE defaults to it
+ unset(_dep_warning_result CACHE) # clear out as check_cxx_source_compiles caches the result
+ check_cxx_source_compiles("${_code}" _dep_warning_result)
+ assert_var_bool_value(_dep_warning_result ${_dep_warning_result_expected})
+ endif()
+endfunction()
diff --git a/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt b/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt
new file mode 100644
index 00000000..b46719c2
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(format_version)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMGenerateExportHeader)
+
+include(../../test_helpers.cmake)
+
+set(_current_version "4.5.6")
+
+# check 0
+ecm_export_header_format_version(0
+ CURRENT_VERSION ${_current_version}
+ STRING_VAR _versionstring
+ HEXNUMBER_VAR _hexnumber
+)
+
+assert_var_str_value(_versionstring "0")
+assert_var_str_value(_hexnumber "0")
+
+# check other
+ecm_export_header_format_version(1.2.3
+ CURRENT_VERSION ${_current_version}
+ STRING_VAR _versionstring
+ HEXNUMBER_VAR _hexnumber
+)
+
+assert_var_str_value(_versionstring "1.2.3")
+if (NOT CMAKE_VERSION VERSION_LESS 3.13)
+ assert_var_str_value(_hexnumber "0x10203")
+else()
+ assert_var_str_value(_hexnumber "66051")
+endif()
+
+# check CURRENT
+ecm_export_header_format_version(CURRENT
+ CURRENT_VERSION ${_current_version}
+ STRING_VAR _versionstring
+ HEXNUMBER_VAR _hexnumber
+)
+
+assert_var_str_value(_versionstring "4.5.6")
+if (NOT CMAKE_VERSION VERSION_LESS 3.13)
+ assert_var_str_value(_hexnumber "0x40506")
+else()
+ assert_var_str_value(_hexnumber "263430")
+endif()
+
+add_executable(dummy main.cpp)
diff --git a/tests/ECMGenerateExportHeaderTest/format_version/main.cpp b/tests/ECMGenerateExportHeaderTest/format_version/main.cpp
new file mode 100644
index 00000000..0f45ea60
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/format_version/main.cpp
@@ -0,0 +1,4 @@
+int main(int, char**)
+{
+ return 0;
+}
diff --git a/tests/ECMGenerateExportHeaderTest/library/CMakeLists.txt b/tests/ECMGenerateExportHeaderTest/library/CMakeLists.txt
new file mode 100644
index 00000000..eb925c9b
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/library/CMakeLists.txt
@@ -0,0 +1,40 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+# keep version in sync with the one used in consumer/CMakeLists.txt for the library
+# ideally would be send over by an exported target property,
+# but exporting custom properties via EXPORT_PROPERTIES only was added in CMake 3.12
+project(library VERSION 2.40.0)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMGenerateExportHeader)
+
+set(_public_includedir "include/library")
+
+add_library(library library.cpp)
+target_include_directories(library
+ PUBLIC
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
+ "$<INSTALL_INTERFACE:${_public_includedir}>"
+)
+
+if(SET_GROUP)
+ set(_group_args GROUP_BASE_NAME LIBGROUP)
+endif()
+
+ecm_generate_export_header(library
+ ${_group_args}
+ VERSION ${library_VERSION}
+ DEPRECATION_VERSIONS 2.0 2.12
+ EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
+)
+
+install(TARGETS library DESTINATION lib EXPORT library_targets)
+
+install(EXPORT library_targets FILE LibraryTargets.cmake DESTINATION lib/library)
+install(FILES
+ library.hpp
+ "${CMAKE_CURRENT_BINARY_DIR}/library_export.h"
+ DESTINATION ${_public_includedir}
+)
+
+add_executable(dummy main.cpp)
diff --git a/tests/ECMGenerateExportHeaderTest/library/library.cpp b/tests/ECMGenerateExportHeaderTest/library/library.cpp
new file mode 100644
index 00000000..9d08838c
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/library/library.cpp
@@ -0,0 +1,33 @@
+#include "library.hpp"
+
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 0)
+void function_deprecatedAt2_0()
+{
+}
+#endif
+
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 12)
+void function_deprecatedAt2_12()
+{
+}
+#endif
+
+void function_not_deprecated()
+{
+}
+
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 0)
+void Class::method_deprecatedAt2_0()
+{
+}
+#endif
+
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 12)
+void Class::method_deprecatedAt2_12()
+{
+}
+#endif
+
+void Class::method_not_deprecated()
+{
+}
diff --git a/tests/ECMGenerateExportHeaderTest/library/library.hpp b/tests/ECMGenerateExportHeaderTest/library/library.hpp
new file mode 100644
index 00000000..2124bf8a
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/library/library.hpp
@@ -0,0 +1,35 @@
+#include <library_export.h>
+
+enum Enum {
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 0)
+ Enumerator_deprecatedAt2_0,
+#endif
+ Enumerator_not_deprecated,
+};
+
+#if LIBRARY_ENABLE_DEPRECATED_SINCE(2, 0)
+LIBRARY_DEPRECATED_VERSION(2, 0, "Deprecated at 2.0")
+LIBRARY_EXPORT void function_deprecatedAt2_0();
+#endif
+
+#if LIBRARY_ENABLE_DEPRECATED_SINCE(2, 12)
+LIBRARY_DEPRECATED_VERSION(2, 12, "Deprecated at 2.12")
+LIBRARY_EXPORT void function_deprecatedAt2_12();
+#endif
+
+LIBRARY_EXPORT void function_not_deprecated();
+
+class LIBRARY_EXPORT Class {
+public:
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 0)
+ LIBRARY_DEPRECATED_VERSION(2, 0, "Deprecated at 2.0")
+ virtual void method_deprecatedAt2_0();
+#endif
+
+#if LIBRARY_BUILD_DEPRECATED_SINCE(2, 12)
+ LIBRARY_DEPRECATED_VERSION(2, 12, "Deprecated at 2.12")
+ virtual void method_deprecatedAt2_12();
+#endif
+
+ virtual void method_not_deprecated();
+};
diff --git a/tests/ECMGenerateExportHeaderTest/library/main.cpp b/tests/ECMGenerateExportHeaderTest/library/main.cpp
new file mode 100644
index 00000000..0f45ea60
--- /dev/null
+++ b/tests/ECMGenerateExportHeaderTest/library/main.cpp
@@ -0,0 +1,4 @@
+int main(int, char**)
+{
+ return 0;
+}