Skip to content

Conversation

@josuah
Copy link
Contributor

@josuah josuah commented Nov 15, 2025

The rules are interpolated from what there is on the docs:

https://docs.zephyrproject.org/latest/contribute/style/cmake.html#commands-and-syntax

# Good: target_sources(my_target PRIVATE src/file1.cpp src/file2.cpp )

And what seemed to be common on in-tree, in particular for if() and messages():

  • Long lines have continuation lines use 2 spaces
    if(long line ... continuation line... 
    function(arg1 arg2... continuation line... 
  • When the first line is filled with content, the closing parenthesis is
    at the end of the last continuation line
    if(long line filled until the end ... continuation line...) 
    message(long line filled until the end... continuation line...) 
  • When the first line is empty or only containing a distinct label, such
    as an UPPERCASE label) the closing parenthesis is on its own line,
    with same indentation level as the first line.
    zephyr_library_sources( something_a.c something_b.c ) 
    zephyr_library_sources_ifdef(CONFIG_SOMETHING something_a.c something_b.c ) 
  • Call to message() are converted from \ for escaping newlines to a list
    of "... " strings, with an empty space at the end if separation between
    words is needed.
    message("long line... Hello " "cmake! continuation line...") 

If anything seems wrong choice, let me know of what to apply and I'd be glad to apply it again tree-wide.

If the scope of modifications is wrong (i.e. should do all CMakeLists.txt and .cmake), then let me know and I would change the scope for this PR.

I am keeping it as a draft for now to avoid triggering the bot.

Apply the CMake style guidelines to all CMakeList.txt files in boards/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to all CMakeList.txt files in arch/. Signed-off-by: Josuah Demangeon <me@josuah.net>
@josuah josuah force-pushed the pr_cmakelists_txt_indentation branch 5 times, most recently from ec4d920 to 58840e2 Compare November 15, 2025 21:24
@josuah
Copy link
Contributor Author

josuah commented Nov 15, 2025

Since this touches to every CMakeLists.txt, a second batch of commit also adds zephyr-keep-sorted-start/end comments for both CMakeLists.txt and Kconfig, making just one PR for all the "CMake style related changes".

If this is too much for a single PR, then I can easily split it.

Apply the CMake style guidelines to all CMakeList.txt files in cmake/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/adc/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/display/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/ethernet/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/flash/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/gnss/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/i3c/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/misc/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/mm/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/modem/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/sensor/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in drivers/usb/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/bluetooth/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/llext/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/lorawan/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/mgmt/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/modbus/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/net/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/rtio/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/sensing/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/testsuite/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Apply the CMake style guidelines to CMakeList.txt files in subsys/usb/. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the # zephyr-keep-sorted-start/stop comment to have CI check the alphabetical order of includes, to help reducing the chance of conflicts while contributing drivers. Signed-off-by: Josuah Demangeon <me@josuah.net>
@josuah josuah force-pushed the pr_cmakelists_txt_indentation branch from 58840e2 to 5351b5e Compare November 15, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant