style: cmake: apply coding style on CMakeLists.txt files

Apply the CMake style guidelines to all CMakeList.txt files in cmake/.

Signed-off-by: Josuah Demangeon <me@josuah.net>
This commit is contained in:
Josuah Demangeon
2025-11-15 16:33:01 +00:00
committed by Anas Nashif
parent 42a0111133
commit bf9c3b150d
16 changed files with 219 additions and 196 deletions

View File

@@ -16,16 +16,16 @@ endif()
set(qemu_alternate_path $ENV{QEMU_BIN_PATH})
if(qemu_alternate_path)
find_program(
QEMU
PATHS ${qemu_alternate_path}
NO_DEFAULT_PATH
NAMES qemu-system-${QEMU_binary_suffix}
find_program(
QEMU
PATHS ${qemu_alternate_path}
NO_DEFAULT_PATH
NAMES qemu-system-${QEMU_binary_suffix}
)
else()
find_program(
QEMU
qemu-system-${QEMU_binary_suffix}
find_program(
QEMU
qemu-system-${QEMU_binary_suffix}
)
endif()
@@ -45,7 +45,7 @@ endif()
set(qemu_targets
run_qemu
debugserver_qemu
)
)
set(QEMU_FLAGS -pidfile)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
@@ -86,7 +86,7 @@ endif()
if(CONFIG_SEMIHOST)
list(APPEND QEMU_FLAGS
-semihosting-config enable=on,target=auto,chardev=con
)
)
endif()
# Connect monitor to the console chardev.
@@ -99,12 +99,14 @@ endif()
if(CONFIG_QEMU_ICOUNT)
if(CONFIG_QEMU_ICOUNT_SLEEP)
list(APPEND QEMU_FLAGS
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
-rtc clock=vm)
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
-rtc clock=vm
)
else()
list(APPEND QEMU_FLAGS
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=off
-rtc clock=vm)
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=off
-rtc clock=vm
)
endif()
endif()
@@ -112,7 +114,7 @@ endif()
# application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER.
if(CONFIG_BT)
if(NOT CONFIG_BT_UART)
set(NO_QEMU_SERIAL_BT_SERVER 1)
set(NO_QEMU_SERIAL_BT_SERVER 1)
endif()
if(NOT NO_QEMU_SERIAL_BT_SERVER)
list(APPEND QEMU_FLAGS -serial unix:/tmp/bt-server-bredr)
@@ -130,7 +132,7 @@ if(CONFIG_NETWORKING)
set(QEMU_NET_STACK 1)
endif()
elseif((CONFIG_NET_QEMU_PPP) AND NOT (CONFIG_NET_TEST))
set(QEMU_NET_STACK 1)
set(QEMU_NET_STACK 1)
endif()
endif()
@@ -138,7 +140,7 @@ endif()
if(QEMU_PIPE_STACK)
list(APPEND qemu_targets
node
)
)
if(NOT QEMU_PIPE_ID)
set(QEMU_PIPE_ID 1)
@@ -146,12 +148,12 @@ if(QEMU_PIPE_STACK)
list(APPEND QEMU_FLAGS
-serial none
)
)
list(APPEND MORE_FLAGS_FOR_node
-serial pipe:/tmp/hub/ip-stack-node${QEMU_PIPE_ID}
-pidfile qemu-node${QEMU_PIPE_ID}.pid
)
-serial pipe:/tmp/hub/ip-stack-node${QEMU_PIPE_ID}
-pidfile qemu-node${QEMU_PIPE_ID}.pid
)
set(PIPE_NODE_IN /tmp/hub/ip-stack-node${QEMU_PIPE_ID}.in)
set(PIPE_NODE_OUT /tmp/hub/ip-stack-node${QEMU_PIPE_ID}.out)
@@ -159,60 +161,60 @@ if(QEMU_PIPE_STACK)
set(pipes
${PIPE_NODE_IN}
${PIPE_NODE_OUT}
)
)
set(destroy_pipe_commands
COMMAND ${CMAKE_COMMAND} -E remove -f ${pipes}
)
)
set(create_pipe_commands
COMMAND ${CMAKE_COMMAND} -E make_directory /tmp/hub
COMMAND mkfifo ${PIPE_NODE_IN}
COMMAND mkfifo ${PIPE_NODE_OUT}
)
)
set(PRE_QEMU_COMMANDS_FOR_node
${destroy_pipe_commands}
${create_pipe_commands}
)
)
elseif(QEMU_NET_STACK)
list(APPEND qemu_targets
client
server
)
)
foreach(target ${qemu_targets})
if((${target} STREQUAL client) OR (${target} STREQUAL server))
list(APPEND MORE_FLAGS_FOR_${target}
-serial pipe:/tmp/ip-stack-${target}
-pidfile qemu-${target}.pid
)
)
else()
# QEMU_INSTANCE is a command line argument to *make* (not cmake). By
# appending the instance name to the pid file we can easily run more
# instances of the same sample.
if(CONFIG_NET_QEMU_PPP)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(ppp_path unix:/tmp/ppp\${QEMU_INSTANCE})
else()
set(ppp_path unix:/tmp/ppp${QEMU_INSTANCE})
endif()
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(ppp_path unix:/tmp/ppp\${QEMU_INSTANCE})
else()
set(ppp_path unix:/tmp/ppp${QEMU_INSTANCE})
endif()
list(APPEND MORE_FLAGS_FOR_${target}
list(APPEND MORE_FLAGS_FOR_${target}
-serial ${ppp_path}
)
)
else()
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(tmp_file unix:/tmp/slip.sock\${QEMU_INSTANCE})
else()
else()
set(tmp_file unix:/tmp/slip.sock${QEMU_INSTANCE})
endif()
endif()
list(APPEND MORE_FLAGS_FOR_${target}
list(APPEND MORE_FLAGS_FOR_${target}
-serial ${tmp_file}
)
)
endif()
endif()
@@ -229,34 +231,34 @@ elseif(QEMU_NET_STACK)
${PIPE_SERVER_OUT}
${PIPE_CLIENT_IN}
${PIPE_CLIENT_OUT}
)
)
set(destroy_pipe_commands
COMMAND ${CMAKE_COMMAND} -E remove -f ${pipes}
)
)
# TODO: Port to Windows. Perhaps using python? Or removing the
# need for mkfifo and create_symlink somehow.
set(create_pipe_commands
COMMAND mkfifo ${PIPE_SERVER_IN}
COMMAND mkfifo ${PIPE_SERVER_OUT}
)
)
if(PCAP)
list(APPEND create_pipe_commands
COMMAND mkfifo ${PIPE_CLIENT_IN}
COMMAND mkfifo ${PIPE_CLIENT_OUT}
)
)
else()
list(APPEND create_pipe_commands
COMMAND ${CMAKE_COMMAND} -E create_symlink ${PIPE_SERVER_IN} ${PIPE_CLIENT_OUT}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${PIPE_SERVER_OUT} ${PIPE_CLIENT_IN}
)
)
endif()
set(PRE_QEMU_COMMANDS_FOR_server
${destroy_pipe_commands}
${create_pipe_commands}
)
)
if(PCAP)
# Start a monitor application to capture traffic
#
@@ -282,14 +284,14 @@ elseif(QEMU_NET_STACK)
/tmp/ip-stack-client
> /dev/null &
}
)
)
set(POST_QEMU_COMMANDS_FOR_server
# Re-enable Ctrl-C.
COMMAND stty intr ^c
# Kill the monitor_15_4 sub-process
COMMAND pkill -P $$$$
)
)
endif()
endif(QEMU_PIPE_STACK)
@@ -300,7 +302,8 @@ if(CONFIG_CAN AND NOT (CONFIG_SOC_LEON3))
if(NOT "${CONFIG_CAN_QEMU_IFACE_NAME}" STREQUAL "")
# Connect CAN bus 0 to host SocketCAN interface
list(APPEND QEMU_FLAGS
-object can-host-socketcan,id=canhost0,if=${CONFIG_CAN_QEMU_IFACE_NAME},canbus=canbus0)
-object can-host-socketcan,id=canhost0,if=${CONFIG_CAN_QEMU_IFACE_NAME},canbus=canbus0
)
endif()
if(CONFIG_CAN_KVASER_PCI)
@@ -319,7 +322,7 @@ if(CONFIG_X86_64 AND NOT CONFIG_QEMU_UEFI_BOOT)
$<TARGET_FILE:${logical_target_for_zephyr_elf}>
${ZEPHYR_BINARY_DIR}/zephyr-qemu.elf
DEPENDS ${logical_target_for_zephyr_elf}
)
)
# Split the 'locore' and 'main' memory regions into separate executable
# images and specify the 'locore' as the boot kernel, in order to prevent
@@ -334,7 +337,7 @@ if(CONFIG_X86_64 AND NOT CONFIG_QEMU_UEFI_BOOT)
${ZEPHYR_BINARY_DIR}/zephyr-qemu-locore.elf
2>&1 | grep -iv \"empty loadable segment detected\" || true
DEPENDS qemu_image_target
)
)
add_custom_target(qemu_main_image_target
COMMAND
@@ -344,18 +347,18 @@ if(CONFIG_X86_64 AND NOT CONFIG_QEMU_UEFI_BOOT)
${ZEPHYR_BINARY_DIR}/zephyr-qemu-main.elf
2>&1 | grep -iv \"empty loadable segment detected\" || true
DEPENDS qemu_image_target
)
)
add_custom_target(
qemu_kernel_target
DEPENDS qemu_locore_image_target qemu_main_image_target
)
)
set(QEMU_KERNEL_FILE "${ZEPHYR_BINARY_DIR}/zephyr-qemu-locore.elf")
list(APPEND QEMU_EXTRA_FLAGS
"-device;loader,file=${ZEPHYR_BINARY_DIR}/zephyr-qemu-main.elf"
)
)
endif()
if(CONFIG_IVSHMEM)
@@ -465,7 +468,7 @@ foreach(target ${qemu_targets})
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
COMMENT "${QEMU_PIPE_COMMENT}[QEMU] CPU: ${QEMU_CPU_TYPE_${ARCH}}"
USES_TERMINAL
)
)
if(DEFINED QEMU_KERNEL_FILE)
add_dependencies(${target} qemu_nvme_disk qemu_kernel_target)
endif()

View File

@@ -24,14 +24,14 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
else()
# TODO: How would the linker script dependencies work for non-linker
# script generators.
message(STATUS "Warning; this generator is not well supported. The
Linker script may not be regenerated when it should.")
message(STATUS "Warning: this generator is not well supported. The "
"Linker script may not be regenerated when it should.")
set(linker_script_dep "")
endif()
zephyr_get_include_directories_for_lang(C current_includes)
# the command to generate linker file from template
# the command to generate linker file from template
add_custom_command(
OUTPUT ${linker_script_gen}
DEPENDS
@@ -57,7 +57,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMAND_EXPAND_LISTS
)
)
endmacro()
# Force symbols to be entered in the output file as undefined symbols
@@ -119,20 +119,24 @@ endmacro()
# generate linker script snippets from configure files
macro(toolchain_ld_configure_files)
configure_file(
$ENV{ZEPHYR_BASE}/include/zephyr/arch/common/app_data_alignment.ld
${PROJECT_BINARY_DIR}/include/generated/app_data_alignment.ld)
$ENV{ZEPHYR_BASE}/include/zephyr/arch/common/app_data_alignment.ld
${PROJECT_BINARY_DIR}/include/generated/app_data_alignment.ld
)
configure_file(
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem.ld)
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem.ld
)
configure_file(
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem_aligned.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem_aligned.ld)
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem_aligned.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem_aligned.ld
)
configure_file(
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem_unaligned.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem_unaligned.ld)
$ENV{ZEPHYR_BASE}/include/zephyr/linker/app_smem_unaligned.ld
${PROJECT_BINARY_DIR}/include/generated/app_smem_unaligned.ld
)
endmacro()
# link C++ libraries
@@ -161,11 +165,12 @@ macro(toolchain_ld_relocation)
-b ${MEM_RELOCATION_SRAM_BSS_LD}
-c ${MEM_RELOCATION_CODE}
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
)
)
add_library(code_relocation_source_lib STATIC ${MEM_RELOCATION_CODE})
target_include_directories(code_relocation_source_lib PRIVATE
${ZEPHYR_BASE}/kernel/include ${ARCH_DIR}/${ARCH}/include)
${ZEPHYR_BASE}/kernel/include ${ARCH_DIR}/${ARCH}/include
)
target_link_libraries(code_relocation_source_lib zephyr_interface)
endmacro()

View File

@@ -29,7 +29,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
set(STEERING_FILE "${CMAKE_CURRENT_BINARY_DIR}/${linker_script_gen}.xcl")
set(STEERING_FILE_ARG "-DSTEERING_FILE=${STEERING_FILE}")
set(cmake_linker_script_settings
${PROJECT_BINARY_DIR}/include/generated/ld_script_settings_${linker_pass_define}.cmake
${PROJECT_BINARY_DIR}/include/generated/ld_script_settings_${linker_pass_define}.cmake
)
if("${linker_pass_define}" STREQUAL "LINKER_ZEPHYR_PREBUILT")
set(ILINK_THUMB_CALLS_WARNING_SUPPRESSED "--diag_suppress=Lt056")
@@ -44,13 +44,15 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
zephyr_linker_generate_linker_settings_file(${cmake_linker_script_settings})
add_custom_command(
OUTPUT ${linker_script_gen}
${STEERING_FILE}
OUTPUT
${linker_script_gen}
${STEERING_FILE}
DEPENDS
${extra_dependencies}
${cmake_linker_script_settings}
${DEVICE_API_LD_TARGET}
COMMAND ${CMAKE_COMMAND}
${extra_dependencies}
${cmake_linker_script_settings}
${DEVICE_API_LD_TARGET}
COMMAND
${CMAKE_COMMAND}
-C ${cmake_linker_script_settings}
-DPASS="${linker_pass_define}"
${STEERING_FILE_ARG}
@@ -72,7 +74,7 @@ function(toolchain_ld_link_elf)
set(whole_libs)
foreach(lib ${WHOLE_ARCHIVE_LIBS})
list(APPEND whole_libs --whole_archive ${lib})
list(APPEND whole_libs --whole_archive ${lib})
endforeach()
set(ILINK_SEMIHOSTING)

View File

@@ -3,7 +3,7 @@
# See root CMakeLists.txt for description and expectations of these macros
macro(toolchain_ld_relocation)
set(MEM_RELOCATION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
set(MEM_RELOCATION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
set(MEM_RELOCATION_SRAM_DATA_LD
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_data_relocate.ld")
set(MEM_RELOCATION_SRAM_BSS_LD
@@ -13,30 +13,38 @@ macro(toolchain_ld_relocation)
set(DICT_FILE "${PROJECT_BINARY_DIR}/relocation_dict.txt")
file(GENERATE
OUTPUT
${DICT_FILE}
CONTENT
$<TARGET_PROPERTY:code_data_relocation_target,INTERFACE_SOURCES>
OUTPUT
${DICT_FILE}
CONTENT
$<TARGET_PROPERTY:code_data_relocation_target,INTERFACE_SOURCES>
)
add_custom_command(
OUTPUT ${MEM_RELOCATION_CODE} ${MEM_RELOCATION_LD}
OUTPUT
${MEM_RELOCATION_CODE}
${MEM_RELOCATION_LD}
COMMAND
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/build/gen_relocate_app.py
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
-d ${APPLICATION_BINARY_DIR}
-i ${DICT_FILE}
-o ${MEM_RELOCATION_LD}
-s ${MEM_RELOCATION_SRAM_DATA_LD}
-b ${MEM_RELOCATION_SRAM_BSS_LD}
-c ${MEM_RELOCATION_CODE}
--default_ram_region ${MEM_REGION_DEFAULT_RAM}
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY} ${DICT_FILE}
)
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/build/gen_relocate_app.py
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
-d ${APPLICATION_BINARY_DIR}
-i ${DICT_FILE}
-o ${MEM_RELOCATION_LD}
-s ${MEM_RELOCATION_SRAM_DATA_LD}
-b ${MEM_RELOCATION_SRAM_BSS_LD}
-c ${MEM_RELOCATION_CODE}
--default_ram_region ${MEM_REGION_DEFAULT_RAM}
DEPENDS
app
kernel
${ZEPHYR_LIBS_PROPERTY}
${DICT_FILE}
)
add_library(code_relocation_source_lib STATIC ${MEM_RELOCATION_CODE})
target_include_directories(code_relocation_source_lib PRIVATE
${ZEPHYR_BASE}/kernel/include ${ARCH_DIR}/${ARCH}/include)
target_include_directories(code_relocation_source_lib
PRIVATE
${ZEPHYR_BASE}/kernel/include ${ARCH_DIR}/${ARCH}/include
)
target_link_libraries(code_relocation_source_lib zephyr_interface)
endmacro()

View File

@@ -152,7 +152,7 @@ if(CONFIG_USERSPACE)
# handling in arch_data_copy, so put it in RAM_REGION rather than DATA_REGION
zephyr_linker_group(NAME APP_SMEM_GROUP GROUP RAM_REGION SYMBOL SECTION)
zephyr_linker_symbol(SYMBOL "_app_smem_size" EXPR "@__app_smem_group_size@")
zephyr_linker_symbol(SYMBOL "_app_smem_rom_start" EXPR "@__app_smem_group_load_start@")
zephyr_linker_symbol(SYMBOL "_app_smem_rom_start" EXPR "@__app_smem_group_load_start@")
zephyr_linker_section(NAME .bss GROUP RAM_REGION TYPE BSS)

View File

@@ -27,37 +27,40 @@ if((DEFINED WEST) AND (NOT DEFINED BSIM_COMPONENTS_PATH) AND (NOT DEFINED BSIM_O
status babblesim_base
OUTPUT_QUIET
ERROR_QUIET
RESULT_VARIABLE ret_val1)
RESULT_VARIABLE ret_val1
)
execute_process(COMMAND ${WEST}
list babblesim_base -f {posixpath}
OUTPUT_VARIABLE BSIM_BASE_PATH
ERROR_QUIET
RESULT_VARIABLE ret_val2)
RESULT_VARIABLE ret_val2
)
if(NOT (${ret_val1} OR ${ret_val2}))
string(STRIP ${BSIM_BASE_PATH} BSIM_COMPONENTS_PATH)
get_filename_component(BSIM_OUT_PATH ${BSIM_COMPONENTS_PATH}/.. ABSOLUTE)
endif()
endif()
message(STATUS "Using BSIM from BSIM_COMPONENTS_PATH=${BSIM_COMPONENTS_PATH}\
BSIM_OUT_PATH=${BSIM_OUT_PATH}")
message(STATUS "Using BSIM from BSIM_COMPONENTS_PATH=${BSIM_COMPONENTS_PATH} "
"BSIM_OUT_PATH=${BSIM_OUT_PATH}")
if((NOT DEFINED BSIM_COMPONENTS_PATH) OR (NOT DEFINED BSIM_OUT_PATH))
message(FATAL_ERROR "This board requires the BabbleSim simulator. Please either\n\
a) Enable the west babblesim group with\n\
west config manifest.group-filter +babblesim && west update\n\
and build it with\n\
cd ${ZEPHYR_BASE}/../tools/bsim\n\
make everything -j 8\n\
OR\n\
b) set the environment variable BSIM_COMPONENTS_PATH to point to your own bsim installation\n\
`components/` folder, *and* BSIM_OUT_PATH to point to the folder where the simulator\n\
is compiled to.\n\
More information can be found in https://babblesim.github.io/folder_structure_and_env.html"
message(FATAL_ERROR
"This board requires the BabbleSim simulator. Please either\n"
" a) Enable the west babblesim group with\n"
" west config manifest.group-filter +babblesim && west update\n"
" and build it with\n"
" cd ${ZEPHYR_BASE}/../tools/bsim\n"
" make everything -j 8\n"
" OR\n"
" b) set the environment variable BSIM_COMPONENTS_PATH to point to your own bsim installation\n"
" `components/` folder, *and* BSIM_OUT_PATH to point to the folder where the simulator\n"
" is compiled to.\n"
" More information can be found in https://babblesim.github.io/folder_structure_and_env.html"
)
endif()
#Many apps cmake files (in and out of tree) expect these environment variables. Lets provide them:
# Many apps cmake files (in and out of tree) expect these environment variables. Lets provide them:
set(ENV{BSIM_COMPONENTS_PATH} ${BSIM_COMPONENTS_PATH})
set(ENV{BSIM_OUT_PATH} ${BSIM_OUT_PATH})
@@ -68,10 +71,11 @@ set(ENV{BSIM_OUT_PATH} ${BSIM_OUT_PATH})
# Do NOT use it outside of this module. It uses variables internal to it
function(bsim_handle_not_built_error)
get_filename_component(BSIM_ROOT_PATH ${BSIM_COMPONENTS_PATH}/.. ABSOLUTE)
message(FATAL_ERROR "Please ensure you have the latest babblesim and rebuild it."
"If you got it from Zephyr's manifest, you can do:\n\
west update\n\
cd ${BSIM_ROOT_PATH}; make everything -j 8\n"
message(FATAL_ERROR
"Please ensure you have the latest babblesim and rebuild it.\n"
"If you got it from Zephyr's manifest, you can do:\n"
" west update\n"
" cd ${BSIM_ROOT_PATH}; make everything -j 8"
)
endfunction(bsim_handle_not_built_error)
@@ -88,8 +92,8 @@ function(bsim_check_build_version bs_comp req_comp_ver)
endif()
if(found_version VERSION_LESS req_comp_ver)
message(WARNING
"Built ${bs_comp} version = ${found_version} < ${req_comp_ver} (required version)")
message(WARNING "Built ${bs_comp} version = ${found_version} < ${req_comp_ver} "
"(required version)")
bsim_handle_not_built_error()
endif()
endfunction(bsim_check_build_version)

View File

@@ -43,11 +43,11 @@ if("toolchain_ld_base" IN_LIST Deprecated_FIND_COMPONENTS)
if(COMMAND toolchain_ld_base)
message(DEPRECATION
"The macro/function 'toolchain_ld_base' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
"The macro/function 'toolchain_ld_base' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
)
toolchain_ld_base()
endif()
@@ -59,11 +59,11 @@ if("toolchain_ld_baremetal" IN_LIST Deprecated_FIND_COMPONENTS)
if(COMMAND toolchain_ld_baremetal)
message(DEPRECATION
"The macro/function 'toolchain_ld_baremetal' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
"The macro/function 'toolchain_ld_baremetal' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
)
toolchain_ld_baremetal()
endif()
@@ -75,11 +75,11 @@ if("toolchain_ld_cpp" IN_LIST Deprecated_FIND_COMPONENTS)
if(COMMAND toolchain_ld_cpp)
message(DEPRECATION
"The macro/function 'toolchain_ld_cpp' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
"The macro/function 'toolchain_ld_cpp' is deprecated. "
"Please use '${LINKER}/linker_flags.cmake' and define the appropriate "
"linker flags as properties instead. "
"See '${ZEPHYR_BASE}/cmake/linker/linker_flags_template.cmake' for "
"known linker properties."
)
toolchain_ld_cpp()
endif()
@@ -87,7 +87,7 @@ endif()
if(NOT "${Deprecated_FIND_COMPONENTS}" STREQUAL "")
message(STATUS "The following deprecated component(s) could not be found: "
"${Deprecated_FIND_COMPONENTS}")
"${Deprecated_FIND_COMPONENTS}")
endif()
set(Deprecated_FOUND True)

View File

@@ -19,7 +19,7 @@
find_program(
DTC
dtc
)
)
if(DTC)
# Parse the 'dtc --version' output to find the installed version.
@@ -29,7 +29,7 @@ if(DTC)
OUTPUT_VARIABLE dtc_version_output
ERROR_VARIABLE dtc_error_output
RESULT_VARIABLE dtc_status
)
)
set(DTC_VERSION_STRING)
if(${dtc_status} EQUAL 0)
@@ -39,8 +39,8 @@ if(DTC)
endif()
find_package_handle_standard_args(Dtc
REQUIRED_VARS DTC
VERSION_VAR DTC_VERSION_STRING
REQUIRED_VARS DTC
VERSION_VAR DTC_VERSION_STRING
)
if(NOT Dtc_FOUND)

View File

@@ -29,12 +29,10 @@ include(FindPackageHandleStandardArgs)
if(EXISTS "${GNULD_LINKER}")
if(NOT DEFINED GNULD_LINKER_IS_BFD)
# ... issue warning if GNULD_LINKER_IS_BFD is not already set.
message(
WARNING
message(WARNING
"GNULD_LINKER specified directly in cache, but GNULD_LINKER_IS_BFD is not "
"defined. Assuming GNULD_LINKER_IS_BFD as OFF, please set GNULD_LINKER_IS_BFD "
"to correct value in cache to silence this warning"
)
"to correct value in cache to silence this warning")
set(GNULD_LINKER_IS_BFD OFF)
endif()
@@ -43,9 +41,11 @@ if(EXISTS "${GNULD_LINKER}")
endif()
# See if the compiler has a preferred linker
execute_process(COMMAND ${CMAKE_C_COMPILER} --print-prog-name=ld.bfd
OUTPUT_VARIABLE GNULD_LINKER
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-prog-name=ld.bfd
OUTPUT_VARIABLE GNULD_LINKER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(EXISTS "${GNULD_LINKER}")
cmake_path(NORMAL_PATH GNULD_LINKER)
@@ -73,12 +73,11 @@ endif()
if(GNULD_LINKER)
# Parse the 'ld.bfd --version' output to find the installed version.
execute_process(
COMMAND
${GNULD_LINKER} --version
COMMAND ${GNULD_LINKER} --version
OUTPUT_VARIABLE gnuld_version_output
ERROR_VARIABLE gnuld_error_output
RESULT_VARIABLE gnuld_status
)
)
if(${gnuld_status} EQUAL 0)
# Extract GNU ld version. Different distros have their
@@ -88,14 +87,15 @@ if(GNULD_LINKER)
# - "GNU ld (Zephyr SDK 0.15.2) 2.38"
# - "GNU ld (Gentoo 2.39 p5) 2.39.0"
# - "GNU ld version 2.17.50.0.9 20070103"
string(REGEX MATCH
"GNU ld (\\(.+\\)|version) ([0-9]+[.][0-9]+[.]?[0-9]*).*"
out_var ${gnuld_version_output})
string(REGEX
MATCH "GNU ld (\\(.+\\)|version) ([0-9]+[.][0-9]+[.]?[0-9]*).*"
out_var ${gnuld_version_output}
)
set(GNULD_VERSION_STRING ${CMAKE_MATCH_2} CACHE STRING "GNU ld version" FORCE)
endif()
endif()
find_package_handle_standard_args(GnuLd
REQUIRED_VARS GNULD_LINKER
VERSION_VAR GNULD_VERSION_STRING
REQUIRED_VARS GNULD_LINKER
VERSION_VAR GNULD_VERSION_STRING
)

View File

@@ -20,9 +20,11 @@
include(FindPackageHandleStandardArgs)
# See if the compiler has a preferred linker
execute_process(COMMAND ${CMAKE_C_COMPILER} --print-prog-name=ld.lld
OUTPUT_VARIABLE LLVMLLD_LINKER
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-prog-name=ld.lld
OUTPUT_VARIABLE LLVMLLD_LINKER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT EXISTS "${LLVMLLD_LINKER}")
# Need to clear it or else find_program() won't replace the value.
@@ -44,12 +46,11 @@ endif()
if(LLVMLLD_LINKER)
# Parse the 'ld.lld --version' output to find the installed version.
execute_process(
COMMAND
${LLVMLLD_LINKER} --version
COMMAND ${LLVMLLD_LINKER} --version
OUTPUT_VARIABLE llvmlld_version_output
ERROR_VARIABLE llvmlld_error_output
RESULT_VARIABLE llvmlld_status
)
)
set(LLVMLLD_VERSION_STRING)
if(${llvmlld_status} EQUAL 0)
@@ -59,14 +60,15 @@ if(LLVMLLD_LINKER)
# - "GNU ld (GNU Binutils for Ubuntu) 2.34"
# - "GNU ld (Zephyr SDK 0.15.2) 2.38"
# - "GNU ld (Gentoo 2.39 p5) 2.39.0"
string(REGEX MATCH
"LLD ([0-9]+[.][0-9]+[.]?[0-9]*).*"
out_var ${llvmlld_version_output})
string(REGEX
MATCH "LLD ([0-9]+[.][0-9]+[.]?[0-9]*).*"
out_var ${llvmlld_version_output}
)
set(LLVMLLD_VERSION_STRING ${CMAKE_MATCH_1})
endif()
endif()
find_package_handle_standard_args(LlvmLld
REQUIRED_VARS LLVMLLD_LINKER
VERSION_VAR LLVMLLD_VERSION_STRING
REQUIRED_VARS LLVMLLD_LINKER
VERSION_VAR LLVMLLD_VERSION_STRING
)

View File

@@ -10,8 +10,7 @@ zephyr_get(ZEPHYR_SCA_VARIANT)
if(ScaTools_FIND_REQUIRED AND NOT DEFINED ZEPHYR_SCA_VARIANT)
message(FATAL_ERROR "ScaTools required but 'ZEPHYR_SCA_VARIANT' is not set. "
"Please set 'ZEPHYR_SCA_VARIANT' to desired tool."
)
"Please set 'ZEPHYR_SCA_VARIANT' to desired tool.")
endif()
if(NOT DEFINED ZEPHYR_SCA_VARIANT)
@@ -26,6 +25,4 @@ foreach(root ${SCA_ROOT})
endforeach()
message(FATAL_ERROR "ZEPHYR_SCA_VARIANT set to '${ZEPHYR_SCA_VARIANT}' but no "
"implementation for '${ZEPHYR_SCA_VARIANT}' found. "
"SCA_ROOTs searched: ${SCA_ROOT}"
)
"implementation for '${ZEPHYR_SCA_VARIANT}' found. SCA_ROOTs searched: ${SCA_ROOT}")

View File

@@ -32,7 +32,10 @@ if(DEFINED CONFIG_POSIX_THREADS)
set(CMAKE_USE_PTHREADS_INIT 1)
endif()
find_package_handle_standard_args(Threads DEFAULT_MSG Threads_FOUND)
find_package_handle_standard_args(Threads
DEFAULT_MSG
Threads_FOUND
)
if(Threads_FOUND AND NOT TARGET Threads::Threads)
# This is just an empty interface, because we don't need to provide any

View File

@@ -55,14 +55,15 @@ endif()
# 2) No toolchain specified == Default to Zephyr toolchain
# Until we completely deprecate it
if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT) OR
(DEFINED ZEPHYR_SDK_INSTALL_DIR) OR
(Zephyr-sdk_FIND_REQUIRED))
(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT) OR
(DEFINED ZEPHYR_SDK_INSTALL_DIR) OR
(Zephyr-sdk_FIND_REQUIRED)
)
# No toolchain was specified, so inform user that we will be searching.
if(NOT Zephyr-sdk_FIND_QUIETLY AND
NOT DEFINED ZEPHYR_SDK_INSTALL_DIR AND
NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT)
NOT DEFINED ZEPHYR_SDK_INSTALL_DIR AND
NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT)
message(STATUS "ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK")
endif()
@@ -86,13 +87,14 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
else()
# Paths that are used to find installed Zephyr SDK versions
SET(zephyr_sdk_search_paths
/usr
/usr/local
/opt
$ENV{HOME}
$ENV{HOME}/.local
$ENV{HOME}/.local/opt
$ENV{HOME}/bin)
/usr
/usr/local
/opt
$ENV{HOME}
$ENV{HOME}/.local
$ENV{HOME}/.local/opt
$ENV{HOME}/bin
)
# Search for Zephyr SDK version 0.0.0 which does not exist, this is needed to
# return a list of compatible versions and find the best suited version that
@@ -135,8 +137,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
# Loop over each found Zepher SDK version until one is found that is compatible.
foreach(zephyr_sdk_candidate ${Zephyr-sdk_CONSIDERED_VERSIONS})
if("${zephyr_sdk_candidate}" VERSION_GREATER_EQUAL "${Zephyr-sdk_FIND_VERSION}"
AND "${zephyr_sdk_candidate}" VERSION_LESS${upper_bound} "${Zephyr-sdk_FIND_VERSION_MAX}"
)
AND "${zephyr_sdk_candidate}" VERSION_LESS${upper_bound} "${Zephyr-sdk_FIND_VERSION_MAX}")
# Find the path for the current version being checked and get the directory
# of the Zephyr SDK so it can be checked.
cmake_path(GET Zephyr-sdk-${zephyr_sdk_candidate}_DIR PARENT_PATH zephyr_sdk_current_check_path)

View File

@@ -29,6 +29,6 @@ if(CMAKE_C_COMPILER)
endif()
find_package_handle_standard_args(armclang
REQUIRED_VARS CMAKE_C_COMPILER
VERSION_VAR ARMCLANG_VERSION
REQUIRED_VARS CMAKE_C_COMPILER
VERSION_VAR ARMCLANG_VERSION
)

View File

@@ -21,6 +21,6 @@ if(CMAKE_C_COMPILER)
endif()
find_package_handle_standard_args(oneApi
REQUIRED_VARS CMAKE_C_COMPILER
VERSION_VAR ONEAPI_VERSION
REQUIRED_VARS CMAKE_C_COMPILER
VERSION_VAR ONEAPI_VERSION
)

View File

@@ -55,13 +55,11 @@ if(${CMAKE_VERSION} VERSION_EQUAL 3.22.1 OR ${CMAKE_VERSION} VERSION_EQUAL 3.22.
# It seems only pip-installed builds are affected so we test to see if we are affected
cmake_path(GET ZEPHYR_BASE PARENT_PATH test_cmake_path)
if(ZEPHYR_BASE STREQUAL test_cmake_path)
message(FATAL_ERROR "The CMake version ${CMAKE_VERSION} installed suffers"
" the \n 'cmake_path(... PARENT_PATH)' bug, see: \n"
"https://gitlab.kitware.com/cmake/cmake/-/issues/23187\n"
"https://github.com/scikit-build/cmake-python-distributions/issues/221\n"
"Please install another CMake version or use a build of CMake that"
" does not come from PyPI."
)
message(FATAL_ERROR "The CMake version ${CMAKE_VERSION} installed suffers the \n"
" 'cmake_path(... PARENT_PATH)' bug, see:\n"
"https://gitlab.kitware.com/cmake/cmake/-/issues/23187\n"
"https://github.com/scikit-build/cmake-python-distributions/issues/221\n"
"Please install another CMake version or use a build of CMake that does not come from PyPI.")
endif()
endif()