Skip to content

Commit 6f946e2

Browse files
SebastianBoeAnas Nashif
authored andcommitted
cmake: Execute arch/CMakeLists.txt before subsys/CMakeList.txt
Re-order the execution of the arch/ and subsys/ CMakeLists.txt code to work around a manifestation of issue #6505. When OpenThread created an External project in subsys, it did not have access to important toolchain flags added in arch/. Intuitively, subsystems might depends on how the ARCH is configured, but the ARCH shouldn't depend on any subsystem. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 07a64f1 commit 6f946e2

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,23 @@ endif()
289289

290290
configure_file(version.h.in ${PROJECT_BINARY_DIR}/include/generated/version.h)
291291

292+
# Unfortunately, the order in which CMakeLists.txt code is processed
293+
# matters so we need to be careful about how we order the processing
294+
# of subdirectories. One example is "Compiler flags added late in the
295+
# build are not exported to external build systems #5605"; when we
296+
# integrate with an external build system we read out all compiler
297+
# flags when the external project is created. So an external project
298+
# defined in subsys or ext will not get global flags added by drivers/
299+
# or tests/ as the subdirectories are ordered now.
300+
#
301+
# Another example of when the order matters is the reading and writing
302+
# of global properties such as ZEPHYR_LIBS or
303+
# GENERATED_KERNEL_OBJECT_FILES.
304+
#
305+
# Arch is placed early because it defines important compiler flags
306+
# that must be exported to external build systems defined in
307+
# e.g. subsys/.
308+
add_subdirectory(arch)
292309
add_subdirectory(lib)
293310
add_subdirectory(misc)
294311
# We use include instead of add_subdirectory to avoid creating a new directory scope.
@@ -298,7 +315,6 @@ include(misc/generated/CMakeLists.txt)
298315
add_subdirectory(boards)
299316
add_subdirectory(ext)
300317
add_subdirectory(subsys)
301-
add_subdirectory(arch)
302318
add_subdirectory(drivers)
303319
add_subdirectory(tests)
304320

0 commit comments

Comments
 (0)