Lines Matching +full:cmake +full:- +full:ext
1 # SPDX-License-Identifier: Apache-2.0
5 # Note that this is *NOT* the top-level CMakeLists.txt. That's in the
16 cmake was invoked with '${CMAKE_CURRENT_LIST_DIR}' specified as the source directory,
25 # See https://gitlab.kitware.com/cmake/cmake/issues/16228
26 # and https://cmake.org/pipermail/cmake/2019-May/thread.html#69496
33 subtle and hard to debug CMake issues.")
36 # -fmacro-prefix-map=${ZEPHYR_BASE}=
57 # - device dependencies structs must be generated (CONFIG_DEVICE_DEPS=y)
58 # - ISR tables must be generated (CONFIG_GEN_ISR_TABLES=y)
59 # - Kernel objects hash tables (CONFIG_USERSPACE=y)
60 # - Application memory partitions (CONFIG_USERSPACE=y)
66 # - zephyr_pre0: linker sections may resize / addresses may relocate
67 # - zephyr_pre1: All linker section sizes are fixed, addresses cannot change
68 # - zephyr_final: Final image.
76 # Three stage linking active: pre0 -> pre1 -> final, this will correspond to `pre1`
77 # Two stage linking active: pre0 -> final, this will correspond to `pre0`
94 set_property( GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little${ARCH}) # BFD format
101 # "zephyr_interface" is a source-less library that encapsulates all the global
105 # https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#interface-libraries
108 # "zephyr" is a catch-all CMake library for source files that can be
124 include(${ZEPHYR_BASE}/cmake/linker_script/${ARCH}/linker.cmake OPTIONAL)
132 "but Zephyr ignores flags from the environment. Use 'cmake "
133 "-DEXTRA_${var}=$ENV{${var}}' instead."
144 # Ensure that include/zephyr/toolchain.h includes toolchain/other.h for all off-tree toolchains
151 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,no_strict_aliasing>>)
192 # to compiler flags. Each macro will store the flags in a CMake variable, whose
258 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,required>>)
265 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp98>)
268 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp11>) # Default in kconfig
271 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp14>)
274 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp17>)
277 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp2a>)
280 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp20>)
283 set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp2b>)
296 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,no_exceptions>>)
301 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,no_rtti>>)
307 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_error_misra_sane>>)
327 # @Intent: Set compiler specific flag to disable printf-related optimizations
331 # @Intent: Set compiler specific flag for tentative definitions, no-common
366 # Common toolchain-agnostic assembly flags
368 $<$<COMPILE_LANGUAGE:ASM>:-D_ASMLANGUAGE>
428 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_base>>)
432 # cmake -DW=... settings
434 # W=1 - warnings that may be relevant and does not occur too often
435 # W=2 - warnings that occur quite often but may still be relevant
436 # W=3 - the more obscure warnings, can most likely be ignored
438 # @Intent: Add cmake -DW toolchain supported warnings, if any
441 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_1>>)
446 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_2>>)
451 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_dw_3>>)
459 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,warning_error_implicit_int>>)
471 # Allow the user to inject options when calling cmake, e.g.
472 # 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..'
473 include(cmake/extra_flags.cmake)
475 zephyr_cc_option(-fno-asynchronous-unwind-tables)
483 zephyr_cc_option(-ftls-model=local-exec)
488 zephyr_cc_option(-fomit-frame-pointer)
490 zephyr_cc_option(-fno-omit-frame-pointer)
503 zephyr_cc_option(-fno-reorder-functions)
507 # `min-pagesize` parameter (defaults to 0x1000). The `min-pagesize` parameter
510 zephyr_cc_option(--param=min-pagesize=0)
513 zephyr_cc_option(-fno-defer-pop)
517 zephyr_cc_option(-Wno-vla)
520 zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage)
532 zephyr_cc_option(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR)
533 zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE)
535 zephyr_cc_option(-fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR)
555 set(build_version_argument "-DBUILD_VERSION=${BUILD_VERSION}")
561 # Likely a git-submodule. Let's ask git where the real database is located.
565 COMMAND ${GIT_EXECUTABLE} rev-parse --absolute-git-dir
573 message(WARNING "BUILD_VERSION: git rev-parse failed: ${stderr}")
576 message(WARNING "BUILD_VERSION: git rev-parse warned: ${stderr}")
583 "please specify '-DBUILD_VERSION=<version>'")
587 "repository, please specify '-DBUILD_VERSION=<version>'")
597 COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
598 -DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
599 -DVERSION_TYPE=KERNEL
600 -DVERSION_FILE=${ZEPHYR_BASE}/VERSION
601 -DKERNEL_VERSION_CUSTOMIZATION="$<TARGET_PROPERTY:version_h,KERNEL_VERSION_CUSTOMIZATION>"
603 -P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
614 COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
615 -DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/zephyr/app_version.h
616 -DVERSION_TYPE=APP
617 -DVERSION_FILE=${APPLICATION_SOURCE_DIR}/VERSION
618 -DAPP_VERSION_CUSTOMIZATION="$<TARGET_PROPERTY:app_version_h,APP_VERSION_CUSTOMIZATION>"
620 -P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
638 # defined in subsys or ext will not get global flags added by drivers/
660 # Include zephyr modules generated CMake file.
663 # subdirectory to have its own, local cmake target(s). If not then
666 # https://cmake.org/pipermail/cmake/2019-June/069547.html
691 # Other OS: The list will update whenever a file is added/removed/modified and ensure a re-build.
700 set(syscalls_links --create-links ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_links)
703 # When running CMake it must be ensured that all dependencies are correctly acquired.
708 --directory ${ZEPHYR_BASE}/include # Walk this directory
709 --out-file ${syscalls_subdirs_txt} # Write file with discovered folder
710 --trigger-file ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
713 file(STRINGS ${syscalls_subdirs_txt} PARSE_SYSCALLS_PATHS_DEPENDS ENCODING UTF-8)
717 # Hence adding a file requires CMake to re-run to add this file to the file list.
725 # When a folder is removed, CMake will try to find a target that creates that dependency.
726 # This command sets up the target for CMake to find.
727 # Without this code, CMake will fail with the following error:
731 COMMAND ${CMAKE_COMMAND} -E echo ""
741 --directory ${ZEPHYR_BASE}/include # Walk this directory
742 --out-file ${syscalls_subdirs_txt} # Write file with discovered folder
743 --trigger-file ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
748 # Ensure subdir file always exists when specifying CMake dependency.
755 # Thus CMake only needs to re-run when sub-directories are added / removed, which is indicated
787 --include ${d}
798 --scan ${ZEPHYR_BASE}/include # Read files from this dir
799 --scan ${ZEPHYR_BASE}/drivers # For net sockets
800 --scan ${ZEPHYR_BASE}/subsys/net # More net sockets
802 --json-file ${syscalls_json} # Write this file
803 --tag-struct-file ${struct_tags_json} # Write subsystem list to this file
804 --file-list ${syscalls_file_list_output}
805 $<$<BOOL:${CONFIG_EMIT_ALL_SYSCALLS}>:--emit-all-syscalls>
831 # 64-bit systems do not require special handling of 64-bit system call
835 set(SYSCALL_LONG_REGISTERS_ARG --long-registers)
839 set(SYSCALL_SPLIT_TIMEOUT_ARG --split-type k_timeout_t --split-type k_ticks_t)
846 ${CMAKE_COMMAND} -E copy
861 --json-file ${syscalls_json} # Read this file
862 --base-output include/generated/zephyr/syscalls # Write to this dir
863 --syscall-dispatch include/generated/zephyr/syscall_dispatch.c # Write this file
864 --syscall-exports-llext include/generated/zephyr/syscall_exports_llext.c
865 --syscall-weakdefs-llext syscall_weakdefs_llext.c # compiled in CMake library 'syscall_weakdefs'
866 --syscall-list ${syscall_list_h}
867 $<$<BOOL:${CONFIG_USERSPACE}>:--gen-mrsh-files>
877 set(gen_kobject_list_include_args --include-subsystem-list ${struct_tags_json})
879 set(DRV_VALIDATION ${PROJECT_BINARY_DIR}/include/generated/zephyr/driver-validation.h)
885 --validation-output ${DRV_VALIDATION}
887 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
895 include(${ZEPHYR_BASE}/cmake/kobj.cmake)
901 ${CMAKE_CURRENT_BINARY_DIR}/include/generated/device-api-sections.ld
905 ${CMAKE_CURRENT_BINARY_DIR}/include/generated/device-api-sections.cmake
913 --alignment ${CONFIG_LINKER_ITERABLE_SUBALIGN}
914 --input ${struct_tags_json}
915 --tag __subsystem
916 --ld-output ${DEVICE_API_LD_SECTIONS}
917 --cmake-output ${DEVICE_API_LINKER_SECTIONS_CMAKE}
929 # Add a pseudo-target that is up-to-date when all generated headers
930 # are up-to-date.
965 -i $<TARGET_OBJECTS:${OFFSETS_LIB}>
966 -o ${OFFSETS_H_PATH}
990 # To prevent CMake failure when a driver is enabled, for example: REGULATOR=y
1041 # that cmake can successfully find the linker scripts' header
1045 STRIP_PREFIX # Don't use a -I prefix
1050 set(dynamic_deps --dynamic-deps)
1066 --output-source device_deps.c
1067 --output-graphviz dev_graph.dot
1069 --num-dynamic-devices ${number_of_dynamic_devices}
1070 --kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1071 --zephyr-base ${ZEPHYR_BASE}
1072 --start-symbol "$<TARGET_PROPERTY:linker,devices_start_symbol>"
1109 set_ifndef( TOPT -Wl,-T) # Use this if the compiler driver doesn't set a value
1143 # only initialized post-kernel.
1150 set(APP_SMEM_PINNED_PARTITION_LIST_ARG "--pinpartitions=${APP_SMEM_PINNED_PARTITION_LIST_ARG_CSL}")
1157 set(LIBC_PART -l libc.a z_libc_partition -l libm.a z_libc_partition)
1160 set(LIBC_PART -l libc_nano.a z_libc_partition -l libm_nano.a z_libc_partition)
1163 set(LIBC_PART -l libc.a z_libc_partition)
1170 -f ${CMAKE_BINARY_DIR}/compile_commands.json
1171 -o ${APP_SMEM_UNALIGNED_LD}
1172 $<$<BOOL:${APP_SMEM_PINNED_UNALIGNED_LD}>:--pinoutput=${APP_SMEM_PINNED_UNALIGNED_LD}>
1176 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1209 -e $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1210 -o ${APP_SMEM_ALIGNED_LD}
1211 $<$<BOOL:${APP_SMEM_PINNED_ALIGNED_LD}>:--pinoutput=${APP_SMEM_PINNED_ALIGNED_LD}>
1215 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1243 --kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1244 --gperf-output ${KOBJECT_PREBUILT_HASH_LIST}
1246 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1260 --output-file ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE}
1261 --multiple-iterations 10
1276 -i ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC_PRE}
1277 -o ${KOBJECT_PREBUILT_HASH_OUTPUT_SRC}
1278 -p "struct k_object"
1279 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1295 "${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
1309 set(KOBJECT_LINKER_HEADER_DATA "${PROJECT_BINARY_DIR}/include/generated/zephyr/linker-kobject-prebuilt-data.h")
1316 --object $<TARGET_OBJECTS:kobj_prebuilt_hash_output_lib>
1317 --outdir ${PROJECT_BINARY_DIR}/include/generated/zephyr
1318 --datapct ${CONFIG_KOBJECT_DATA_AREA_RESERVE_EXTRA_PERCENT}
1319 --rodata ${CONFIG_KOBJECT_RODATA_AREA_EXTRA_BYTES}
1320 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1382 list(APPEND GEN_ISR_TABLE_EXTRA_ARG --sw-isr-table)
1386 list(APPEND GEN_ISR_TABLE_EXTRA_ARG --vector-table)
1395 --output-source isr_tables.c
1396 --linker-output-files isr_tables_vt.ld isr_tables_swi.ld
1397 --kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1398 --intlist-section .intList
1399 --intlist-section intList
1400 $<$<BOOL:${CONFIG_BIG_ENDIAN}>:--big-endian>
1401 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--debug>
1415 -k $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1416 -o symtab.c
1433 # elf file. More information in gen_kobject_list.py --help.
1443 --kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
1444 --gperf-output ${KOBJECT_HASH_LIST}
1446 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1462 --output-file ${KOBJECT_HASH_OUTPUT_SRC_PRE}
1463 --multiple-iterations 10
1483 -i ${KOBJECT_HASH_OUTPUT_SRC_PRE}
1484 -o ${KOBJECT_HASH_OUTPUT_SRC}
1485 -p "struct k_object"
1486 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
1505 "${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
1668 ${CMAKE_COMMAND} -E copy ${logical_target_for_zephyr_elf}.map ${KERNEL_MAP_NAME}
1791 -c
1792 -f ${CONFIG_BUILD_OUTPUT_UF2_FAMILY_ID}
1793 -b ${flash_addr}
1794 -o ${KERNEL_UF2_NAME}
1811 --meta-out ${KERNEL_META_PATH}
1812 --zephyr-base=${ZEPHYR_BASE}
1813 $<$<BOOL:${CONFIG_BUILD_OUTPUT_META_STATE_PROPAGATE}>:--meta-state-propagate>
1831 ${CMAKE_COMMAND} -E remove zephyr_pre${index}.elf
1943 ${CMAKE_COMMAND} -E copy ${KERNEL_ELF_NAME} ${KERNEL_EXE_NAME}
1951 set(MAKE "${CMAKE_MAKE_PROGRAM}" CACHE FILEPATH "cmake defined make")
1958 ${MAKE} -f ${ZEPHYR_BASE}/scripts/native_simulator/Makefile all --warn-undefined-variables
1959 -r NSI_CONFIG_FILE=${APPLICATION_BINARY_DIR}/zephyr/NSI/nsi_config
1960 # nsi_config is created by the board cmake file
1972 --elf-file=${KERNEL_ELF_NAME}
1973 --header-file=${PROJECT_BINARY_DIR}/include/public/zephyr_image_info.h
1974 $<$<BOOL:${adjustment}>:--adjusted-lma=${adjustment}>
1983 #slidgen must be the first post-build command to be executed
1990 --elf-file ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME}
1991 --slid-listing ${PROJECT_BINARY_DIR}/slid_listing.txt
2002 --elf-file=${check_init_priorities_input}
2021 COMMAND ${check_init_priorities_command} --initlevels
2037 set(signing_script ${CMAKE_CURRENT_LIST_DIR}/cmake/mcuboot.cmake)
2048 # Generate USB-C VIF policies in XML format
2050 include(${CMAKE_CURRENT_LIST_DIR}/cmake/vif.cmake)
2075 set(LOG_DICT_DB_NAME_ARG --json)
2078 set(LOG_DICT_DB_NAME_ARG --syst)
2087 --build-header ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
2096 COMMAND ${CMAKE_COMMAND} -E echo "Generating logging dictionary database: ${LOG_DICT_DB_NAME}"
2117 # Add post_build_commands to post-process the final .elf file produced by
2123 COMMAND ${CMAKE_COMMAND} -E echo "Generating files from ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} for board: ${BOARD}"
2135 # Merge in out-of-tree hex files.
2143 -o ${MERGED_HEX_NAME}
2156 if(EXISTS ${ZEPHYR_BASE}/cmake/emu/${default_emu}.cmake)
2161 if(EXISTS ${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake)
2162 include(${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake)
2172 ${CMAKE_COMMAND} -E echo
2179 add_subdirectory(cmake/flash)
2180 add_subdirectory(cmake/usage)
2181 add_subdirectory(cmake/reports)
2203 # In CMake projects, 'CMAKE_BUILD_TYPE' usually determines the
2213 # To avoid false-positive matches, the flag must either be matched first
2217 The CMake build type was set to '${CMAKE_BUILD_TYPE}', but the optimization flag was set to '${OPTIMIZATION_FLAG}'.
2218 This may be intentional and the warning can be turned off by setting the CMake variable 'NO_BUILD_TYPE_WARNING'"
2230 # Filter out non LLEXT and LLEXT_EDK flags - and add required ones
2234 set(llext_edk_cflags ${zephyr_defs} -DLL_EXTENSION_BUILD)
2243 -E make_directory edk/include/generated/zephyr
2247 --json-file ${syscalls_json} # Read this file
2248 --base-output edk/include/generated/zephyr/syscalls # Write to this dir
2249 --syscall-dispatch edk/include/generated/zephyr/syscall_dispatch.c # Write this file
2250 --syscall-list ${edk_syscall_list_h}
2251 $<$<BOOL:${CONFIG_LLEXT_EDK_USERSPACE_ONLY}>:--userspace-only>
2255 -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
2256 -DAPPLICATION_SOURCE_DIR=${APPLICATION_SOURCE_DIR}
2257 -DINTERFACE_INCLUDE_DIRECTORIES="$<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>"
2258 -Dllext_edk_file=${llext_edk_file}
2259 -Dllext_edk_cflags="${llext_edk_cflags}"
2260 -Dllext_edk_name=${CONFIG_LLEXT_EDK_NAME}
2261 -DWEST_TOPDIR=${WEST_TOPDIR}
2262 -DZEPHYR_BASE=${ZEPHYR_BASE}
2263 -DCONFIG_LLEXT_EDK_USERSPACE_ONLY=${CONFIG_LLEXT_EDK_USERSPACE_ONLY}
2264 -P ${ZEPHYR_BASE}/cmake/llext-edk.cmake
2268 add_custom_target(llext-edk DEPENDS ${llext_edk_file})
2278 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,nostdincxx>>)
2284 cmake/makefile_exports
2292 build_info(zephyr zephyr-base VALUE ${ZEPHYR_BASE})