diff --git a/CMakeLists.txt b/CMakeLists.txt index bfb0bf933f8..ae87eb1e9f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,12 +331,14 @@ zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage) # in binaries, makes failure logs more deterministic and most # importantly makes builds more deterministic -# If both match then the last one wins. This matters for tests/ and -# samples/ inside *both* CMAKE_SOURCE_DIR and ZEPHYR_BASE: for them -# let's strip the shortest prefix. +# If several match then the last one wins. This matters for instances +# like tests/ and samples/: they're inside all of them! Then let's +# strip as little as possible. zephyr_cc_option(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR) zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE) -# TODO: -fmacro-prefix-map=modules/etc. "build/zephyr_modules.txt" might help. +if(WEST_TOPDIR) + zephyr_cc_option(-fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR) +endif() # TODO: Archiver arguments # ar_option(D) diff --git a/cmake/host-tools.cmake b/cmake/host-tools.cmake index 489bcecf00a..050bb90e2b9 100644 --- a/cmake/host-tools.cmake +++ b/cmake/host-tools.cmake @@ -37,6 +37,14 @@ else() # Just output information for a single version. This will still work # even after output is one line. message(STATUS "Found west: ${WEST} (found suitable version \"${west_version}\", minimum required is \"${MIN_WEST_VERSION}\")") + + if (${west_version} VERSION_GREATER_EQUAL "0.7.0") + execute_process( + COMMAND ${WEST} topdir + OUTPUT_VARIABLE WEST_TOPDIR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() endif() # Search for the must-have program dtc on PATH and in