Swatantra-66 commented on code in PR #20874:
URL: https://github.com/apache/nuttx/pull/20874#discussion_r4348218300
##########
CMakeLists.txt:
##########
@@ -503,6 +523,125 @@ endif()
project(NuttX LANGUAGES C CXX ASM)
+# When NuttX is embedded as a subproject via add_subdirectory(), CMake will not
+# automatically load CMAKE_TOOLCHAIN_FILE during project() if the parent
project
+# already enabled languages. Explicitly include it to ensure architecture
+# settings, compiler definitions, and ARCH_SUBDIR are populated.
+if(NOT CMAKE_SOURCE_DIR STREQUAL NUTTX_DIR)
+ # Capture the compiler selected during language initialization before
+ # including the toolchain file, as the toolchain will assign CMAKE_C_COMPILER
+ # to the cross-compiler executable.
+ if(CMAKE_C_COMPILER)
+ set(_active_c_compiler "${CMAKE_C_COMPILER}")
+ elseif(DEFINED CACHE{CMAKE_C_COMPILER})
+ set(_active_c_compiler "$CACHE{CMAKE_C_COMPILER}")
+ endif()
+
+ # Ensure CMAKE_TOOLCHAIN_FILE is resolved using lookup rules before testing
+ # existence, in case a relative path was provided.
+ if(CMAKE_TOOLCHAIN_FILE)
+ nuttx_resolve_toolchain_file()
+
+ if(EXISTS "${CMAKE_TOOLCHAIN_FILE}" AND NOT IS_DIRECTORY
+ "${CMAKE_TOOLCHAIN_FILE}")
+ include(${CMAKE_TOOLCHAIN_FILE})
+ endif()
+ endif()
+
+ function(nuttx_toolchain_mismatch_error reason compiler_name compiler_path)
Review Comment:
Simplified. Removed the custom function and complex branches, replacing them
with a concise 10-line direct prefix check on the compiler executable name
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]