Warning, /frameworks/extra-cmake-modules/tests/ECMGenerateExportHeaderTest/consumer/testAPI_NO_DEPRECATED.cmake is written in an unsupported language. File is not indexed.

0001 if(GROUP_MODE STREQUAL "GROUP_USE_GROUP")
0002     set(_deprecation_macros_base_name "LIBGROUP")
0003 else()
0004     set(_deprecation_macros_base_name "LIBRARY")
0005 endif()
0006 
0007 function(testAPI code_var_name)
0008     set(options BUILD_TIME_ONLY_DISABLABLE NO_WARNING)
0009     set(oneValueArgs DEPRECATED_AT CXX_STANDARD)
0010     set(multiValueArgs)
0011     cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
0012 
0013     if((NOT ARGS_DEPRECATED_AT) OR
0014        (ARGS_BUILD_TIME_ONLY_DISABLABLE AND ARGS_DEPRECATED_AT VERSION_GREATER DEPRECATED_EXCLUDED_BEFORE_AND_AT))
0015        set(_build_result_expected TRUE)
0016     else()
0017        set(_build_result_expected FALSE)
0018     endif()
0019 
0020     if (ARGS_CXX_STANDARD)
0021         if(MSVC)
0022             # C++11 is default for MSVC, no /std:c++11 flag available to set
0023             if (NOT ARGS_CXX_STANDARD STREQUAL "11")
0024                 set(std_flag  "/std:c++${ARGS_CXX_STANDARD}")
0025             endif()
0026         else()
0027             set(std_flag "-std=c++${ARGS_CXX_STANDARD}")
0028         endif()
0029     else()
0030         set(std_flag)
0031     endif()
0032 
0033     set(CMAKE_REQUIRED_FLAGS "${std_flag}")
0034     set(CMAKE_REQUIRED_LIBRARIES library)
0035     set(CMAKE_REQUIRED_DEFINITIONS "-D${_deprecation_macros_base_name}_NO_DEPRECATED")
0036 
0037     set(_code "
0038 #include <library.hpp>
0039 int main(int, char**)
0040 {
0041     ${${code_var_name}}
0042 }
0043 ")
0044 
0045     unset(_result CACHE) # clear out as check_cxx_source_compiles caches the result
0046     check_cxx_source_compiles("${_code}" _result)
0047 
0048     assert_var_bool_value(_result ${_build_result_expected})
0049 
0050     # check warning
0051     if(_build_result_expected)
0052         if(ARGS_BUILD_TIME_ONLY_DISABLABLE AND NOT ARGS_NO_WARNING)
0053             set(_dep_warning_as_error_result_expected FALSE)
0054         else()
0055             set(_dep_warning_as_error_result_expected TRUE)
0056         endif()
0057 
0058         if(MSVC)
0059             # warning C4996 warns about deprecated declarations
0060             set(dep_warning_as_error_flag "-we4996")
0061         else()
0062             set(dep_warning_as_error_flag "-Werror=deprecated-declarations")
0063         endif()
0064 
0065         set(CMAKE_REQUIRED_FLAGS "${std_flag} ${dep_warning_as_error_flag}")
0066         set(CMAKE_REQUIRED_DEFINITIONS) # unset LIBRARY_DISABLE_DEPRECATED_BEFORE_AND_AT, as LIBRARY_DEPRECATED_WARNINGS_SINCE defaults to it
0067         unset(_dep_warning_result CACHE) # clear out as check_cxx_source_compiles caches the result
0068         check_cxx_source_compiles("${_code}" _dep_warning_result)
0069         assert_var_bool_value(_dep_warning_result ${_dep_warning_as_error_result_expected})
0070     endif()
0071 endfunction()