Anas Nashif | 3ae5262 | 2019-04-06 09:08:09 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | |
Mark Ruvald Pedersen | 59036db | 2018-12-19 16:27:55 +0100 | [diff] [blame] | 3 | # *DOCUMENTATION* |
| 4 | # |
| 5 | # Note that this is *NOT* the top-level CMakeLists.txt. That's in the |
| 6 | # application. See the Application Development Primer documentation |
| 7 | # for details. |
| 8 | # |
| 9 | # To see a list of typical targets execute "make usage" |
| 10 | # More info can be located in ./README.rst |
| 11 | # Comments in this file are targeted only to the developer, do not |
| 12 | # expect to learn how to build the kernel reading this file. |
| 13 | |
Sebastian Bøe | ee9af86 | 2018-06-04 11:47:45 +0200 | [diff] [blame] | 14 | if(NOT DEFINED ZEPHYR_BINARY_DIR) |
Anas Nashif | f2cb20c | 2019-06-18 14:45:40 -0400 | [diff] [blame] | 15 | message(FATAL_ERROR "A user error has occurred. |
Sebastian Bøe | ee9af86 | 2018-06-04 11:47:45 +0200 | [diff] [blame] | 16 | cmake was invoked with '${CMAKE_CURRENT_LIST_DIR}' specified as the source directory, |
| 17 | but it must be invoked with an application source directory, |
| 18 | such as '${CMAKE_CURRENT_LIST_DIR}/samples/hello_world'. |
| 19 | Debug variables: |
| 20 | CMAKE_CACHEFILE_DIR: ${CMAKE_CACHEFILE_DIR} |
| 21 | ") |
| 22 | endif() |
| 23 | |
Marc Herbert | d3d3394 | 2019-05-31 15:37:40 -0700 | [diff] [blame] | 24 | |
| 25 | # See https://gitlab.kitware.com/cmake/cmake/issues/16228 |
| 26 | # and https://cmake.org/pipermail/cmake/2019-May/thread.html#69496 |
| 27 | if(NOT ZEPHYR_BASE STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 28 | message(WARNING "ZEPHYR_BASE doesn't match CMAKE_CURRENT_SOURCE_DIR |
| 29 | ZEPHYR_BASE = ${ZEPHYR_BASE} |
| 30 | PWD = $ENV{PWD} |
| 31 | CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR} |
| 32 | You may be using a mix of symbolic links and real paths which causes \ |
| 33 | subtle and hard to debug CMake issues.") |
| 34 | endif() |
| 35 | # For Zephyr more specifically this breaks (at least) |
| 36 | # -fmacro-prefix-map=${ZEPHYR_BASE}= |
| 37 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 38 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 39 | # Verify that the toolchain can compile a dummy file, if it is not we |
Anas Nashif | f2cb20c | 2019-06-18 14:45:40 -0400 | [diff] [blame] | 40 | # won't be able to test for compatibility with certain C flags. |
Sebastian Bøe | 6212ec9 | 2019-08-28 13:02:51 +0200 | [diff] [blame] | 41 | zephyr_check_compiler_flag(C "" toolchain_is_ok) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 42 | assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMakeError.log.") |
| 43 | |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 44 | # In some cases the "final" things are not used at all and "_prebuilt" |
| 45 | # is the last station. See "logical_target_for_zephyr_elf" below for |
| 46 | # details. |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 47 | set(CMAKE_EXECUTABLE_SUFFIX .elf) |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 48 | set(ZEPHYR_PREBUILT_EXECUTABLE zephyr_prebuilt) |
Mark Ruvald Pedersen | 37d4947 | 2019-05-07 15:20:20 +0200 | [diff] [blame] | 49 | set(ZEPHYR_FINAL_EXECUTABLE zephyr_final) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 50 | |
Mark Ruvald Pedersen | 11d6bae | 2019-04-29 16:57:37 +0200 | [diff] [blame] | 51 | # Set some phony targets to collect dependencies |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 52 | set(OFFSETS_H_TARGET offsets_h) |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 53 | set(SYSCALL_LIST_H_TARGET syscall_list_h_target) |
| 54 | set(DRIVER_VALIDATION_H_TARGET driver_validation_h_target) |
| 55 | set(KOBJ_TYPES_H_TARGET kobj_types_h_target) |
Andrew Boie | c1c54b1 | 2020-03-16 12:48:00 -0700 | [diff] [blame] | 56 | set(PARSE_SYSCALLS_TARGET parse_syscalls_target) |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 57 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 58 | define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT BRIEF_DOCS " " FULL_DOCS " ") |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 59 | set_property( GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little${ARCH}) # BFD format |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 60 | |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 61 | # "zephyr_interface" is a source-less library that encapsulates all the global |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 62 | # compiler options needed by all source files. All zephyr libraries, |
| 63 | # including the library named "zephyr" link with this library to |
| 64 | # obtain these flags. |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 65 | # https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#interface-libraries |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 66 | add_library(zephyr_interface INTERFACE) |
| 67 | |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 68 | # "zephyr" is a catch-all CMake library for source files that can be |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 69 | # built purely with the include paths, defines, and other compiler |
| 70 | # flags that come with zephyr_interface. |
| 71 | zephyr_library_named(zephyr) |
| 72 | |
| 73 | zephyr_include_directories( |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 74 | include |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 75 | ${PROJECT_BINARY_DIR}/include/generated |
| 76 | ${USERINCLUDE} |
| 77 | ${STDINCLUDE} |
| 78 | ) |
| 79 | |
Sebastian Bøe | 4036339 | 2019-01-25 10:14:13 +0100 | [diff] [blame] | 80 | # Don't add non-existing include directories, it creates noise and |
| 81 | # warnings in some tooling |
| 82 | foreach(optional_include_dir |
| 83 | ${SOC_DIR}/${ARCH}/${SOC_PATH} |
| 84 | ${SOC_DIR}/${ARCH}/${SOC_PATH}/include |
| 85 | ${SOC_DIR}/${ARCH}/${SOC_FAMILY}/include |
Andy Ross | 544a38e | 2020-06-25 17:42:51 -0700 | [diff] [blame] | 86 | ${SOC_DIR}/${ARCH}/${SOC_FAMILY}/common/include |
Sebastian Bøe | 4036339 | 2019-01-25 10:14:13 +0100 | [diff] [blame] | 87 | ) |
| 88 | if(EXISTS ${optional_include_dir}) |
| 89 | zephyr_include_directories(${optional_include_dir}) |
| 90 | endif() |
| 91 | endforeach() |
| 92 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 93 | zephyr_compile_definitions( |
| 94 | KERNEL |
| 95 | __ZEPHYR__=1 |
Anas Nashif | 34aebad | 2018-01-03 12:26:19 -0500 | [diff] [blame] | 96 | ) |
| 97 | |
Mark Ruvald Pedersen | 0159207 | 2019-01-10 12:07:51 +0100 | [diff] [blame] | 98 | # @Intent: Set compiler flags to enable buffer overflow checks in libc functions |
| 99 | # @config in CONFIG_NO_OPTIMIZATIONS optional : Optimizations may affect security |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 100 | zephyr_compile_definitions($<TARGET_PROPERTY:compiler,security_fortify> ) |
Mark Ruvald Pedersen | 0159207 | 2019-01-10 12:07:51 +0100 | [diff] [blame] | 101 | |
| 102 | # @Intent: Set compiler flags to detect general stack overflows across all functions |
| 103 | if(CONFIG_STACK_CANARIES) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 104 | zephyr_compile_options($<TARGET_PROPERTY:compiler,security_canaries>) |
Anas Nashif | 34aebad | 2018-01-03 12:26:19 -0500 | [diff] [blame] | 105 | endif() |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 106 | |
Anas Nashif | daf7716 | 2018-04-09 21:53:26 -0500 | [diff] [blame] | 107 | if(BUILD_VERSION) |
| 108 | zephyr_compile_definitions( |
| 109 | BUILD_VERSION=${BUILD_VERSION} |
| 110 | ) |
| 111 | endif() |
| 112 | |
Mark Ruvald Pedersen | 0b3c65f | 2019-01-30 10:12:30 +0100 | [diff] [blame] | 113 | # @Intent: Obtain compiler optimizations flags and store in variables |
| 114 | # @details: |
| 115 | # Kconfig.zephyr "Optimization level" is a kconfig choice, ensuring |
| 116 | # only *one* of CONFIG_{NO,DEBUG,SPEED,SIZE}_OPTIMIZATIONS is set. |
| 117 | # Refer to Kconfig.zephyr for selection logic and description of these choices. |
| 118 | # toolchain_cc_optimize_*() macros must provide the mapping from these kconfigs |
| 119 | # to compiler flags. Each macro will store the flags in a CMake variable, whose |
| 120 | # name is passed as argument (somewhat like by reference). |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 121 | # |
Mark Ruvald Pedersen | 0b3c65f | 2019-01-30 10:12:30 +0100 | [diff] [blame] | 122 | # If the user wants to tweak the optimizations, there are two ways: |
| 123 | # 1) Using EXTRA_CFLAGS which is applied regardless of kconfig choice, or |
| 124 | # 2) Rely on override support being implemented by your toolchain_cc_optimize_*() |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 125 | # |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 126 | get_property(OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG TARGET compiler PROPERTY no_optimization) |
| 127 | get_property(OPTIMIZE_FOR_DEBUG_FLAG TARGET compiler PROPERTY optimization_debug) |
| 128 | get_property(OPTIMIZE_FOR_SPEED_FLAG TARGET compiler PROPERTY optimization_speed) |
| 129 | get_property(OPTIMIZE_FOR_SIZE_FLAG TARGET compiler PROPERTY optimization_size) |
Sebastian Bøe | 600c8f7 | 2018-01-24 10:40:32 +0100 | [diff] [blame] | 130 | |
Mark Ruvald Pedersen | 0b3c65f | 2019-01-30 10:12:30 +0100 | [diff] [blame] | 131 | # From kconfig choice, pick the actual OPTIMIZATION_FLAG to use. |
| 132 | # Kconfig choice ensures only one of these CONFIG_*_OPTIMIZATIONS is set. |
Alberto Escolar Piedras | f60527a | 2018-01-22 15:35:54 +0100 | [diff] [blame] | 133 | if(CONFIG_NO_OPTIMIZATIONS) |
Sebastian Bøe | 600c8f7 | 2018-01-24 10:40:32 +0100 | [diff] [blame] | 134 | set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_NO_OPTIMIZATIONS_FLAG}) |
| 135 | elseif(CONFIG_DEBUG_OPTIMIZATIONS) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 136 | set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_DEBUG_FLAG}) |
Aurelien Jarno | e8413d1 | 2018-06-16 23:40:04 +0200 | [diff] [blame] | 137 | elseif(CONFIG_SPEED_OPTIMIZATIONS) |
| 138 | set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SPEED_FLAG}) |
Sebastian Bøe | 600c8f7 | 2018-01-24 10:40:32 +0100 | [diff] [blame] | 139 | elseif(CONFIG_SIZE_OPTIMIZATIONS) |
Mark Ruvald Pedersen | 0b3c65f | 2019-01-30 10:12:30 +0100 | [diff] [blame] | 140 | set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SIZE_FLAG}) # Default in kconfig |
Sebastian Bøe | 600c8f7 | 2018-01-24 10:40:32 +0100 | [diff] [blame] | 141 | else() |
Anas Nashif | 885aaf2 | 2019-01-18 19:15:19 -0500 | [diff] [blame] | 142 | assert(0 "Unreachable code. Expected optimization level to have been chosen. See Kconfig.zephyr") |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 143 | endif() |
| 144 | |
Ulf Magnusson | de42aea | 2020-02-07 00:48:22 +0100 | [diff] [blame] | 145 | if(NOT CONFIG_ARCH_IS_SET) |
| 146 | message(WARNING "\ |
| 147 | None of the CONFIG_<arch> (e.g. CONFIG_X86) symbols are set. \ |
| 148 | Select one of them from the SOC_SERIES_* symbol or, lacking that, from the \ |
| 149 | SOC_* symbol.") |
| 150 | endif() |
| 151 | |
Mark Ruvald Pedersen | 0b3c65f | 2019-01-30 10:12:30 +0100 | [diff] [blame] | 152 | # Apply the final optimization flag(s) |
| 153 | zephyr_compile_options(${OPTIMIZATION_FLAG}) |
| 154 | |
Mark Ruvald Pedersen | 63df409 | 2019-02-18 23:54:30 +0100 | [diff] [blame] | 155 | # @Intent: Obtain compiler specific flags related to C++ that are not influenced by kconfig |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 156 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,required>>) |
Benoit Leforestier | 26e0f9a | 2018-10-23 18:20:51 +0200 | [diff] [blame] | 157 | |
Mark Ruvald Pedersen | 63df409 | 2019-02-18 23:54:30 +0100 | [diff] [blame] | 158 | # @Intent: Obtain compiler specific flags for compiling under different ISO standards of C++ |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 159 | if(CONFIG_CPLUSPLUS) |
| 160 | # From kconfig choice, pick a single dialect. |
| 161 | # Kconfig choice ensures only one of these CONFIG_STD_CPP* is set. |
| 162 | if(CONFIG_STD_CPP98) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 163 | set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp98>) |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 164 | elseif(CONFIG_STD_CPP11) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 165 | set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp11>) # Default in kconfig |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 166 | elseif(CONFIG_STD_CPP14) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 167 | set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp14>) |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 168 | elseif(CONFIG_STD_CPP17) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 169 | set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp17>) |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 170 | elseif(CONFIG_STD_CPP2A) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 171 | set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp2a>) |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 172 | else() |
| 173 | assert(0 "Unreachable code. Expected C++ standard to have been chosen. See Kconfig.zephyr.") |
| 174 | endif() |
Benoit Leforestier | 26e0f9a | 2018-10-23 18:20:51 +0200 | [diff] [blame] | 175 | |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 176 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${STD_CPP_DIALECT_FLAGS}>) |
Ulf Magnusson | 9b6c2f4 | 2019-05-15 23:01:58 +0200 | [diff] [blame] | 177 | endif() |
Mark Ruvald Pedersen | 63df409 | 2019-02-18 23:54:30 +0100 | [diff] [blame] | 178 | |
| 179 | if(NOT CONFIG_EXCEPTIONS) |
| 180 | # @Intent: Obtain compiler specific flags related to C++ Exceptions |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 181 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,no_exceptions>>) |
Mark Ruvald Pedersen | 63df409 | 2019-02-18 23:54:30 +0100 | [diff] [blame] | 182 | endif() |
| 183 | |
| 184 | if(NOT CONFIG_RTTI) |
| 185 | # @Intent: Obtain compiler specific flags related to C++ Run Time Type Information |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 186 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,no_rtti>>) |
Mark Ruvald Pedersen | 63df409 | 2019-02-18 23:54:30 +0100 | [diff] [blame] | 187 | endif() |
| 188 | |
Andy Ross | fe04adf | 2019-02-27 11:53:18 -0800 | [diff] [blame] | 189 | if(CONFIG_MISRA_SANE) |
Danny Oerndrup | 8e5a95e | 2019-05-16 12:53:58 +0200 | [diff] [blame] | 190 | # @Intent: Obtain toolchain compiler flags relating to MISRA. |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 191 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_error_misra_sane>>) |
| 192 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_error_misra_sane>>) |
Andy Ross | fe04adf | 2019-02-27 11:53:18 -0800 | [diff] [blame] | 193 | endif() |
| 194 | |
Flavio Ceolin | b587e8d | 2020-08-26 09:48:33 -0700 | [diff] [blame] | 195 | # This is intend to be temporary. Once we have fixed the violations that |
| 196 | # prevents build Zephyr, these flags shall be part of the default flags. |
| 197 | if(CONFIG_CODING_GUIDELINE_CHECK) |
| 198 | # @Intent: Obtain toolchain compiler flags relating to coding guideline |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 199 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_error_coding_guideline>>) |
Flavio Ceolin | b587e8d | 2020-08-26 09:48:33 -0700 | [diff] [blame] | 200 | endif() |
| 201 | |
Danny Oerndrup | 4ddbc00 | 2019-06-11 13:55:53 +0200 | [diff] [blame] | 202 | # @Intent: Set compiler specific macro inclusion of AUTOCONF_H |
Torsten Rasmussen | f109e68 | 2020-08-13 15:49:46 +0200 | [diff] [blame] | 203 | zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${AUTOCONF_H}") |
Danny Oerndrup | 4ddbc00 | 2019-06-11 13:55:53 +0200 | [diff] [blame] | 204 | |
Danny Oerndrup | faa72b7 | 2019-06-11 15:56:57 +0200 | [diff] [blame] | 205 | # @Intent: Set compiler specific flag for bare metal freestanding option |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 206 | zephyr_compile_options($<TARGET_PROPERTY:compiler,freestanding>) |
Danny Oerndrup | faa72b7 | 2019-06-11 15:56:57 +0200 | [diff] [blame] | 207 | |
Danny Oerndrup | e34ed7c | 2019-06-12 14:56:46 +0200 | [diff] [blame] | 208 | # @Intent: Set compiler specific flag for tentative definitions, no-common |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 209 | zephyr_compile_options($<TARGET_PROPERTY:compiler,no_common>) |
Danny Oerndrup | e34ed7c | 2019-06-12 14:56:46 +0200 | [diff] [blame] | 210 | |
Danny Oerndrup | e0569ac | 2019-07-23 09:00:55 +0200 | [diff] [blame] | 211 | # @Intent: Set compiler specific flag for production of debug information |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 212 | zephyr_compile_options($<TARGET_PROPERTY:compiler,debug>) |
Danny Oerndrup | e0569ac | 2019-07-23 09:00:55 +0200 | [diff] [blame] | 213 | |
Arvin Farahmand | e430b7b | 2021-04-15 11:20:10 -0400 | [diff] [blame] | 214 | if(CONFIG_COMPILER_COLOR_DIAGNOSTICS) |
Arvin Farahmand | b8f5968 | 2021-04-15 11:20:10 -0400 | [diff] [blame] | 215 | # @Intent: Set compiler specific flag for diagnostic messages |
| 216 | zephyr_compile_options($<TARGET_PROPERTY:compiler,diagnostic>) |
| 217 | endif() |
| 218 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 219 | zephyr_compile_options( |
Rajavardhan Gundi | 08172cd | 2017-12-12 23:29:37 +0530 | [diff] [blame] | 220 | ${TOOLCHAIN_C_FLAGS} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 221 | ) |
| 222 | |
Mark Ruvald Pedersen | cb0fd45 | 2019-01-30 21:48:25 +0100 | [diff] [blame] | 223 | # @Intent: Obtain compiler specific flags related to assembly |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 224 | # ToDo: Remember to get feedback from Oticon on this, as they might use the `ASM_BASE_FLAG` since this is done this way. |
| 225 | zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:asm,required>>) |
Mark Ruvald Pedersen | cb0fd45 | 2019-01-30 21:48:25 +0100 | [diff] [blame] | 226 | |
Nicolas Pitre | b86aa65 | 2019-07-02 16:22:04 -0400 | [diff] [blame] | 227 | # @Intent: Enforce standard integer type correspondance to match Zephyr usage. |
| 228 | # (must be after compiler specific flags) |
Torsten Rasmussen | f109e68 | 2020-08-13 15:49:46 +0200 | [diff] [blame] | 229 | zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${ZEPHYR_BASE}/include/toolchain/zephyr_stdint.h") |
Nicolas Pitre | b86aa65 | 2019-07-02 16:22:04 -0400 | [diff] [blame] | 230 | |
Mark Ruvald Pedersen | cb0fd45 | 2019-01-30 21:48:25 +0100 | [diff] [blame] | 231 | # Common toolchain-agnostic assembly flags |
| 232 | zephyr_compile_options( |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 233 | $<$<COMPILE_LANGUAGE:ASM>:-D_ASMLANGUAGE> |
| 234 | ) |
| 235 | |
Mark Ruvald Pedersen | 1f01325 | 2019-04-25 15:46:11 +0200 | [diff] [blame] | 236 | # @Intent: Set fundamental linker specific flags |
| 237 | toolchain_ld_base() |
Aurelien Jarno | c6727d4 | 2018-11-26 13:48:34 +0100 | [diff] [blame] | 238 | |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 239 | toolchain_ld_force_undefined_symbols( |
| 240 | _OffsetAbsSyms |
| 241 | _ConfigAbsSyms |
| 242 | ) |
| 243 | |
Alberto Escolar Piedras | 76f76441 | 2017-10-03 16:31:55 +0200 | [diff] [blame] | 244 | if(NOT CONFIG_NATIVE_APPLICATION) |
Mark Ruvald Pedersen | 65f02c0 | 2019-04-25 16:31:30 +0200 | [diff] [blame] | 245 | # @Intent: Set linker specific flags for bare metal target |
| 246 | toolchain_ld_baremetal() |
Alberto Escolar Piedras | 76f76441 | 2017-10-03 16:31:55 +0200 | [diff] [blame] | 247 | endif() |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 248 | |
Benoit Leforestier | 26e0f9a | 2018-10-23 18:20:51 +0200 | [diff] [blame] | 249 | if(CONFIG_LIB_CPLUSPLUS) |
Mark Ruvald Pedersen | 3db09aa | 2019-04-26 08:43:04 +0200 | [diff] [blame] | 250 | # @Intent: Set linker specific flags for C++ |
| 251 | toolchain_ld_cpp() |
Benoit Leforestier | 26e0f9a | 2018-10-23 18:20:51 +0200 | [diff] [blame] | 252 | endif() |
| 253 | |
Danny Oerndrup | 8eaa906 | 2019-05-16 12:49:31 +0200 | [diff] [blame] | 254 | # @Intent: Add the basic toolchain warning flags |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 255 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_base>>) |
| 256 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_base>>) |
Danny Oerndrup | bdb229f | 2019-05-06 15:19:27 +0200 | [diff] [blame] | 257 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 258 | # ========================================================================== |
| 259 | # |
| 260 | # cmake -DW=... settings |
| 261 | # |
| 262 | # W=1 - warnings that may be relevant and does not occur too often |
| 263 | # W=2 - warnings that occur quite often but may still be relevant |
| 264 | # W=3 - the more obscure warnings, can most likely be ignored |
| 265 | # ========================================================================== |
Danny Oerndrup | 8eaa906 | 2019-05-16 12:49:31 +0200 | [diff] [blame] | 266 | # @Intent: Add cmake -DW toolchain supported warnings, if any |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 267 | if(W MATCHES "1") |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 268 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_dw_1>>) |
| 269 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_1>>) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 270 | endif() |
| 271 | |
| 272 | if(W MATCHES "2") |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 273 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_dw_2>>) |
| 274 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_2>>) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 275 | endif() |
| 276 | |
| 277 | if(W MATCHES "3") |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 278 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_dw_3>>) |
| 279 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_3>>) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 280 | endif() |
| 281 | |
Danny Oerndrup | 8eaa906 | 2019-05-16 12:49:31 +0200 | [diff] [blame] | 282 | # @Intent: Add extended, more specific, toolchain warning flags |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 283 | zephyr_compile_options($<TARGET_PROPERTY:compiler,warning_extended>) |
Benoit Leforestier | 04dad59 | 2019-01-25 13:57:03 +0100 | [diff] [blame] | 284 | |
Danny Oerndrup | 025ffa2 | 2019-05-16 12:58:40 +0200 | [diff] [blame] | 285 | # @Intent: Trigger an error when a declaration does not specify a type |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 286 | zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warning_error_implicit_int>>) |
| 287 | zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_error_implicit_int>>) |
Danny Oerndrup | 025ffa2 | 2019-05-16 12:58:40 +0200 | [diff] [blame] | 288 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 289 | # Allow the user to inject options when calling cmake, e.g. |
| 290 | # 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..' |
Sebastian Bøe | 9f59045 | 2017-11-10 12:22:23 +0100 | [diff] [blame] | 291 | include(cmake/extra_flags.cmake) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 292 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 293 | zephyr_cc_option(-fno-asynchronous-unwind-tables) |
| 294 | zephyr_cc_option(-fno-pie) |
| 295 | zephyr_cc_option(-fno-pic) |
| 296 | zephyr_cc_option(-fno-strict-overflow) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 297 | |
Daniel Leung | 02b2035 | 2020-09-28 11:27:11 -0700 | [diff] [blame] | 298 | if(CONFIG_THREAD_LOCAL_STORAGE) |
| 299 | # Only support local exec TLS model at this point. |
| 300 | zephyr_cc_option(-ftls-model=local-exec) |
| 301 | endif() |
| 302 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 303 | if(CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT) |
| 304 | if(CONFIG_OMIT_FRAME_POINTER) |
| 305 | zephyr_cc_option(-fomit-frame-pointer) |
| 306 | else() |
| 307 | zephyr_cc_option(-fno-omit-frame-pointer) |
| 308 | endif() |
| 309 | endif() |
| 310 | |
Sebastian Bøe | 244451b | 2019-02-27 08:28:25 +0100 | [diff] [blame] | 311 | separate_arguments(COMPILER_OPT_AS_LIST UNIX_COMMAND ${CONFIG_COMPILER_OPT}) |
| 312 | zephyr_compile_options(${COMPILER_OPT_AS_LIST}) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 313 | |
| 314 | # TODO: Include arch compiler options at this point. |
| 315 | |
Danny Oerndrup | cbbbdea | 2019-05-06 15:21:58 +0200 | [diff] [blame] | 316 | if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") |
| 317 | # GCC assumed |
| 318 | zephyr_cc_option(-fno-reorder-functions) |
Rajavardhan Gundi | 08172cd | 2017-12-12 23:29:37 +0530 | [diff] [blame] | 319 | |
Anas Nashif | 7ee8bb9 | 2018-02-11 14:36:21 -0600 | [diff] [blame] | 320 | if(NOT ${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "xcc") |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 321 | zephyr_cc_option(-fno-defer-pop) |
| 322 | endif() |
| 323 | endif() |
| 324 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 325 | zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage) |
| 326 | |
Marc Herbert | 28a5657 | 2019-04-11 16:34:04 -0700 | [diff] [blame] | 327 | # If the compiler supports it, strip the ${ZEPHYR_BASE} prefix from the |
| 328 | # __FILE__ macro used in __ASSERT*, in the |
| 329 | # .noinit."/home/joe/zephyr/fu/bar.c" section names and in any |
| 330 | # application code. This saves some memory, stops leaking user locations |
| 331 | # in binaries, makes failure logs more deterministic and most |
| 332 | # importantly makes builds more deterministic |
Marc Herbert | f67dcdb | 2019-05-31 15:28:38 -0700 | [diff] [blame] | 333 | |
Marc Herbert | eddbf3c | 2019-06-11 16:57:37 -0700 | [diff] [blame] | 334 | # If several match then the last one wins. This matters for instances |
| 335 | # like tests/ and samples/: they're inside all of them! Then let's |
| 336 | # strip as little as possible. |
Marc Herbert | f67dcdb | 2019-05-31 15:28:38 -0700 | [diff] [blame] | 337 | zephyr_cc_option(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR) |
| 338 | zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE) |
Marc Herbert | eddbf3c | 2019-06-11 16:57:37 -0700 | [diff] [blame] | 339 | if(WEST_TOPDIR) |
| 340 | zephyr_cc_option(-fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR) |
| 341 | endif() |
Marc Herbert | 28a5657 | 2019-04-11 16:34:04 -0700 | [diff] [blame] | 342 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 343 | # TODO: Archiver arguments |
| 344 | # ar_option(D) |
| 345 | |
Håkon Øye Amundsen | d6551b5 | 2018-11-29 09:08:08 +0000 | [diff] [blame] | 346 | # Declare MPU userspace dependencies before the linker scripts to make |
| 347 | # sure the order of dependencies are met |
Andrew Boie | 41f6011 | 2019-01-31 15:53:24 -0800 | [diff] [blame] | 348 | if(CONFIG_USERSPACE) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 349 | set(APP_SMEM_ALIGNED_DEP app_smem_aligned_linker) |
| 350 | set(APP_SMEM_UNALIGNED_DEP app_smem_unaligned_linker) |
Håkon Øye Amundsen | d6551b5 | 2018-11-29 09:08:08 +0000 | [diff] [blame] | 351 | endif() |
| 352 | |
Daniel Leung | 1117169 | 2021-03-18 14:00:07 -0700 | [diff] [blame] | 353 | if(CONFIG_USERSPACE) |
| 354 | set(KOBJECT_LINKER_DEP kobject_linker) |
| 355 | endif() |
| 356 | |
Håkon Øye Amundsen | a449439 | 2018-11-29 09:14:27 +0000 | [diff] [blame] | 357 | get_property(TOPT GLOBAL PROPERTY TOPT) |
Oleg Zhurakivskyy | 2211935 | 2019-03-08 11:29:33 +0200 | [diff] [blame] | 358 | set_ifndef( TOPT -Wl,-T) # clang doesn't pick -T for some reason and complains, |
| 359 | # while -Wl,-T works for both, gcc and clang |
Håkon Øye Amundsen | a449439 | 2018-11-29 09:14:27 +0000 | [diff] [blame] | 360 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 361 | if(CONFIG_HAVE_CUSTOM_LINKER_SCRIPT) |
| 362 | set(LINKER_SCRIPT ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT}) |
Sebastian Bøe | c1aa9d1 | 2018-04-12 14:48:05 +0200 | [diff] [blame] | 363 | if(NOT EXISTS ${LINKER_SCRIPT}) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 364 | set(LINKER_SCRIPT ${CONFIG_CUSTOM_LINKER_SCRIPT}) |
Sebastian Bøe | c1aa9d1 | 2018-04-12 14:48:05 +0200 | [diff] [blame] | 365 | assert_exists(CONFIG_CUSTOM_LINKER_SCRIPT) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 366 | endif() |
| 367 | else() |
| 368 | # Try a board specific linker file |
| 369 | set(LINKER_SCRIPT ${BOARD_DIR}/linker.ld) |
| 370 | if(NOT EXISTS ${LINKER_SCRIPT}) |
| 371 | # If not available, try an SoC specific linker file |
Anas Nashif | 96455d5 | 2018-09-04 14:34:06 -0500 | [diff] [blame] | 372 | set(LINKER_SCRIPT ${SOC_DIR}/${ARCH}/${SOC_PATH}/linker.ld) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 373 | endif() |
| 374 | endif() |
| 375 | |
| 376 | if(NOT EXISTS ${LINKER_SCRIPT}) |
| 377 | message(FATAL_ERROR "Could not find linker script: '${LINKER_SCRIPT}'. Corrupted configuration?") |
| 378 | endif() |
| 379 | |
| 380 | configure_file(version.h.in ${PROJECT_BINARY_DIR}/include/generated/version.h) |
| 381 | |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 382 | # Error-out when the deprecated naming convention is found (until |
| 383 | # after 1.14.0 has been released) |
| 384 | foreach(path |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 385 | ${BOARD_DIR}/dts.fixup |
| 386 | ${PROJECT_SOURCE_DIR}/soc/${ARCH}/${SOC_PATH}/dts.fixup |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 387 | ${APPLICATION_SOURCE_DIR}/dts.fixup |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 388 | ) |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 389 | if(EXISTS ${path}) |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 390 | message(FATAL_ERROR |
| 391 | "A deprecated filename has been detected. Porting is required." |
| 392 | "The file '${path}' exists, but it should be named dts_fixup.h instead." |
| 393 | "See https://github.com/zephyrproject-rtos/zephyr/pull/10352 for more details" |
| 394 | ) |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 395 | endif() |
| 396 | endforeach() |
| 397 | |
| 398 | set_ifndef( DTS_BOARD_FIXUP_FILE ${BOARD_DIR}/dts_fixup.h) |
| 399 | set_ifndef( DTS_SOC_FIXUP_FILE ${SOC_DIR}/${ARCH}/${SOC_PATH}/dts_fixup.h) |
| 400 | set( DTS_APP_FIXUP_FILE ${APPLICATION_SOURCE_DIR}/dts_fixup.h) |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 401 | |
Ulf Magnusson | 4e85006 | 2020-01-16 13:29:53 +0100 | [diff] [blame] | 402 | set_ifndef(DTS_CAT_OF_FIXUP_FILES ${ZEPHYR_BINARY_DIR}/include/generated/devicetree_fixups.h) |
Sebastian Bøe | 361fdaa | 2019-01-28 13:40:50 +0100 | [diff] [blame] | 403 | |
| 404 | # Concatenate the fixups into a single header file for easy |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 405 | # #include'ing |
Ulf Magnusson | 4e85006 | 2020-01-16 13:29:53 +0100 | [diff] [blame] | 406 | file(WRITE ${DTS_CAT_OF_FIXUP_FILES} "/* May only be included by devicetree.h */\n\n") |
Martí Bolívar | 21c7d42 | 2020-05-08 16:06:48 -0700 | [diff] [blame] | 407 | set(DISCOVERED_FIXUP_FILES) |
Sebastian Bøe | 361fdaa | 2019-01-28 13:40:50 +0100 | [diff] [blame] | 408 | foreach(fixup_file |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 409 | ${DTS_BOARD_FIXUP_FILE} |
| 410 | ${DTS_SOC_FIXUP_FILE} |
| 411 | ${DTS_APP_FIXUP_FILE} |
| 412 | ${shield_dts_fixups} |
| 413 | ) |
Sebastian Bøe | 361fdaa | 2019-01-28 13:40:50 +0100 | [diff] [blame] | 414 | if(EXISTS ${fixup_file}) |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 415 | file(READ ${fixup_file} contents) |
| 416 | file(APPEND ${DTS_CAT_OF_FIXUP_FILES} "${contents}") |
Martí Bolívar | 21c7d42 | 2020-05-08 16:06:48 -0700 | [diff] [blame] | 417 | string(APPEND DISCOVERED_FIXUP_FILES "- ${fixup_file}\n") |
Sebastian Bøe | c23cc26 | 2018-10-09 16:03:29 +0200 | [diff] [blame] | 418 | endif() |
| 419 | endforeach() |
| 420 | |
Martí Bolívar | 21c7d42 | 2020-05-08 16:06:48 -0700 | [diff] [blame] | 421 | if (DISCOVERED_FIXUP_FILES) |
| 422 | message(WARNING "One or more dts_fixup.h files detected:\n${DISCOVERED_FIXUP_FILES}Use of these files is deprecated; use the devicetree.h API instead.") |
| 423 | endif() |
| 424 | |
Sebastian Bøe | 6f946e2 | 2018-01-09 10:52:57 +0100 | [diff] [blame] | 425 | # Unfortunately, the order in which CMakeLists.txt code is processed |
| 426 | # matters so we need to be careful about how we order the processing |
| 427 | # of subdirectories. One example is "Compiler flags added late in the |
| 428 | # build are not exported to external build systems #5605"; when we |
| 429 | # integrate with an external build system we read out all compiler |
| 430 | # flags when the external project is created. So an external project |
| 431 | # defined in subsys or ext will not get global flags added by drivers/ |
| 432 | # or tests/ as the subdirectories are ordered now. |
| 433 | # |
| 434 | # Another example of when the order matters is the reading and writing |
| 435 | # of global properties such as ZEPHYR_LIBS or |
| 436 | # GENERATED_KERNEL_OBJECT_FILES. |
| 437 | # |
| 438 | # Arch is placed early because it defines important compiler flags |
| 439 | # that must be exported to external build systems defined in |
| 440 | # e.g. subsys/. |
| 441 | add_subdirectory(arch) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 442 | add_subdirectory(lib) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 443 | # We use include instead of add_subdirectory to avoid creating a new directory scope. |
| 444 | # This is because source file properties are directory scoped, including the GENERATED |
| 445 | # property which is set implicitly for custom command outputs |
| 446 | include(misc/generated/CMakeLists.txt) |
Anas Nashif | 3d1252f | 2018-09-03 15:20:14 -0500 | [diff] [blame] | 447 | |
Erwan Gouriou | ba31cb5 | 2018-09-13 16:25:53 +0200 | [diff] [blame] | 448 | if(EXISTS ${SOC_DIR}/${ARCH}/CMakeLists.txt) |
Anas Nashif | 96455d5 | 2018-09-04 14:34:06 -0500 | [diff] [blame] | 449 | add_subdirectory(${SOC_DIR}/${ARCH} soc/${ARCH}) |
Anas Nashif | 3d1252f | 2018-09-03 15:20:14 -0500 | [diff] [blame] | 450 | else() |
Anas Nashif | 96455d5 | 2018-09-04 14:34:06 -0500 | [diff] [blame] | 451 | add_subdirectory(${SOC_DIR}/${ARCH}/${SOC_PATH} soc/${ARCH}/${SOC_PATH}) |
Anas Nashif | 3d1252f | 2018-09-03 15:20:14 -0500 | [diff] [blame] | 452 | endif() |
| 453 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 454 | add_subdirectory(boards) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 455 | add_subdirectory(subsys) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 456 | add_subdirectory(drivers) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 457 | |
Torsten Rasmussen | bd7569f | 2019-03-19 10:38:18 +0100 | [diff] [blame] | 458 | # Include zephyr modules generated CMake file. |
Torsten Rasmussen | 2fc062b | 2020-08-24 11:01:04 +0200 | [diff] [blame] | 459 | foreach(module_name ${ZEPHYR_MODULE_NAMES}) |
| 460 | # Note the second, binary_dir parameter requires the added |
| 461 | # subdirectory to have its own, local cmake target(s). If not then |
| 462 | # this binary_dir is created but stays empty. Object files land in |
| 463 | # the main binary dir instead. |
| 464 | # https://cmake.org/pipermail/cmake/2019-June/069547.html |
Torsten Rasmussen | 3d88083 | 2021-01-19 12:01:38 +0100 | [diff] [blame] | 465 | zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name}) |
Torsten Rasmussen | ab7ec17 | 2020-08-25 13:32:33 +0200 | [diff] [blame] | 466 | if(NOT ${ZEPHYR_${MODULE_NAME_UPPER}_CMAKE_DIR} STREQUAL "") |
| 467 | set(ZEPHYR_CURRENT_MODULE_DIR ${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR}) |
| 468 | set(ZEPHYR_CURRENT_CMAKE_DIR ${ZEPHYR_${MODULE_NAME_UPPER}_CMAKE_DIR}) |
| 469 | add_subdirectory(${ZEPHYR_CURRENT_CMAKE_DIR} ${CMAKE_BINARY_DIR}/modules/${module_name}) |
| 470 | endif() |
Torsten Rasmussen | 2fc062b | 2020-08-24 11:01:04 +0200 | [diff] [blame] | 471 | endforeach() |
Torsten Rasmussen | ab7ec17 | 2020-08-25 13:32:33 +0200 | [diff] [blame] | 472 | # Done processing modules, clear ZEPHYR_CURRENT_MODULE_DIR and ZEPHYR_CURRENT_CMAKE_DIR. |
Torsten Rasmussen | 2fc062b | 2020-08-24 11:01:04 +0200 | [diff] [blame] | 473 | set(ZEPHYR_CURRENT_MODULE_DIR) |
Torsten Rasmussen | ab7ec17 | 2020-08-25 13:32:33 +0200 | [diff] [blame] | 474 | set(ZEPHYR_CURRENT_CMAKE_DIR) |
Torsten Rasmussen | 7e9d1bd | 2019-02-05 10:36:22 +0100 | [diff] [blame] | 475 | |
Andrew Boie | 5960119 | 2020-05-29 13:24:51 -0700 | [diff] [blame] | 476 | set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h) |
| 477 | set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json) |
| 478 | set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json) |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 479 | |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 480 | # The syscalls subdirs txt file is constructed by python containing a list of folders to use for |
| 481 | # dependency handling, including empty folders. |
| 482 | # Windows: The list is used to specify DIRECTORY list with CMAKE_CONFIGURE_DEPENDS attribute. |
| 483 | # Other OS: The list will update whenever a file is added/removed/modified and ensure a re-build. |
| 484 | set(syscalls_subdirs_txt ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_subdirs.txt) |
| 485 | |
| 486 | # As syscalls_subdirs_txt is updated whenever a file is modified, this file can not be used for |
| 487 | # monitoring of added / removed folders. A trigger file is thus used for correct dependency |
| 488 | # handling. The trigger file will update when a folder is added / removed. |
| 489 | set(syscalls_subdirs_trigger ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_subdirs.trigger) |
| 490 | |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 491 | if(NOT (${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows)) |
| 492 | set(syscalls_links --create-links ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_links) |
| 493 | endif() |
| 494 | |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 495 | # When running CMake it must be ensured that all dependencies are correctly acquired. |
| 496 | execute_process( |
| 497 | COMMAND |
| 498 | ${PYTHON_EXECUTABLE} |
Alex Tereschenko | 3c1a78e | 2018-06-14 20:21:18 +0200 | [diff] [blame] | 499 | ${ZEPHYR_BASE}/scripts/subfolder_list.py |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 500 | --directory ${ZEPHYR_BASE}/include # Walk this directory |
| 501 | --out-file ${syscalls_subdirs_txt} # Write file with discovered folder |
| 502 | --trigger ${syscalls_subdirs_trigger} # Trigger file that is used for json generation |
| 503 | ${syscalls_links} # If defined, create symlinks for dependencies |
| 504 | ) |
Carles Cufi | 3ad1f27 | 2019-07-18 10:38:25 +0200 | [diff] [blame] | 505 | file(STRINGS ${syscalls_subdirs_txt} PARSE_SYSCALLS_PATHS_DEPENDS ENCODING UTF-8) |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 506 | |
| 507 | if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows) |
| 508 | # On windows only adding/removing files or folders will be reflected in depends. |
| 509 | # Hence adding a file requires CMake to re-run to add this file to the file list. |
| 510 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARSE_SYSCALLS_PATHS_DEPENDS}) |
| 511 | |
| 512 | # Also On Windows each header file must be monitored as file modifications are not reflected |
| 513 | # on directory level. |
Alex Tereschenko | 3c1a78e | 2018-06-14 20:21:18 +0200 | [diff] [blame] | 514 | file(GLOB_RECURSE PARSE_SYSCALLS_HEADER_DEPENDS ${ZEPHYR_BASE}/include/*.h) |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 515 | else() |
| 516 | # The syscall parsing depends on the folders in order to detect add/removed/modified files. |
| 517 | # When a folder is removed, CMake will try to find a target that creates that dependency. |
| 518 | # This command sets up the target for CMake to find. |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 519 | # Without this code, CMake will fail with the following error: |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 520 | # <folder> needed by '<target>', missing and no known rule to make it |
| 521 | # when a folder is removed. |
| 522 | add_custom_command(OUTPUT ${PARSE_SYSCALLS_PATHS_DEPENDS} |
| 523 | COMMAND ${CMAKE_COMMAND} -E echo "" |
| 524 | COMMENT "Preparing syscall dependency handling" |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 525 | ) |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 526 | |
| 527 | add_custom_command( |
| 528 | OUTPUT |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 529 | ${syscalls_subdirs_trigger} |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 530 | COMMAND |
| 531 | ${PYTHON_EXECUTABLE} |
Alex Tereschenko | 3c1a78e | 2018-06-14 20:21:18 +0200 | [diff] [blame] | 532 | ${ZEPHYR_BASE}/scripts/subfolder_list.py |
| 533 | --directory ${ZEPHYR_BASE}/include # Walk this directory |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 534 | --out-file ${syscalls_subdirs_txt} # Write file with discovered folder |
| 535 | --trigger ${syscalls_subdirs_trigger} # Trigger file that is used for json generation |
| 536 | ${syscalls_links} # If defined, create symlinks for dependencies |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 537 | DEPENDS ${PARSE_SYSCALLS_PATHS_DEPENDS} |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 538 | ) |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 539 | |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 540 | # Ensure subdir file always exists when specifying CMake dependency. |
| 541 | if(NOT EXISTS ${syscalls_subdirs_txt}) |
| 542 | file(WRITE ${syscalls_subdirs_txt} "") |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 543 | endif() |
| 544 | |
| 545 | # On other OS'es, modifying a file is reflected on the folder timestamp and hence detected |
| 546 | # when using depend on directory level. |
| 547 | # Thus CMake only needs to re-run when sub-directories are added / removed, which is indicated |
| 548 | # using a trigger file. |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 549 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt}) |
Torsten Rasmussen | f38e388 | 2018-06-07 15:50:31 +0200 | [diff] [blame] | 550 | endif() |
| 551 | |
Sebastian Bøe | 56f6e35 | 2018-04-30 15:59:16 +0200 | [diff] [blame] | 552 | # syscall declarations are searched for in the SYSCALL_INCLUDE_DIRS |
Adithya Baglody | e67720b | 2018-07-02 14:59:19 +0530 | [diff] [blame] | 553 | if(CONFIG_APPLICATION_DEFINED_SYSCALL) |
Sebastian Bøe | 56f6e35 | 2018-04-30 15:59:16 +0200 | [diff] [blame] | 554 | list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR}) |
Adithya Baglody | e67720b | 2018-07-02 14:59:19 +0530 | [diff] [blame] | 555 | endif() |
| 556 | |
Andrew Boie | c186387 | 2019-11-21 23:11:29 -0800 | [diff] [blame] | 557 | if(CONFIG_ZTEST) |
Sebastian Bøe | 56f6e35 | 2018-04-30 15:59:16 +0200 | [diff] [blame] | 558 | list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include) |
Andrew Boie | c186387 | 2019-11-21 23:11:29 -0800 | [diff] [blame] | 559 | endif() |
| 560 | |
Sebastian Bøe | 56f6e35 | 2018-04-30 15:59:16 +0200 | [diff] [blame] | 561 | foreach(d ${SYSCALL_INCLUDE_DIRS}) |
| 562 | list(APPEND parse_syscalls_include_args |
| 563 | --include ${d} |
| 564 | ) |
| 565 | endforeach() |
| 566 | |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 567 | add_custom_command( |
| 568 | OUTPUT |
| 569 | ${syscalls_json} |
Andrew Boie | 5960119 | 2020-05-29 13:24:51 -0700 | [diff] [blame] | 570 | ${struct_tags_json} |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 571 | COMMAND |
| 572 | ${PYTHON_EXECUTABLE} |
Alex Tereschenko | 3c1a78e | 2018-06-14 20:21:18 +0200 | [diff] [blame] | 573 | ${ZEPHYR_BASE}/scripts/parse_syscalls.py |
Adithya Baglody | e67720b | 2018-07-02 14:59:19 +0530 | [diff] [blame] | 574 | --include ${ZEPHYR_BASE}/include # Read files from this dir |
Andrew Boie | fed960b | 2020-05-29 13:33:12 -0700 | [diff] [blame] | 575 | --include ${ZEPHYR_BASE}/drivers # For net sockets |
| 576 | --include ${ZEPHYR_BASE}/subsys/net # More net sockets |
Sebastian Bøe | 56f6e35 | 2018-04-30 15:59:16 +0200 | [diff] [blame] | 577 | ${parse_syscalls_include_args} # Read files from these dirs also |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 578 | --json-file ${syscalls_json} # Write this file |
Andrew Boie | 5960119 | 2020-05-29 13:24:51 -0700 | [diff] [blame] | 579 | --tag-struct-file ${struct_tags_json} # Write subsystem list to this file |
Torsten Rasmussen | 080e32e | 2018-06-14 22:27:17 +0200 | [diff] [blame] | 580 | DEPENDS ${syscalls_subdirs_trigger} ${PARSE_SYSCALLS_HEADER_DEPENDS} |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 581 | ) |
| 582 | |
Joakim Andersson | 08d2f48 | 2020-08-04 18:26:43 +0200 | [diff] [blame] | 583 | add_custom_target(${SYSCALL_LIST_H_TARGET} DEPENDS ${syscall_list_h}) |
Torsten Rasmussen | c4c79f5 | 2021-02-09 22:27:59 +0100 | [diff] [blame] | 584 | |
| 585 | # This only works for CMake version >=3.15, but as the property is ignored on |
| 586 | # older CMake versions there is no reason to check for version. |
| 587 | set_property(TARGET ${SYSCALL_LIST_H_TARGET} |
| 588 | APPEND PROPERTY |
| 589 | ADDITIONAL_CLEAN_FILES |
| 590 | ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscalls |
| 591 | ) |
| 592 | |
| 593 | # Only works with make. |
| 594 | if(${CMAKE_VERSION} VERSION_LESS 3.15) |
| 595 | set_property(DIRECTORY |
| 596 | APPEND PROPERTY |
| 597 | ADDITIONAL_MAKE_CLEAN_FILES |
| 598 | ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscalls |
| 599 | ) |
| 600 | endif() |
| 601 | |
Andrew Boie | c1c54b1 | 2020-03-16 12:48:00 -0700 | [diff] [blame] | 602 | add_custom_target(${PARSE_SYSCALLS_TARGET} |
Joakim Andersson | 08d2f48 | 2020-08-04 18:26:43 +0200 | [diff] [blame] | 603 | DEPENDS |
| 604 | ${syscalls_json} |
Joakim Andersson | d268f82 | 2020-08-04 18:31:48 +0200 | [diff] [blame] | 605 | ${struct_tags_json} |
Joakim Andersson | 08d2f48 | 2020-08-04 18:26:43 +0200 | [diff] [blame] | 606 | ) |
Andrew Boie | 9ff64bb | 2019-11-05 09:39:05 -0800 | [diff] [blame] | 607 | |
| 608 | # 64-bit systems do not require special handling of 64-bit system call |
| 609 | # parameters or return values, indicate this to the system call boilerplate |
| 610 | # generation script. |
| 611 | if(CONFIG_64BIT) |
| 612 | set(SYSCALL_LONG_REGISTERS_ARG --long-registers) |
| 613 | endif() |
| 614 | |
Andy Ross | cfeb07e | 2020-03-05 21:14:02 -0800 | [diff] [blame] | 615 | if(CONFIG_TIMEOUT_64BIT) |
| 616 | set(SYSCALL_SPLIT_TIMEOUT_ARG --split-type k_timeout_t) |
| 617 | endif() |
| 618 | |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 619 | add_custom_command(OUTPUT include/generated/syscall_dispatch.c ${syscall_list_h} |
| 620 | # Also, some files are written to include/generated/syscalls/ |
| 621 | COMMAND |
| 622 | ${PYTHON_EXECUTABLE} |
Alex Tereschenko | 3c1a78e | 2018-06-14 20:21:18 +0200 | [diff] [blame] | 623 | ${ZEPHYR_BASE}/scripts/gen_syscalls.py |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 624 | --json-file ${syscalls_json} # Read this file |
| 625 | --base-output include/generated/syscalls # Write to this dir |
| 626 | --syscall-dispatch include/generated/syscall_dispatch.c # Write this file |
Andrew Boie | 353acf4 | 2018-07-23 18:10:15 -0700 | [diff] [blame] | 627 | --syscall-list ${syscall_list_h} |
Andrew Boie | 9ff64bb | 2019-11-05 09:39:05 -0800 | [diff] [blame] | 628 | ${SYSCALL_LONG_REGISTERS_ARG} |
Andy Ross | cfeb07e | 2020-03-05 21:14:02 -0800 | [diff] [blame] | 629 | ${SYSCALL_SPLIT_TIMEOUT_ARG} |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 630 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
Andrew Boie | c1c54b1 | 2020-03-16 12:48:00 -0700 | [diff] [blame] | 631 | DEPENDS ${PARSE_SYSCALLS_TARGET} |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 632 | ) |
| 633 | |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 634 | # This is passed into all calls to the gen_kobject_list.py script. |
Andrew Boie | 5960119 | 2020-05-29 13:24:51 -0700 | [diff] [blame] | 635 | set(gen_kobject_list_include_args --include ${struct_tags_json}) |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 636 | |
Leandro Pereira | c200367 | 2018-04-04 13:50:32 -0700 | [diff] [blame] | 637 | set(DRV_VALIDATION ${PROJECT_BINARY_DIR}/include/generated/driver-validation.h) |
| 638 | add_custom_command( |
| 639 | OUTPUT ${DRV_VALIDATION} |
| 640 | COMMAND |
| 641 | ${PYTHON_EXECUTABLE} |
| 642 | ${ZEPHYR_BASE}/scripts/gen_kobject_list.py |
| 643 | --validation-output ${DRV_VALIDATION} |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 644 | ${gen_kobject_list_include_args} |
Leandro Pereira | c200367 | 2018-04-04 13:50:32 -0700 | [diff] [blame] | 645 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 646 | DEPENDS |
| 647 | ${ZEPHYR_BASE}/scripts/gen_kobject_list.py |
Andrew Boie | c1c54b1 | 2020-03-16 12:48:00 -0700 | [diff] [blame] | 648 | ${PARSE_SYSCALLS_TARGET} |
Leandro Pereira | c200367 | 2018-04-04 13:50:32 -0700 | [diff] [blame] | 649 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 650 | ) |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 651 | add_custom_target(${DRIVER_VALIDATION_H_TARGET} DEPENDS ${DRV_VALIDATION}) |
Leandro Pereira | c200367 | 2018-04-04 13:50:32 -0700 | [diff] [blame] | 652 | |
Torsten Rasmussen | d7862cf | 2020-02-12 15:42:09 +0100 | [diff] [blame] | 653 | include(${ZEPHYR_BASE}/cmake/kobj.cmake) |
Leandro Pereira | 39dc7d0 | 2018-04-05 13:59:33 -0700 | [diff] [blame] | 654 | gen_kobj(KOBJ_INCLUDE_PATH) |
Leandro Pereira | c200367 | 2018-04-04 13:50:32 -0700 | [diff] [blame] | 655 | |
Sebastian Bøe | fdac7b3 | 2020-01-23 15:39:17 +0100 | [diff] [blame] | 656 | # Add a pseudo-target that is up-to-date when all generated headers |
| 657 | # are up-to-date. |
| 658 | |
| 659 | add_custom_target(zephyr_generated_headers) |
| 660 | add_dependencies(zephyr_generated_headers |
| 661 | offsets_h |
| 662 | ) |
| 663 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 664 | # Generate offsets.c.obj from offsets.c |
| 665 | # Generate offsets.h from offsets.c.obj |
| 666 | |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 667 | set(OFFSETS_LIB offsets) |
| 668 | |
Klaus Petersen | c66cb76 | 2018-11-15 10:37:46 +0100 | [diff] [blame] | 669 | set(OFFSETS_C_PATH ${ARCH_DIR}/${ARCH}/core/offsets/offsets.c) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 670 | set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/offsets.h) |
| 671 | |
Klaus Petersen | 62e55e5 | 2019-02-04 12:10:57 +0100 | [diff] [blame] | 672 | add_library( ${OFFSETS_LIB} OBJECT ${OFFSETS_C_PATH}) |
Stephanos Ioannidis | 2d74604 | 2019-10-25 00:08:21 +0900 | [diff] [blame] | 673 | target_include_directories(${OFFSETS_LIB} PRIVATE |
| 674 | kernel/include |
| 675 | ${ARCH_DIR}/${ARCH}/include |
| 676 | ) |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 677 | target_link_libraries(${OFFSETS_LIB} zephyr_interface) |
Joakim Andersson | d268f82 | 2020-08-04 18:31:48 +0200 | [diff] [blame] | 678 | add_dependencies(zephyr_interface |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 679 | ${SYSCALL_LIST_H_TARGET} |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 680 | ${DRIVER_VALIDATION_H_TARGET} |
| 681 | ${KOBJ_TYPES_H_TARGET} |
Sebastian Bøe | 13a6840 | 2017-11-20 13:03:55 +0100 | [diff] [blame] | 682 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 683 | |
| 684 | add_custom_command( |
| 685 | OUTPUT ${OFFSETS_H_PATH} |
Carles Cufi | 7d764b3 | 2018-01-11 15:46:44 +0100 | [diff] [blame] | 686 | COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/gen_offset_header.py |
Klaus Petersen | 62e55e5 | 2019-02-04 12:10:57 +0100 | [diff] [blame] | 687 | -i $<TARGET_OBJECTS:${OFFSETS_LIB}> |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 688 | -o ${OFFSETS_H_PATH} |
Sebastian Bøe | 5962aab | 2019-08-15 14:45:59 +0200 | [diff] [blame] | 689 | DEPENDS |
| 690 | ${OFFSETS_LIB} |
| 691 | $<TARGET_OBJECTS:${OFFSETS_LIB}> |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 692 | ) |
Sebastian Bøe | 1b86fb9 | 2019-01-14 16:39:33 +0100 | [diff] [blame] | 693 | add_custom_target(${OFFSETS_H_TARGET} DEPENDS ${OFFSETS_H_PATH}) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 694 | |
Sebastian Bøe | 89516fb | 2017-12-01 15:25:06 +0100 | [diff] [blame] | 695 | zephyr_get_include_directories_for_lang(C ZEPHYR_INCLUDES) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 696 | |
| 697 | add_subdirectory(kernel) |
| 698 | |
| 699 | # Read list content |
| 700 | get_property(ZEPHYR_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_LIBS) |
| 701 | |
| 702 | foreach(zephyr_lib ${ZEPHYR_LIBS_PROPERTY}) |
Torsten Rasmussen | d952004 | 2021-04-14 17:11:39 +0200 | [diff] [blame] | 703 | get_property(lib_type TARGET ${zephyr_lib} PROPERTY TYPE) |
Torsten Rasmussen | d952004 | 2021-04-14 17:11:39 +0200 | [diff] [blame] | 704 | # To prevent CMake failure when a driver is enabled, for example: REGULATOR=y |
| 705 | # we disable any Zephyr libraries without sources and adds the `empty_file.c`. |
| 706 | if(${lib_type} STREQUAL STATIC_LIBRARY |
Torsten Rasmussen | d952004 | 2021-04-14 17:11:39 +0200 | [diff] [blame] | 707 | AND NOT ${zephyr_lib} STREQUAL app |
| 708 | ) |
Torsten Rasmussen | 25578be | 2021-04-23 09:09:49 +0200 | [diff] [blame] | 709 | get_property(source_list TARGET ${zephyr_lib} PROPERTY SOURCES) |
| 710 | get_property(lib_imported TARGET ${zephyr_lib} PROPERTY IMPORTED) |
| 711 | if(NOT source_list |
| 712 | AND NOT ${lib_imported} |
Torsten Rasmussen | d952004 | 2021-04-14 17:11:39 +0200 | [diff] [blame] | 713 | ) |
Torsten Rasmussen | 25578be | 2021-04-23 09:09:49 +0200 | [diff] [blame] | 714 | message(WARNING |
| 715 | "No SOURCES given to Zephyr library: ${zephyr_lib}\nExcluding target from build." |
| 716 | ) |
| 717 | target_sources(${zephyr_lib} PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c) |
| 718 | set_property(TARGET ${zephyr_lib} PROPERTY EXCLUDE_FROM_ALL TRUE) |
| 719 | list(REMOVE_ITEM ZEPHYR_LIBS_PROPERTY ${zephyr_lib}) |
| 720 | continue() |
| 721 | endif() |
Torsten Rasmussen | d952004 | 2021-04-14 17:11:39 +0200 | [diff] [blame] | 722 | endif() |
Torsten Rasmussen | 25578be | 2021-04-23 09:09:49 +0200 | [diff] [blame] | 723 | |
| 724 | # TODO: Could this become an INTERFACE property of zephyr_interface? |
| 725 | add_dependencies(${zephyr_lib} zephyr_generated_headers) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 726 | endforeach() |
| 727 | |
| 728 | get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT) |
| 729 | |
Adithya Baglody | 62e152a | 2018-11-13 15:34:02 +0530 | [diff] [blame] | 730 | if (CONFIG_CODE_DATA_RELOCATION) |
| 731 | set(CODE_RELOCATION_DEP code_relocation_source_lib) |
| 732 | endif() # CONFIG_CODE_DATA_RELOCATION |
Sebastian Bøe | b85dd3c | 2017-12-31 10:39:23 +0100 | [diff] [blame] | 733 | |
Daniel Leung | c745995 | 2021-03-19 12:09:05 -0700 | [diff] [blame] | 734 | # Give the linker script targets all of the include directories so |
| 735 | # that cmake can successfully find the linker scripts' header |
Sebastian Bøe | b1ab501 | 2017-12-14 13:03:23 +0100 | [diff] [blame] | 736 | # dependencies. |
| 737 | zephyr_get_include_directories_for_lang(C |
| 738 | ZEPHYR_INCLUDE_DIRS |
| 739 | STRIP_PREFIX # Don't use a -I prefix |
| 740 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 741 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 742 | if(CONFIG_GEN_ISR_TABLES) |
Rajavardhan Gundi | 08172cd | 2017-12-12 23:29:37 +0530 | [diff] [blame] | 743 | if(CONFIG_GEN_SW_ISR_TABLE) |
| 744 | list(APPEND GEN_ISR_TABLE_EXTRA_ARG --sw-isr-table) |
| 745 | endif() |
| 746 | |
| 747 | if(CONFIG_GEN_IRQ_VECTOR_TABLE) |
| 748 | list(APPEND GEN_ISR_TABLE_EXTRA_ARG --vector-table) |
| 749 | endif() |
| 750 | |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 751 | # isr_tables.c is generated from ${ZEPHYR_PREBUILT_EXECUTABLE} by |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 752 | # gen_isr_tables.py |
| 753 | add_custom_command( |
Torsten Rasmussen | c4c79f5 | 2021-02-09 22:27:59 +0100 | [diff] [blame] | 754 | OUTPUT isr_tables.c isrList.bin |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 755 | COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> |
| 756 | $<TARGET_PROPERTY:bintools,elfconvert_flag> |
| 757 | $<TARGET_PROPERTY:bintools,elfconvert_flag_intarget>${OUTPUT_FORMAT} |
| 758 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary |
| 759 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_only>.intList |
| 760 | $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>$<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> |
| 761 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>isrList.bin |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 762 | $<TARGET_PROPERTY:bintools,elfconvert_flag_final> |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 763 | COMMAND ${PYTHON_EXECUTABLE} |
Carles Cufi | 7d764b3 | 2018-01-11 15:46:44 +0100 | [diff] [blame] | 764 | ${ZEPHYR_BASE}/arch/common/gen_isr_tables.py |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 765 | --output-source isr_tables.c |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 766 | --kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 767 | --intlist isrList.bin |
Yasushi SHOJI | 6fc0d77 | 2018-10-09 18:59:16 +0900 | [diff] [blame] | 768 | $<$<BOOL:${CONFIG_BIG_ENDIAN}>:--big-endian> |
Sebastian Bøe | a55279a | 2018-01-04 14:08:39 +0100 | [diff] [blame] | 769 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--debug> |
Rajavardhan Gundi | 08172cd | 2017-12-12 23:29:37 +0530 | [diff] [blame] | 770 | ${GEN_ISR_TABLE_EXTRA_ARG} |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 771 | DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE} |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 772 | COMMAND_EXPAND_LISTS |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 773 | ) |
| 774 | set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_SOURCE_FILES isr_tables.c) |
| 775 | endif() |
| 776 | |
Morten Priess | a846e72 | 2021-04-21 09:06:02 +0200 | [diff] [blame] | 777 | if(CONFIG_HAS_DTS) |
| 778 | # dev_handles.c is generated from ${ZEPHYR_PREBUILT_EXECUTABLE} by |
| 779 | # gen_handles.py |
| 780 | add_custom_command( |
| 781 | OUTPUT dev_handles.c |
| 782 | COMMAND |
| 783 | ${PYTHON_EXECUTABLE} |
| 784 | ${ZEPHYR_BASE}/scripts/gen_handles.py |
| 785 | --output-source dev_handles.c |
| 786 | --kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> |
| 787 | --zephyr-base ${ZEPHYR_BASE} |
| 788 | DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE} |
| 789 | ) |
| 790 | set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_SOURCE_FILES dev_handles.c) |
| 791 | endif() |
Peter Bigot | d554d34 | 2020-06-30 10:05:35 -0500 | [diff] [blame] | 792 | |
Adithya Baglody | 62e152a | 2018-11-13 15:34:02 +0530 | [diff] [blame] | 793 | if(CONFIG_CODE_DATA_RELOCATION) |
Mark Ruvald Pedersen | 86a3e8f | 2019-05-03 10:33:03 +0200 | [diff] [blame] | 794 | # @Intent: Linker script to relocate .text, data and .bss sections |
| 795 | toolchain_ld_relocation() |
Adithya Baglody | 62e152a | 2018-11-13 15:34:02 +0530 | [diff] [blame] | 796 | endif() |
| 797 | |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 798 | if(CONFIG_USERSPACE) |
Torsten Rasmussen | e37d9e6 | 2020-11-20 18:39:30 +0100 | [diff] [blame] | 799 | zephyr_get_compile_options_for_lang_as_string(C compiler_flags_priv) |
Torsten Rasmussen | e0758c3 | 2020-08-21 19:13:53 +0200 | [diff] [blame] | 800 | string(REPLACE "$<TARGET_PROPERTY:compiler,coverage>" "" |
| 801 | NO_COVERAGE_FLAGS "${compiler_flags_priv}" |
| 802 | ) |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 803 | |
| 804 | get_property(include_dir_in_interface TARGET zephyr_interface |
| 805 | PROPERTY INTERFACE_INCLUDE_DIRECTORIES) |
| 806 | |
| 807 | get_property(sys_include_dir_in_interface TARGET zephyr_interface |
| 808 | PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) |
| 809 | |
| 810 | get_property(compile_definitions_interface TARGET zephyr_interface |
| 811 | PROPERTY INTERFACE_COMPILE_DEFINITIONS) |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 812 | |
Carles Cufi | 7d764b3 | 2018-01-11 15:46:44 +0100 | [diff] [blame] | 813 | set(GEN_KOBJ_LIST ${ZEPHYR_BASE}/scripts/gen_kobject_list.py) |
| 814 | set(PROCESS_GPERF ${ZEPHYR_BASE}/scripts/process_gperf.py) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 815 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 816 | set(KOBJECT_HASH_LIST kobject_hash.gperf) |
| 817 | set(KOBJECT_HASH_OUTPUT_SRC_PRE kobject_hash_preprocessed.c) |
| 818 | set(KOBJECT_HASH_OUTPUT_SRC kobject_hash.c) |
| 819 | set(KOBJECT_HASH_OUTPUT_OBJ kobject_hash.c.obj) |
| 820 | set(KOBJECT_HASH_OUTPUT_OBJ_RENAMED kobject_hash_renamed.o) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 821 | |
| 822 | # Essentially what we are doing here is extracting some information |
| 823 | # out of the nearly finished elf file, generating the source code |
| 824 | # for a hash table based on that information, and then compiling and |
| 825 | # linking the hash table back into a now even more nearly finished |
Marc Herbert | 4a10eea | 2019-04-16 15:39:45 -0700 | [diff] [blame] | 826 | # elf file. More information in gen_kobject_list.py --help. |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 827 | |
| 828 | # Use the script GEN_KOBJ_LIST to scan the kernel binary's |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 829 | # (${ZEPHYR_PREBUILT_EXECUTABLE}) DWARF information to produce a table of kernel |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 830 | # objects (KOBJECT_HASH_LIST) which we will then pass to gperf |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 831 | add_custom_command( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 832 | OUTPUT ${KOBJECT_HASH_LIST} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 833 | COMMAND |
| 834 | ${PYTHON_EXECUTABLE} |
| 835 | ${GEN_KOBJ_LIST} |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 836 | --kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 837 | --gperf-output ${KOBJECT_HASH_LIST} |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 838 | ${gen_kobject_list_include_args} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 839 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
Corey Wharton | ccd15df | 2020-02-29 14:51:42 -0800 | [diff] [blame] | 840 | DEPENDS |
| 841 | ${ZEPHYR_PREBUILT_EXECUTABLE} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 842 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 843 | ) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 844 | add_custom_target( |
| 845 | kobj_hash_list |
| 846 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_LIST} |
| 847 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 848 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 849 | # Use gperf to generate C code (KOBJECT_HASH_OUTPUT_SRC_PRE) which implements a |
| 850 | # perfect hashtable based on KOBJECT_HASH_LIST |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 851 | add_custom_command( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 852 | OUTPUT ${KOBJECT_HASH_OUTPUT_SRC_PRE} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 853 | COMMAND |
| 854 | ${GPERF} |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 855 | --output-file ${KOBJECT_HASH_OUTPUT_SRC_PRE} |
Daniel Leung | 1117169 | 2021-03-18 14:00:07 -0700 | [diff] [blame] | 856 | --multiple-iterations 10 |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 857 | ${KOBJECT_HASH_LIST} |
| 858 | DEPENDS kobj_hash_list ${KOBJECT_HASH_LIST} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 859 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 860 | ) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 861 | add_custom_target( |
| 862 | kobj_hash_output_src_pre |
| 863 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC_PRE} |
| 864 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 865 | |
| 866 | # For our purposes the code/data generated by gperf is not optimal. |
| 867 | # |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 868 | # The script PROCESS_GPERF creates a new c file KOBJECT_HASH_OUTPUT_SRC based on |
| 869 | # KOBJECT_HASH_OUTPUT_SRC_PRE to greatly reduce the amount of code/data generated |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 870 | # since we know we are always working with pointer values |
| 871 | add_custom_command( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 872 | OUTPUT ${KOBJECT_HASH_OUTPUT_SRC} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 873 | COMMAND |
Sebastian Bøe | 1b60070 | 2018-06-21 14:34:42 +0200 | [diff] [blame] | 874 | ${PYTHON_EXECUTABLE} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 875 | ${PROCESS_GPERF} |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 876 | -i ${KOBJECT_HASH_OUTPUT_SRC_PRE} |
| 877 | -o ${KOBJECT_HASH_OUTPUT_SRC} |
Andrew Boie | 2dc2ecf | 2020-03-11 07:13:07 -0700 | [diff] [blame] | 878 | -p "struct z_object" |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 879 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 880 | DEPENDS kobj_hash_output_src_pre ${KOBJECT_HASH_OUTPUT_SRC_PRE} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 881 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 882 | ) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 883 | add_custom_target( |
| 884 | kobj_hash_output_src |
| 885 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC} |
| 886 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 887 | |
| 888 | # We need precise control of where generated text/data ends up in the final |
| 889 | # kernel image. Disable function/data sections and use objcopy to move |
| 890 | # generated data into special section names |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 891 | add_library( |
| 892 | kobj_hash_output_lib |
| 893 | STATIC ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 894 | ) |
| 895 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 896 | set_source_files_properties(${KOBJECT_HASH_OUTPUT_SRC} |
| 897 | PROPERTIES COMPILE_FLAGS |
Andrew Boie | a514898 | 2019-03-14 17:04:11 -0700 | [diff] [blame] | 898 | "${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections") |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 899 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 900 | set_source_files_properties(${KOBJECT_HASH_OUTPUT_SRC} |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 901 | PROPERTIES COMPILE_DEFINITIONS "${compile_definitions_interface}") |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 902 | |
| 903 | # Turn off -ffunction-sections, etc. |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 904 | # NB: Using a library instead of target_compile_options(kobj_hash_output_lib |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 905 | # [...]) because a library's options have precedence |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 906 | add_library(kobj_hash_output_lib_interface INTERFACE) |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 907 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 908 | target_link_libraries(kobj_hash_output_lib kobj_hash_output_lib_interface) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 909 | |
Kumar Gala | 3713ea4 | 2019-03-14 11:50:08 -0500 | [diff] [blame] | 910 | foreach(incl ${include_dir_in_interface}) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 911 | target_include_directories(kobj_hash_output_lib_interface INTERFACE ${incl}) |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 912 | endforeach() |
| 913 | |
Kumar Gala | 3713ea4 | 2019-03-14 11:50:08 -0500 | [diff] [blame] | 914 | foreach(incl ${sys_include_dir_in_interface}) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 915 | target_include_directories(kobj_hash_output_lib_interface SYSTEM INTERFACE ${incl}) |
Kumar Gala | 3713ea4 | 2019-03-14 11:50:08 -0500 | [diff] [blame] | 916 | endforeach() |
Adithya Baglody | 4b3c7b3 | 2018-11-21 14:31:56 +0530 | [diff] [blame] | 917 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 918 | set( |
| 919 | KOBJECT_HASH_OUTPUT_OBJ_PATH |
| 920 | ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/kobj_hash_output_lib.dir/${KOBJECT_HASH_OUTPUT_OBJ} |
| 921 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 922 | |
| 923 | add_custom_command( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 924 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED} |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 925 | COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> |
| 926 | $<TARGET_PROPERTY:bintools,elfconvert_flag> |
| 927 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.data=.kobject_data.data |
| 928 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.text=.kobject_data.text |
| 929 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.rodata=.kobject_data.rodata |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 930 | $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KOBJECT_HASH_OUTPUT_OBJ_PATH} |
| 931 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KOBJECT_HASH_OUTPUT_OBJ_RENAMED} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 932 | $<TARGET_PROPERTY:bintools,elfconvert_flag_final> |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 933 | DEPENDS kobj_hash_output_lib |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 934 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 935 | COMMAND_EXPAND_LISTS |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 936 | ) |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 937 | add_custom_target( |
| 938 | kobj_hash_output_obj_renamed |
| 939 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED} |
| 940 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 941 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 942 | add_library(kobj_hash_output_obj_renamed_lib STATIC IMPORTED GLOBAL) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 943 | set_property( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 944 | TARGET kobj_hash_output_obj_renamed_lib |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 945 | PROPERTY |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 946 | IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED} |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 947 | ) |
| 948 | add_dependencies( |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 949 | kobj_hash_output_obj_renamed_lib |
| 950 | kobj_hash_output_obj_renamed |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 951 | ) |
| 952 | |
Daniel Leung | 28c3512 | 2021-03-18 12:02:19 -0700 | [diff] [blame] | 953 | set_property( |
| 954 | GLOBAL APPEND PROPERTY |
| 955 | GENERATED_KERNEL_OBJECT_FILES kobj_hash_output_obj_renamed_lib |
| 956 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 957 | endif() |
| 958 | |
| 959 | # Read global variables into local variables |
| 960 | get_property(GKOF GLOBAL PROPERTY GENERATED_KERNEL_OBJECT_FILES) |
| 961 | get_property(GKSF GLOBAL PROPERTY GENERATED_KERNEL_SOURCE_FILES) |
| 962 | |
Alberto Escolar Piedras | 76f76441 | 2017-10-03 16:31:55 +0200 | [diff] [blame] | 963 | |
Alberto Escolar Piedras | c288241 | 2018-07-05 10:51:03 +0200 | [diff] [blame] | 964 | get_property(CSTD GLOBAL PROPERTY CSTD) |
| 965 | set_ifndef(CSTD c99) |
| 966 | |
Danny Oerndrup | 6331dae | 2019-06-13 15:33:03 +0200 | [diff] [blame] | 967 | # @Intent: Obtain compiler specific flag for specifying the c standard |
Alberto Escolar Piedras | c288241 | 2018-07-05 10:51:03 +0200 | [diff] [blame] | 968 | zephyr_compile_options( |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 969 | $<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,cstd>${CSTD}> |
Alberto Escolar Piedras | c288241 | 2018-07-05 10:51:03 +0200 | [diff] [blame] | 970 | ) |
| 971 | |
Mark Ruvald Pedersen | 197197a | 2019-05-03 11:02:56 +0200 | [diff] [blame] | 972 | # @Intent: Configure linker scripts, i.e. generate linker scripts with variables substituted |
| 973 | toolchain_ld_configure_files() |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 974 | |
Andrew Boie | 4ce652e | 2019-02-22 16:08:44 -0800 | [diff] [blame] | 975 | if(CONFIG_USERSPACE) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 976 | set(APP_SMEM_ALIGNED_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem_aligned.ld") |
| 977 | set(APP_SMEM_UNALIGNED_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem_unaligned.ld") |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 978 | set(OBJ_FILE_DIR "${PROJECT_BINARY_DIR}/../") |
| 979 | |
| 980 | add_custom_target( |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 981 | ${APP_SMEM_ALIGNED_DEP} |
Sebastian Bøe | 2a96312 | 2019-02-08 15:49:57 +0100 | [diff] [blame] | 982 | DEPENDS |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 983 | ${APP_SMEM_ALIGNED_LD} |
| 984 | ) |
| 985 | |
| 986 | add_custom_target( |
| 987 | ${APP_SMEM_UNALIGNED_DEP} |
| 988 | DEPENDS |
| 989 | ${APP_SMEM_UNALIGNED_LD} |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 990 | ) |
| 991 | |
Andrew Boie | 4b4f773 | 2019-02-01 12:18:31 -0800 | [diff] [blame] | 992 | if(CONFIG_NEWLIB_LIBC) |
Andrew Boie | 17ce822 | 2019-02-21 13:44:54 -0800 | [diff] [blame] | 993 | set(NEWLIB_PART -l libc.a z_libc_partition) |
Andrew Boie | 4b4f773 | 2019-02-01 12:18:31 -0800 | [diff] [blame] | 994 | endif() |
Ioannis Glaropoulos | d58f8be | 2019-11-15 14:07:51 +0100 | [diff] [blame] | 995 | if(CONFIG_NEWLIB_LIBC_NANO) |
| 996 | set(NEWLIB_PART -l libc_nano.a z_libc_partition) |
| 997 | endif() |
Andrew Boie | e686aef | 2019-02-27 14:41:45 -0800 | [diff] [blame] | 998 | |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 999 | add_custom_command( |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1000 | OUTPUT ${APP_SMEM_UNALIGNED_LD} |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 1001 | COMMAND ${PYTHON_EXECUTABLE} |
| 1002 | ${ZEPHYR_BASE}/scripts/gen_app_partitions.py |
| 1003 | -d ${OBJ_FILE_DIR} |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1004 | -o ${APP_SMEM_UNALIGNED_LD} |
Torsten Rasmussen | 5a703c8 | 2019-11-05 10:24:08 +0100 | [diff] [blame] | 1005 | ${NEWLIB_PART} |
Torsten Rasmussen | 1f9723a | 2019-11-04 14:30:24 +0100 | [diff] [blame] | 1006 | $<TARGET_PROPERTY:zephyr_property_target,COMPILE_OPTIONS> |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 1007 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
Sebastian Bøe | 2a96312 | 2019-02-08 15:49:57 +0100 | [diff] [blame] | 1008 | DEPENDS |
| 1009 | kernel |
| 1010 | ${ZEPHYR_LIBS_PROPERTY} |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 1011 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/ |
Torsten Rasmussen | 1f9723a | 2019-11-04 14:30:24 +0100 | [diff] [blame] | 1012 | COMMAND_EXPAND_LISTS |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1013 | COMMENT "Generating app_smem_unaligned linker section" |
| 1014 | ) |
| 1015 | |
Mark Ruvald Pedersen | 4c81197 | 2019-04-29 17:16:54 +0200 | [diff] [blame] | 1016 | configure_linker_script( |
Mark Ruvald Pedersen | 1073fba | 2019-04-29 20:27:23 +0200 | [diff] [blame] | 1017 | linker_app_smem_unaligned.cmd |
Mark Ruvald Pedersen | fbcea17 | 2019-04-29 20:35:12 +0200 | [diff] [blame] | 1018 | "-DLINKER_APP_SMEM_UNALIGNED" |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1019 | ${CODE_RELOCATION_DEP} |
| 1020 | ${APP_SMEM_UNALIGNED_DEP} |
| 1021 | ${APP_SMEM_UNALIGNED_LD} |
Sebastian Bøe | fdac7b3 | 2020-01-23 15:39:17 +0100 | [diff] [blame] | 1022 | zephyr_generated_headers |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1023 | ) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1024 | |
| 1025 | add_custom_target( |
| 1026 | linker_app_smem_unaligned_script |
| 1027 | DEPENDS |
| 1028 | linker_app_smem_unaligned.cmd |
| 1029 | ) |
| 1030 | |
| 1031 | set_property(TARGET |
| 1032 | linker_app_smem_unaligned_script |
| 1033 | PROPERTY INCLUDE_DIRECTORIES |
| 1034 | ${ZEPHYR_INCLUDE_DIRS} |
| 1035 | ) |
| 1036 | |
| 1037 | set(APP_SMEM_UNALIGNED_LIB app_smem_unaligned_output_obj_renamed_lib) |
| 1038 | add_executable( app_smem_unaligned_prebuilt misc/empty_file.c) |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1039 | toolchain_ld_link_elf( |
| 1040 | TARGET_ELF app_smem_unaligned_prebuilt |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1041 | OUTPUT_MAP ${PROJECT_BINARY_DIR}/app_smem_unaligned_prebuilt.map |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1042 | LIBRARIES_PRE_SCRIPT "" |
| 1043 | LINKER_SCRIPT ${PROJECT_BINARY_DIR}/linker_app_smem_unaligned.cmd |
| 1044 | LIBRARIES_POST_SCRIPT "" |
| 1045 | DEPENDENCIES ${CODE_RELOCATION_DEP} |
| 1046 | ) |
Torsten Rasmussen | c4c79f5 | 2021-02-09 22:27:59 +0100 | [diff] [blame] | 1047 | target_byproducts(TARGET app_smem_unaligned_prebuilt |
| 1048 | BYPRODUCTS ${PROJECT_BINARY_DIR}/app_smem_unaligned_prebuilt.map |
| 1049 | ) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1050 | set_property(TARGET app_smem_unaligned_prebuilt PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_app_smem_unaligned.cmd) |
Mark Ruvald Pedersen | 85af280 | 2019-04-29 14:49:33 +0200 | [diff] [blame] | 1051 | add_dependencies( app_smem_unaligned_prebuilt linker_app_smem_unaligned_script ${OFFSETS_LIB}) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1052 | |
| 1053 | add_custom_command( |
| 1054 | OUTPUT ${APP_SMEM_ALIGNED_LD} |
| 1055 | COMMAND ${PYTHON_EXECUTABLE} |
| 1056 | ${ZEPHYR_BASE}/scripts/gen_app_partitions.py |
| 1057 | -e $<TARGET_FILE:app_smem_unaligned_prebuilt> |
| 1058 | -o ${APP_SMEM_ALIGNED_LD} |
Torsten Rasmussen | 5a703c8 | 2019-11-05 10:24:08 +0100 | [diff] [blame] | 1059 | ${NEWLIB_PART} |
Torsten Rasmussen | 1f9723a | 2019-11-04 14:30:24 +0100 | [diff] [blame] | 1060 | $<TARGET_PROPERTY:zephyr_property_target,COMPILE_OPTIONS> |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1061 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
| 1062 | DEPENDS |
| 1063 | kernel |
| 1064 | ${ZEPHYR_LIBS_PROPERTY} |
| 1065 | app_smem_unaligned_prebuilt |
| 1066 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/ |
Torsten Rasmussen | 1f9723a | 2019-11-04 14:30:24 +0100 | [diff] [blame] | 1067 | COMMAND_EXPAND_LISTS |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 1068 | COMMENT "Generating app_smem_aligned linker section" |
Adithya Baglody | 50950eb | 2018-12-20 15:47:42 +0530 | [diff] [blame] | 1069 | ) |
| 1070 | endif() |
| 1071 | |
Daniel Leung | 1117169 | 2021-03-18 14:00:07 -0700 | [diff] [blame] | 1072 | if(CONFIG_USERSPACE) |
| 1073 | # This CONFIG_USERSPACE block is to create place holders to reserve space |
| 1074 | # for the gperf generated structures for zephyr_prebuilt.elf. |
| 1075 | # These place holders are there so that the placement of kobjects would be |
| 1076 | # the same between linking zephyr_prebuilt.elf and zephyr.elf, as |
| 1077 | # the gperf hash table is hashed on the addresses of kobjects. |
| 1078 | # The placeholders are generated from app_smem_unaligned_prebuilt.elf. |
| 1079 | |
| 1080 | set(KOBJECT_PREBUILT_HASH_LIST kobject_prebuilt_hash.gperf) |
| 1081 | set(KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE kobject_prebuilt_hash_preprocessed.c) |
| 1082 | set(KOBJECT_PREBUILT_HASH_OUTPUT_SRC kobject_prebuilt_hash.c) |
| 1083 | set(KOBJECT_PREBUILT_HASH_OUTPUT_OBJ kobject_prebuilt_hash.c.obj) |
| 1084 | |
| 1085 | add_custom_command( |
| 1086 | OUTPUT ${KOBJECT_PREBUILT_HASH_LIST} |
| 1087 | COMMAND |
| 1088 | ${PYTHON_EXECUTABLE} |
| 1089 | ${GEN_KOBJ_LIST} |
| 1090 | --kernel $<TARGET_FILE:app_smem_unaligned_prebuilt> |
| 1091 | --gperf-output ${KOBJECT_PREBUILT_HASH_LIST} |
| 1092 | ${gen_kobject_list_include_args} |
| 1093 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
| 1094 | DEPENDS |
| 1095 | app_smem_unaligned_prebuilt |
| 1096 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 1097 | ) |
| 1098 | add_custom_target( |
| 1099 | kobj_prebuilt_hash_list |
| 1100 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_PREBUILT_HASH_LIST} |
| 1101 | ) |
| 1102 | |
| 1103 | add_custom_command( |
| 1104 | OUTPUT ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE} |
| 1105 | COMMAND |
| 1106 | ${GPERF} |
| 1107 | --output-file ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE} |
| 1108 | --multiple-iterations 10 |
| 1109 | ${KOBJECT_PREBUILT_HASH_LIST} |
| 1110 | DEPENDS kobj_prebuilt_hash_list ${KOBJECT_PREBUILT_HASH_LIST} |
| 1111 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 1112 | ) |
| 1113 | add_custom_target( |
| 1114 | kobj_prebuilt_hash_output_src_pre |
| 1115 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE} |
| 1116 | ) |
| 1117 | |
| 1118 | add_custom_command( |
| 1119 | OUTPUT ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1120 | COMMAND |
| 1121 | ${PYTHON_EXECUTABLE} |
| 1122 | ${PROCESS_GPERF} |
| 1123 | -i ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE} |
| 1124 | -o ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1125 | -p "struct z_object" |
| 1126 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
| 1127 | DEPENDS kobj_prebuilt_hash_output_src_pre ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE} |
| 1128 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 1129 | ) |
| 1130 | add_custom_target( |
| 1131 | kobj_prebuilt_hash_output_src |
| 1132 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1133 | ) |
| 1134 | |
| 1135 | add_library( |
| 1136 | kobj_prebuilt_hash_output_lib |
| 1137 | STATIC ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1138 | ) |
| 1139 | |
| 1140 | set_source_files_properties(${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1141 | PROPERTIES COMPILE_FLAGS |
| 1142 | "${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections") |
| 1143 | |
| 1144 | set_source_files_properties(${KOBJECT_PREBUILT_HASH_OUTPUT_SRC} |
| 1145 | PROPERTIES COMPILE_DEFINITIONS "${compile_definitions_interface}") |
| 1146 | |
| 1147 | add_library(kobj_prebuilt_hash_output_lib_interface INTERFACE) |
| 1148 | |
| 1149 | target_link_libraries( |
| 1150 | kobj_prebuilt_hash_output_lib |
| 1151 | kobj_prebuilt_hash_output_lib_interface |
| 1152 | ) |
| 1153 | |
| 1154 | foreach(incl ${include_dir_in_interface}) |
| 1155 | target_include_directories( |
| 1156 | kobj_prebuilt_hash_output_lib_interface |
| 1157 | INTERFACE ${incl} |
| 1158 | ) |
| 1159 | endforeach() |
| 1160 | |
| 1161 | foreach(incl ${sys_include_dir_in_interface}) |
| 1162 | target_include_directories( |
| 1163 | kobj_prebuilt_hash_output_lib_interface |
| 1164 | SYSTEM INTERFACE ${incl} |
| 1165 | ) |
| 1166 | endforeach() |
| 1167 | |
| 1168 | set( |
| 1169 | KOBJECT_PREBUILT_HASH_OUTPUT_OBJ_PATH |
| 1170 | ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/kobj_prebuilt_hash_output_lib.dir/${KOBJECT_PREBUILT_HASH_OUTPUT_OBJ} |
| 1171 | ) |
| 1172 | |
| 1173 | set(KOBJECT_LINKER_HEADER_DATA "${PROJECT_BINARY_DIR}/include/generated/linker-kobject-prebuilt-data.h") |
| 1174 | |
| 1175 | add_custom_command( |
| 1176 | OUTPUT ${KOBJECT_LINKER_HEADER_DATA} |
| 1177 | COMMAND |
| 1178 | ${PYTHON_EXECUTABLE} |
| 1179 | ${ZEPHYR_BASE}/scripts/gen_kobject_placeholders.py |
| 1180 | --object ${KOBJECT_PREBUILT_HASH_OUTPUT_OBJ_PATH} |
| 1181 | --outdir ${PROJECT_BINARY_DIR}/include/generated |
| 1182 | --datapct ${CONFIG_KOBJECT_DATA_AREA_RESERVE_EXTRA_PERCENT} |
| 1183 | --rodata ${CONFIG_KOBJECT_RODATA_AREA_EXTRA_BYTES} |
| 1184 | $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> |
| 1185 | DEPENDS |
| 1186 | kobj_prebuilt_hash_output_lib |
| 1187 | ${KOBJECT_PREBUILT_HASH_OUTPUT_OBJ_PATH} |
| 1188 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 1189 | ) |
| 1190 | |
| 1191 | add_custom_target( |
| 1192 | ${KOBJECT_LINKER_DEP} |
| 1193 | DEPENDS |
| 1194 | ${KOBJECT_LINKER_HEADER_DATA} |
| 1195 | ) |
| 1196 | endif() |
| 1197 | |
Daniel Leung | c745995 | 2021-03-19 12:09:05 -0700 | [diff] [blame] | 1198 | configure_linker_script( |
| 1199 | linker_zephyr_prebuilt.cmd |
| 1200 | "-DLINKER_ZEPHYR_PREBUILT" |
| 1201 | ${APP_SMEM_ALIGNED_DEP} |
Daniel Leung | 1117169 | 2021-03-18 14:00:07 -0700 | [diff] [blame] | 1202 | ${KOBJECT_LINKER_DEP} |
Daniel Leung | c745995 | 2021-03-19 12:09:05 -0700 | [diff] [blame] | 1203 | ${CODE_RELOCATION_DEP} |
| 1204 | zephyr_generated_headers |
| 1205 | ) |
| 1206 | |
| 1207 | add_custom_target( |
| 1208 | linker_zephyr_prebuilt_script_target |
| 1209 | DEPENDS |
| 1210 | linker_zephyr_prebuilt.cmd |
| 1211 | ) |
| 1212 | |
| 1213 | set_property(TARGET |
| 1214 | linker_zephyr_prebuilt_script_target |
| 1215 | PROPERTY INCLUDE_DIRECTORIES |
| 1216 | ${ZEPHYR_INCLUDE_DIRS} |
| 1217 | ) |
| 1218 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1219 | # FIXME: Is there any way to get rid of empty_file.c? |
Sebastian Bøe | 1526070 | 2019-01-14 16:31:02 +0100 | [diff] [blame] | 1220 | add_executable( ${ZEPHYR_PREBUILT_EXECUTABLE} misc/empty_file.c) |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1221 | toolchain_ld_link_elf( |
| 1222 | TARGET_ELF ${ZEPHYR_PREBUILT_EXECUTABLE} |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1223 | OUTPUT_MAP ${PROJECT_BINARY_DIR}/${ZEPHYR_PREBUILT_EXECUTABLE}.map |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1224 | LIBRARIES_PRE_SCRIPT "" |
Daniel Leung | c745995 | 2021-03-19 12:09:05 -0700 | [diff] [blame] | 1225 | LINKER_SCRIPT ${PROJECT_BINARY_DIR}/linker_zephyr_prebuilt.cmd |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1226 | DEPENDENCIES ${CODE_RELOCATION_DEP} |
| 1227 | ) |
Torsten Rasmussen | c4c79f5 | 2021-02-09 22:27:59 +0100 | [diff] [blame] | 1228 | target_byproducts(TARGET ${ZEPHYR_PREBUILT_EXECUTABLE} |
| 1229 | BYPRODUCTS ${PROJECT_BINARY_DIR}/${ZEPHYR_PREBUILT_EXECUTABLE}.map |
| 1230 | ) |
Daniel Leung | c745995 | 2021-03-19 12:09:05 -0700 | [diff] [blame] | 1231 | set_property(TARGET |
| 1232 | ${ZEPHYR_PREBUILT_EXECUTABLE} |
| 1233 | PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_zephyr_prebuilt.cmd |
| 1234 | ) |
| 1235 | add_dependencies( |
| 1236 | ${ZEPHYR_PREBUILT_EXECUTABLE} |
| 1237 | linker_zephyr_prebuilt_script_target |
| 1238 | ${OFFSETS_LIB} |
| 1239 | ) |
Alberto Escolar Piedras | 76f76441 | 2017-10-03 16:31:55 +0200 | [diff] [blame] | 1240 | |
Marc Herbert | 498b494 | 2019-04-16 23:30:52 -0700 | [diff] [blame] | 1241 | set(generated_kernel_files ${GKSF} ${GKOF}) |
| 1242 | if(NOT generated_kernel_files) |
| 1243 | # Use the prebuilt elf as the final elf since we don't have a |
| 1244 | # generation stage. |
| 1245 | set(logical_target_for_zephyr_elf ${ZEPHYR_PREBUILT_EXECUTABLE}) |
| 1246 | else() |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1247 | # The final linker pass uses the same source linker script of the |
| 1248 | # previous passes, but this time with a different output |
| 1249 | # file and preprocessed with the define LINKER_ZEPHYR_FINAL. |
| 1250 | # |
| 1251 | # LINKER_PASS2 is deprecated but being kept to avoid breaking |
| 1252 | # external projects. It will be removed in the future. |
Mark Ruvald Pedersen | 4c81197 | 2019-04-29 17:16:54 +0200 | [diff] [blame] | 1253 | configure_linker_script( |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1254 | linker.cmd |
| 1255 | "-DLINKER_ZEPHYR_FINAL;-DLINKER_PASS2" |
Sebastian Bøe | 2a96312 | 2019-02-08 15:49:57 +0100 | [diff] [blame] | 1256 | ${CODE_RELOCATION_DEP} |
| 1257 | ${ZEPHYR_PREBUILT_EXECUTABLE} |
Sebastian Bøe | fdac7b3 | 2020-01-23 15:39:17 +0100 | [diff] [blame] | 1258 | zephyr_generated_headers |
Sebastian Bøe | 7a6afcd | 2019-02-08 15:39:37 +0100 | [diff] [blame] | 1259 | ) |
Andy Gross | e8860fe | 2018-02-01 01:12:32 -0600 | [diff] [blame] | 1260 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1261 | add_custom_target( |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1262 | linker_zephyr_final_script_target |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1263 | DEPENDS |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1264 | linker.cmd |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1265 | ) |
Sebastian Bøe | b1ab501 | 2017-12-14 13:03:23 +0100 | [diff] [blame] | 1266 | set_property(TARGET |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1267 | linker_zephyr_final_script_target |
Sebastian Bøe | b1ab501 | 2017-12-14 13:03:23 +0100 | [diff] [blame] | 1268 | PROPERTY INCLUDE_DIRECTORIES |
| 1269 | ${ZEPHYR_INCLUDE_DIRS} |
| 1270 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1271 | |
Mark Ruvald Pedersen | 37d4947 | 2019-05-07 15:20:20 +0200 | [diff] [blame] | 1272 | add_executable( ${ZEPHYR_FINAL_EXECUTABLE} misc/empty_file.c ${GKSF}) |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1273 | toolchain_ld_link_elf( |
| 1274 | TARGET_ELF ${ZEPHYR_FINAL_EXECUTABLE} |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1275 | OUTPUT_MAP ${PROJECT_BINARY_DIR}/${ZEPHYR_FINAL_EXECUTABLE}.map |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1276 | LIBRARIES_PRE_SCRIPT ${GKOF} |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1277 | LINKER_SCRIPT ${PROJECT_BINARY_DIR}/linker.cmd |
Mark Ruvald Pedersen | 4052bac | 2019-05-07 16:32:36 +0200 | [diff] [blame] | 1278 | LIBRARIES_POST_SCRIPT "" |
| 1279 | DEPENDENCIES ${CODE_RELOCATION_DEP} |
| 1280 | ) |
Daniel Leung | cdd02a9 | 2021-03-19 12:18:52 -0700 | [diff] [blame] | 1281 | set_property(TARGET ${ZEPHYR_FINAL_EXECUTABLE} PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker.cmd) |
| 1282 | add_dependencies( ${ZEPHYR_FINAL_EXECUTABLE} linker_zephyr_final_script_target) |
Mark Ruvald Pedersen | 37d4947 | 2019-05-07 15:20:20 +0200 | [diff] [blame] | 1283 | |
| 1284 | # Use the pass2 elf as the final elf |
| 1285 | set(logical_target_for_zephyr_elf ${ZEPHYR_FINAL_EXECUTABLE}) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1286 | endif() |
| 1287 | |
Sebastian Bøe | 0fc3934 | 2018-10-16 13:25:04 +0200 | [diff] [blame] | 1288 | # Export the variable to the application's scope to allow the |
| 1289 | # application to know what the name of the final elf target is. |
| 1290 | set(logical_target_for_zephyr_elf ${logical_target_for_zephyr_elf} PARENT_SCOPE) |
| 1291 | |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1292 | # Override the base name of the last, "logical" .elf output (and last .map) so: |
Marc Herbert | 498b494 | 2019-04-16 23:30:52 -0700 | [diff] [blame] | 1293 | # 1. it doesn't depend on the number of passes above and the |
| 1294 | # post_build_commands below can always find it no matter which is it; |
| 1295 | # 2. it can be defined in Kconfig |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1296 | set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES OUTPUT_NAME ${KERNEL_NAME}) |
| 1297 | |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1298 | set(post_build_commands "") |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1299 | set(post_build_byproducts "") |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1300 | |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1301 | list(APPEND |
| 1302 | post_build_commands |
| 1303 | COMMAND |
Torsten Rasmussen | 4df38c7 | 2020-06-11 10:48:06 +0200 | [diff] [blame] | 1304 | ${CMAKE_COMMAND} -E rename ${logical_target_for_zephyr_elf}.map ${KERNEL_MAP_NAME} |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1305 | ) |
Torsten Rasmussen | c4c79f5 | 2021-02-09 22:27:59 +0100 | [diff] [blame] | 1306 | list(APPEND post_build_byproducts ${KERNEL_MAP_NAME}) |
Marc Herbert | 0370c9b | 2019-06-13 16:15:44 -0700 | [diff] [blame] | 1307 | |
Håkon Øye Amundsen | c086b93 | 2018-11-26 09:47:16 +0000 | [diff] [blame] | 1308 | if(NOT CONFIG_BUILD_NO_GAP_FILL) |
| 1309 | # Use ';' as separator to get proper space in resulting command. |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1310 | set(GAP_FILL "$<TARGET_PROPERTY:bintools,elfconvert_flag_gapfill>0xff") |
Håkon Øye Amundsen | c086b93 | 2018-11-26 09:47:16 +0000 | [diff] [blame] | 1311 | endif() |
| 1312 | |
Danny Oerndrup | c41e712 | 2019-07-18 15:16:39 +0200 | [diff] [blame] | 1313 | if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE) |
Torsten Rasmussen | d537be0 | 2021-02-02 21:06:11 +0100 | [diff] [blame] | 1314 | target_link_libraries(${logical_target_for_zephyr_elf} $<TARGET_PROPERTY:linker,memusage>) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1315 | |
| 1316 | get_property(memusage_build_command TARGET bintools PROPERTY memusage_command) |
| 1317 | if(memusage_build_command) |
| 1318 | # Note: The use of generator expressions allows downstream extensions to add/change the post build. |
| 1319 | # Unfortunately, the BYPRODUCTS does not allow for generator expression, so question is if we |
| 1320 | # should remove the downstream ability from start. |
| 1321 | # Or fix the output name, by the use of `get_property` |
| 1322 | list(APPEND |
| 1323 | post_build_commands |
Torsten Rasmussen | 571f48f | 2020-09-04 21:07:46 +0200 | [diff] [blame] | 1324 | COMMAND $<TARGET_PROPERTY:bintools,memusage_command> |
| 1325 | $<TARGET_PROPERTY:bintools,memusage_flag> |
| 1326 | $<TARGET_PROPERTY:bintools,memusage_infile>${KERNEL_ELF_NAME} |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1327 | ) |
| 1328 | |
| 1329 | # For now, the byproduct can only be supported upstream on byproducts name, |
| 1330 | # cause byproduct does not support generator expressions |
| 1331 | get_property(memusage_byproducts TARGET bintools PROPERTY memusage_byproducts) |
| 1332 | list(APPEND |
| 1333 | post_build_byproducts |
| 1334 | ${memusage_byproducts} |
| 1335 | ) |
| 1336 | endif() |
Danny Oerndrup | c41e712 | 2019-07-18 15:16:39 +0200 | [diff] [blame] | 1337 | endif() |
| 1338 | |
Kumar Gala | d541913 | 2019-08-13 13:44:20 -0500 | [diff] [blame] | 1339 | if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1340 | get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) |
| 1341 | if(ihex IN_LIST elfconvert_formats) |
| 1342 | list(APPEND |
| 1343 | post_build_commands |
| 1344 | COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> |
| 1345 | $<TARGET_PROPERTY:bintools,elfconvert_flag> |
| 1346 | ${GAP_FILL} |
| 1347 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex |
| 1348 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.comment |
| 1349 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>COMMON |
| 1350 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame |
| 1351 | $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} |
| 1352 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_HEX_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1353 | $<TARGET_PROPERTY:bintools,elfconvert_flag_final> |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1354 | ) |
| 1355 | list(APPEND |
| 1356 | post_build_byproducts |
| 1357 | ${KERNEL_HEX_NAME} |
| 1358 | # ${out_hex_byprod} # Is this needed ? |
| 1359 | ) |
| 1360 | endif() |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1361 | endif() |
Anas Nashif | 4592ff2 | 2017-11-23 07:54:26 -0500 | [diff] [blame] | 1362 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1363 | if(CONFIG_BUILD_OUTPUT_BIN) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1364 | get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) |
| 1365 | if(binary IN_LIST elfconvert_formats) |
| 1366 | list(APPEND |
| 1367 | post_build_commands |
| 1368 | COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> |
| 1369 | $<TARGET_PROPERTY:bintools,elfconvert_flag> |
| 1370 | ${GAP_FILL} |
| 1371 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary |
| 1372 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.comment |
| 1373 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>COMMON |
| 1374 | $<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame |
| 1375 | $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} |
| 1376 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_BIN_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1377 | $<TARGET_PROPERTY:bintools,elfconvert_flag_final> |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1378 | ) |
| 1379 | list(APPEND |
| 1380 | post_build_byproducts |
| 1381 | ${KERNEL_BIN_NAME} |
| 1382 | # ${out_hex_byprod} # Is this needed ? |
| 1383 | ) |
| 1384 | endif() |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1385 | endif() |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1386 | |
Pete Johanson | 310a464 | 2020-12-31 16:51:52 -0500 | [diff] [blame] | 1387 | if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2) |
| 1388 | list(APPEND |
| 1389 | post_build_commands |
| 1390 | COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/uf2conv.py |
| 1391 | -c |
| 1392 | -f ${CONFIG_BUILD_OUTPUT_UF2_FAMILY_ID} |
| 1393 | -b ${CONFIG_FLASH_LOAD_OFFSET} |
| 1394 | -o ${KERNEL_UF2_NAME} |
| 1395 | ${KERNEL_BIN_NAME} |
| 1396 | ) |
| 1397 | list(APPEND |
| 1398 | post_build_byproducts |
| 1399 | ${KERNEL_UF2_NAME} |
| 1400 | ) |
| 1401 | endif() |
Anas Nashif | fdbf2db | 2020-10-20 14:31:56 -0400 | [diff] [blame] | 1402 | |
| 1403 | # Cleanup intermediate files |
| 1404 | if(CONFIG_CLEANUP_INTERMEDIATE_FILES) |
| 1405 | list(APPEND |
| 1406 | post_build_commands |
| 1407 | COMMAND |
| 1408 | # This file can be very large in some cases, delete it as we do not need it. |
| 1409 | ${CMAKE_COMMAND} -E remove ${ZEPHYR_PREBUILT_EXECUTABLE}.elf |
| 1410 | ) |
| 1411 | endif() |
| 1412 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1413 | if(CONFIG_BUILD_OUTPUT_S19) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1414 | get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) |
| 1415 | if(srec IN_LIST elfconvert_formats) |
| 1416 | # Should we print a warning if case the tools does not support converting to s19 ? |
| 1417 | list(APPEND |
| 1418 | post_build_commands |
| 1419 | COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> |
| 1420 | $<TARGET_PROPERTY:bintools,elfconvert_flag> |
| 1421 | ${GAP_FILL} |
| 1422 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec |
| 1423 | $<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1 |
| 1424 | $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} |
| 1425 | $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_S19_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1426 | $<TARGET_PROPERTY:bintools,elfconvert_flag_final> |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1427 | ) |
| 1428 | list(APPEND |
| 1429 | post_build_byproducts |
| 1430 | ${KERNEL_S19_NAME} |
| 1431 | # ${out_S19_byprod} # Is this needed ? |
| 1432 | |
| 1433 | ) |
| 1434 | endif() |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1435 | endif() |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1436 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1437 | if(CONFIG_OUTPUT_DISASSEMBLY) |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1438 | if(CONFIG_OUTPUT_DISASSEMBLE_ALL) |
| 1439 | set(disassembly_type "$<TARGET_PROPERTY:bintools,disassembly_flag_all>") |
Rohit Gujarathi | 35713f2 | 2020-05-07 10:08:37 +0530 | [diff] [blame] | 1440 | else() |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1441 | set(disassembly_type "$<TARGET_PROPERTY:bintools,disassembly_flag_inline_source>") |
Rohit Gujarathi | 35713f2 | 2020-05-07 10:08:37 +0530 | [diff] [blame] | 1442 | endif() |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1443 | list(APPEND |
| 1444 | post_build_commands |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1445 | COMMAND $<TARGET_PROPERTY:bintools,disassembly_command> |
| 1446 | $<TARGET_PROPERTY:bintools,disassembly_flag> |
| 1447 | ${disassembly_type} |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 1448 | $<TARGET_PROPERTY:bintools,disassembly_flag_infile>${KERNEL_ELF_NAME} |
| 1449 | $<TARGET_PROPERTY:bintools,disassembly_flag_outfile>${KERNEL_LST_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1450 | $<TARGET_PROPERTY:bintools,disassembly_flag_final> |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1451 | ) |
| 1452 | list(APPEND |
| 1453 | post_build_byproducts |
| 1454 | ${KERNEL_LST_NAME} |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1455 | # ${out_disassembly_byprod} # Needed ?? |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1456 | ) |
| 1457 | endif() |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1458 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1459 | if(CONFIG_OUTPUT_STAT) |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 1460 | # zephyr_post_build(TOOLS bintools COMMAND readelf FLAGS headers INFILE file OUTFILE outfile) |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1461 | list(APPEND |
| 1462 | post_build_commands |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 1463 | COMMAND $<TARGET_PROPERTY:bintools,readelf_command> |
| 1464 | $<TARGET_PROPERTY:bintools,readelf_flag> |
| 1465 | $<TARGET_PROPERTY:bintools,readelf_flag_headers> |
| 1466 | $<TARGET_PROPERTY:bintools,readelf_flag_infile> ${KERNEL_ELF_NAME} |
| 1467 | $<TARGET_PROPERTY:bintools,readelf_flag_outfile> ${KERNEL_STAT_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1468 | $<TARGET_PROPERTY:bintools,readelf_flag_final> |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1469 | ) |
| 1470 | list(APPEND |
| 1471 | post_build_byproducts |
| 1472 | ${KERNEL_STAT_NAME} |
| 1473 | ) |
| 1474 | endif() |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1475 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1476 | if(CONFIG_BUILD_OUTPUT_STRIPPED) |
| 1477 | list(APPEND |
| 1478 | post_build_commands |
Torsten Rasmussen | c060b07 | 2020-08-18 14:46:06 +0200 | [diff] [blame] | 1479 | COMMAND $<TARGET_PROPERTY:bintools,strip_command> |
| 1480 | $<TARGET_PROPERTY:bintools,strip_flag> |
| 1481 | $<TARGET_PROPERTY:bintools,strip_flag_all> |
| 1482 | $<TARGET_PROPERTY:bintools,strip_flag_infile>${KERNEL_ELF_NAME} |
| 1483 | $<TARGET_PROPERTY:bintools,strip_flag_outfile>${KERNEL_STRIP_NAME} |
Torsten Rasmussen | f160dee | 2020-09-04 10:05:00 +0200 | [diff] [blame] | 1484 | $<TARGET_PROPERTY:bintools,strip_flag_final> |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1485 | ) |
| 1486 | list(APPEND |
| 1487 | post_build_byproducts |
| 1488 | ${KERNEL_STRIP_NAME} |
| 1489 | ) |
| 1490 | endif() |
| 1491 | |
| 1492 | if(CONFIG_BUILD_OUTPUT_EXE) |
| 1493 | list(APPEND |
| 1494 | post_build_commands |
| 1495 | COMMAND |
| 1496 | ${CMAKE_COMMAND} -E copy ${KERNEL_ELF_NAME} ${KERNEL_EXE_NAME} |
| 1497 | ) |
| 1498 | list(APPEND |
| 1499 | post_build_byproducts |
| 1500 | ${KERNEL_EXE_NAME} |
| 1501 | ) |
| 1502 | endif() |
Anas Nashif | 4592ff2 | 2017-11-23 07:54:26 -0500 | [diff] [blame] | 1503 | |
Martí Bolívar | f66a0c3 | 2020-08-18 11:28:04 -0700 | [diff] [blame] | 1504 | # Generate and use MCUboot related artifacts as needed. |
| 1505 | if(CONFIG_BOOTLOADER_MCUBOOT) |
| 1506 | include(${CMAKE_CURRENT_LIST_DIR}/cmake/mcuboot.cmake) |
| 1507 | endif() |
| 1508 | |
Rajavardhan Gundi | ecdea1c | 2019-01-25 11:53:13 +0530 | [diff] [blame] | 1509 | get_property(extra_post_build_commands |
| 1510 | GLOBAL PROPERTY |
| 1511 | extra_post_build_commands |
| 1512 | ) |
| 1513 | |
| 1514 | list(APPEND |
| 1515 | post_build_commands |
| 1516 | ${extra_post_build_commands} |
| 1517 | ) |
| 1518 | |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1519 | get_property(extra_post_build_byproducts |
| 1520 | GLOBAL PROPERTY |
| 1521 | extra_post_build_byproducts |
| 1522 | ) |
| 1523 | |
| 1524 | list(APPEND |
| 1525 | post_build_byproducts |
| 1526 | ${extra_post_build_byproducts} |
| 1527 | ) |
| 1528 | |
Daniel Leung | a5ab1a7 | 2021-04-02 12:54:53 -0700 | [diff] [blame] | 1529 | if(CONFIG_LOG_DICTIONARY_SUPPORT) |
| 1530 | set(LOG_DICT_DB_NAME ${PROJECT_BINARY_DIR}/log_dictionary.json) |
| 1531 | |
| 1532 | list(APPEND |
| 1533 | post_build_commands |
| 1534 | COMMAND |
| 1535 | ${PYTHON_EXECUTABLE} |
| 1536 | ${ZEPHYR_BASE}/scripts/logging/dictionary/database_gen.py |
| 1537 | ${KERNEL_ELF_NAME} |
| 1538 | ${LOG_DICT_DB_NAME} |
| 1539 | --build ${BUILD_VERSION} |
| 1540 | ) |
| 1541 | list(APPEND |
| 1542 | post_build_byproducts |
| 1543 | ${LOG_DICT_DB_NAME} |
| 1544 | ) |
| 1545 | endif() |
| 1546 | |
Marc Herbert | 498b494 | 2019-04-16 23:30:52 -0700 | [diff] [blame] | 1547 | # Add post_build_commands to post-process the final .elf file produced by |
| 1548 | # either the ZEPHYR_PREBUILT_EXECUTABLE or the KERNEL_ELF executable |
| 1549 | # targets above. |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1550 | add_custom_command( |
| 1551 | TARGET ${logical_target_for_zephyr_elf} |
| 1552 | POST_BUILD |
Sebastian Bøe | e51ce4d | 2017-11-20 15:37:59 +0100 | [diff] [blame] | 1553 | ${post_build_commands} |
Sebastian Bøe | f483e5b | 2019-05-10 10:06:32 +0200 | [diff] [blame] | 1554 | BYPRODUCTS |
| 1555 | ${post_build_byproducts} |
Marc Herbert | 498b494 | 2019-04-16 23:30:52 -0700 | [diff] [blame] | 1556 | COMMENT "Generating files from ${KERNEL_ELF_NAME} for board: ${BOARD}" |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1557 | COMMAND_EXPAND_LISTS |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1558 | # NB: COMMENT only works for some CMake-Generators |
Rajavardhan Gundi | ecdea1c | 2019-01-25 11:53:13 +0530 | [diff] [blame] | 1559 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1560 | |
Håkon Øye Amundsen | 81c6662 | 2018-10-30 07:39:13 +0000 | [diff] [blame] | 1561 | # To populate with hex files to merge, do the following: |
| 1562 | # set_property(GLOBAL APPEND PROPERTY HEX_FILES_TO_MERGE ${my_local_list}) |
| 1563 | # Note that the zephyr.hex file will not be included automatically. |
| 1564 | get_property(HEX_FILES_TO_MERGE GLOBAL PROPERTY HEX_FILES_TO_MERGE) |
| 1565 | if(HEX_FILES_TO_MERGE) |
| 1566 | # Merge in out-of-tree hex files. |
Håkon Øye Amundsen | 2a5a02e | 2018-12-05 08:32:32 +0000 | [diff] [blame] | 1567 | set(MERGED_HEX_NAME merged.hex) |
Håkon Øye Amundsen | 81c6662 | 2018-10-30 07:39:13 +0000 | [diff] [blame] | 1568 | |
| 1569 | add_custom_command( |
Håkon Øye Amundsen | 2a5a02e | 2018-12-05 08:32:32 +0000 | [diff] [blame] | 1570 | OUTPUT ${MERGED_HEX_NAME} |
Håkon Øye Amundsen | 81c6662 | 2018-10-30 07:39:13 +0000 | [diff] [blame] | 1571 | COMMAND |
| 1572 | ${PYTHON_EXECUTABLE} |
| 1573 | ${ZEPHYR_BASE}/scripts/mergehex.py |
Håkon Øye Amundsen | 2a5a02e | 2018-12-05 08:32:32 +0000 | [diff] [blame] | 1574 | -o ${MERGED_HEX_NAME} |
Håkon Øye Amundsen | 81c6662 | 2018-10-30 07:39:13 +0000 | [diff] [blame] | 1575 | ${HEX_FILES_TO_MERGE} |
| 1576 | DEPENDS ${HEX_FILES_TO_MERGE} ${logical_target_for_zephyr_elf} |
| 1577 | ) |
| 1578 | |
Håkon Øye Amundsen | 2a5a02e | 2018-12-05 08:32:32 +0000 | [diff] [blame] | 1579 | add_custom_target(mergehex ALL DEPENDS ${MERGED_HEX_NAME}) |
Torsten Rasmussen | d38da9d | 2020-06-30 09:55:54 +0200 | [diff] [blame] | 1580 | list(APPEND RUNNERS_DEPS mergehex) |
Håkon Øye Amundsen | c9a2a5e | 2020-01-03 08:25:03 +0000 | [diff] [blame] | 1581 | |
| 1582 | message(VERBOSE "Merging hex files: ${HEX_FILES_TO_MERGE}") |
Håkon Øye Amundsen | 81c6662 | 2018-10-30 07:39:13 +0000 | [diff] [blame] | 1583 | endif() |
| 1584 | |
Anas Nashif | c15d3c9 | 2017-11-21 18:54:55 -0500 | [diff] [blame] | 1585 | if(EMU_PLATFORM) |
Carles Cufi | 7d764b3 | 2018-01-11 15:46:44 +0100 | [diff] [blame] | 1586 | include(${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake) |
Anas Nashif | fd276ae | 2017-12-21 16:45:45 -0500 | [diff] [blame] | 1587 | else() |
| 1588 | add_custom_target(run |
| 1589 | COMMAND |
| 1590 | ${CMAKE_COMMAND} -E echo |
| 1591 | "===================================================" |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 1592 | "Emulation/Simulation not supported with this board." |
Anas Nashif | fd276ae | 2017-12-21 16:45:45 -0500 | [diff] [blame] | 1593 | "===================================================" |
| 1594 | ) |
Anas Nashif | c15d3c9 | 2017-11-21 18:54:55 -0500 | [diff] [blame] | 1595 | endif() |
| 1596 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1597 | add_subdirectory(cmake/flash) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1598 | add_subdirectory(cmake/usage) |
| 1599 | add_subdirectory(cmake/reports) |
| 1600 | |
Marc Herbert | 8372310 | 2019-06-17 13:26:11 -0700 | [diff] [blame] | 1601 | if(NOT CONFIG_TEST) |
Andrew Boie | 411686f | 2018-05-24 13:18:36 -0700 | [diff] [blame] | 1602 | if(CONFIG_ASSERT AND (NOT CONFIG_FORCE_NO_ASSERT)) |
Sebastian Bøe | fa8f9d4 | 2019-12-06 12:54:53 +0100 | [diff] [blame] | 1603 | message(WARNING "__ASSERT() statements are globally ENABLED") |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1604 | endif() |
Marc Herbert | 8372310 | 2019-06-17 13:26:11 -0700 | [diff] [blame] | 1605 | endif() |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1606 | |
Vincent Wan | a2bc514 | 2020-01-09 14:20:44 -0800 | [diff] [blame] | 1607 | if(CONFIG_BOARD_DEPRECATED_RELEASE) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1608 | message(WARNING " |
| 1609 | WARNING: The board '${BOARD}' is deprecated and will be |
Vincent Wan | a2bc514 | 2020-01-09 14:20:44 -0800 | [diff] [blame] | 1610 | removed in version ${CONFIG_BOARD_DEPRECATED_RELEASE}" |
Mark Ruvald Pedersen | 0efad5f | 2018-12-19 10:40:57 +0100 | [diff] [blame] | 1611 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 1612 | endif() |
Paul Sokolovsky | 1c6a7d7 | 2019-06-06 21:12:14 +0300 | [diff] [blame] | 1613 | |
Vincent Wan | 180b4df | 2020-01-08 17:10:51 -0800 | [diff] [blame] | 1614 | if(CONFIG_SOC_DEPRECATED_RELEASE) |
| 1615 | message(WARNING " |
| 1616 | WARNING: The SoC '${SOC_NAME}' is deprecated and will be |
| 1617 | removed in version ${CONFIG_SOC_DEPRECATED_RELEASE}" |
| 1618 | ) |
| 1619 | endif() |
| 1620 | |
Sebastian Bøe | e50e12d | 2019-08-29 16:19:32 +0200 | [diff] [blame] | 1621 | # In CMake projects, 'CMAKE_BUILD_TYPE' usually determines the |
| 1622 | # optimization flag, but in Zephyr it is determined through |
| 1623 | # Kconfig. Here we give a warning when there is a mismatch between the |
| 1624 | # two in case the user is not aware of this. |
| 1625 | set(build_types None Debug Release RelWithDebInfo MinSizeRel) |
| 1626 | |
| 1627 | if((CMAKE_BUILD_TYPE IN_LIST build_types) AND (NOT NO_BUILD_TYPE_WARNING)) |
| 1628 | string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_uppercase) |
| 1629 | |
Jack Dähn | e41bdcd | 2019-11-15 19:01:39 +0100 | [diff] [blame] | 1630 | if(NOT (${OPTIMIZATION_FLAG} IN_LIST CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_uppercase})) |
Sebastian Bøe | e50e12d | 2019-08-29 16:19:32 +0200 | [diff] [blame] | 1631 | message(WARNING " |
| 1632 | The CMake build type was set to '${CMAKE_BUILD_TYPE}', but the optimization flag was set to '${OPTIMIZATION_FLAG}'. |
| 1633 | This may be intentional and the warning can be turned off by setting the CMake variable 'NO_BUILD_TYPE_WARNING'" |
| 1634 | ) |
| 1635 | endif() |
| 1636 | endif() |
| 1637 | |
Paul Sokolovsky | 1c6a7d7 | 2019-06-06 21:12:14 +0300 | [diff] [blame] | 1638 | # @Intent: Set compiler specific flags for standard C includes |
| 1639 | # Done at the very end, so any other system includes which may |
| 1640 | # be added by Zephyr components were first in list. |
Torsten Rasmussen | c55c64e | 2020-08-18 14:47:53 +0200 | [diff] [blame] | 1641 | # Note, the compile flags are moved, but the system include is still present here. |
| 1642 | zephyr_compile_options($<TARGET_PROPERTY:compiler,nostdinc>) |
| 1643 | target_include_directories(zephyr_interface SYSTEM INTERFACE $<TARGET_PROPERTY:compiler,nostdinc_include>) |
Torsten Rasmussen | a5917f0 | 2020-09-09 15:42:32 +0200 | [diff] [blame] | 1644 | |
| 1645 | # Finally export all build flags from Zephyr |
| 1646 | add_subdirectory_ifdef( |
| 1647 | CONFIG_MAKEFILE_EXPORTS |
| 1648 | cmake/makefile_exports |
| 1649 | ) |