1# SPDX-License-Identifier: Apache-2.0 2# 3# Copyright (c) 2022, Nordic Semiconductor ASA 4 5# FindDeprecated module provides a single location for deprecated CMake build code. 6# Whenever CMake code is deprecated it should be moved to this module and 7# corresponding COMPONENTS should be created with name identifying the deprecated code. 8# 9# This makes it easier to maintain deprecated code and cleanup such code when it 10# has been deprecated for two releases. 11# 12# Example: 13# CMakeList.txt contains deprecated code, like: 14# if(DEPRECATED_VAR) 15# deprecated() 16# endif() 17# 18# such code can easily be around for a long time, so therefore such code should 19# be moved to this module and can then be loaded as: 20# FindDeprecated.cmake 21# if(<deprecated_name> IN_LIST Deprecated_FIND_COMPONENTS) 22# # This code has been deprecated after Zephyr x.y 23# if(DEPRECATED_VAR) 24# deprecated() 25# endif() 26# endif() 27# 28# and then in the original CMakeLists.txt, this code is inserted instead: 29# find_package(Deprecated COMPONENTS <deprecated_name>) 30# 31# The module defines the following variables: 32# 33# 'Deprecated_FOUND', 'DEPRECATED_FOUND' 34# True if the Deprecated component was found and loaded. 35 36if("${Deprecated_FIND_COMPONENTS}" STREQUAL "") 37 message(WARNING "find_package(Deprecated) missing required COMPONENTS keyword") 38endif() 39 40if("toolchain_ld_base" IN_LIST Deprecated_FIND_COMPONENTS) 41 # This code was deprecated after Zephyr v4.0.0 42 list(REMOVE_ITEM Deprecated_FIND_COMPONENTS toolchain_ld_base) 43 44 if(COMMAND toolchain_ld_base) 45 message(DEPRECATION 46 "The macro/function 'toolchain_ld_base' is deprecated. " 47 "Please use '${LINKER}/linker_flags.cmake' and define the appropriate " 48 "linker flags as properties instead. " 49 "See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for " 50 "known linker properties." 51 ) 52 toolchain_ld_base() 53 endif() 54endif() 55 56if("toolchain_ld_baremetal" IN_LIST Deprecated_FIND_COMPONENTS) 57 # This code was deprecated after Zephyr v4.0.0 58 list(REMOVE_ITEM Deprecated_FIND_COMPONENTS toolchain_ld_baremetal) 59 60 if(COMMAND toolchain_ld_baremetal) 61 message(DEPRECATION 62 "The macro/function 'toolchain_ld_baremetal' is deprecated. " 63 "Please use '${LINKER}/linker_flags.cmake' and define the appropriate " 64 "linker flags as properties instead. " 65 "See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for " 66 "known linker properties." 67 ) 68 toolchain_ld_baremetal() 69 endif() 70endif() 71 72if("toolchain_ld_cpp" IN_LIST Deprecated_FIND_COMPONENTS) 73 # This code was deprecated after Zephyr v4.0.0 74 list(REMOVE_ITEM Deprecated_FIND_COMPONENTS toolchain_ld_cpp) 75 76 if(COMMAND toolchain_ld_cpp) 77 message(DEPRECATION 78 "The macro/function 'toolchain_ld_cpp' is deprecated. " 79 "Please use '${LINKER}/linker_flags.cmake' and define the appropriate " 80 "linker flags as properties instead. " 81 "See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for " 82 "known linker properties." 83 ) 84 toolchain_ld_cpp() 85 endif() 86endif() 87 88if(NOT "${Deprecated_FIND_COMPONENTS}" STREQUAL "") 89 message(STATUS "The following deprecated component(s) could not be found: " 90 "${Deprecated_FIND_COMPONENTS}") 91endif() 92 93set(Deprecated_FOUND True) 94set(DEPRECATED_FOUND True) 95