diff --git a/CMakeLists.txt b/CMakeLists.txt index 82ff10e2cd9..148b05047c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -502,22 +502,6 @@ if(CONFIG_NDEBUG) add_compile_options(-DNDEBUG) endif() -# Cmake build provide absolute paths to compile files. If __FILE__ macros are -# used in the source code(ASSERT), the binary will contain many invalid paths. -# This saves some memory, stops exposing build systems locations in binaries, -# make failure logs more deterministic and most importantly makes builds more -# failure logs more deterministic and most importantly makes builds more -# deterministic. Debuggers usually have a path mapping feature to ensure the -# files are still found. -if(NOT MSVC) - if(CONFIG_OUTPUT_STRIP_PATHS) - add_compile_options(-fmacro-prefix-map=${NUTTX_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_APPS_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_BOARD_ABS_DIR}=) - add_compile_options(-fmacro-prefix-map=${NUTTX_CHIP_ABS_DIR}=) - endif() -endif() - add_definitions(-D__NuttX__) add_compile_options($<$:-D__ASSEMBLY__>) diff --git a/cmake/nuttx_toolchain.cmake b/cmake/nuttx_toolchain.cmake index 0b728f2c47f..beecf63424a 100644 --- a/cmake/nuttx_toolchain.cmake +++ b/cmake/nuttx_toolchain.cmake @@ -30,6 +30,22 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") endif() endif() +# Cmake build provide absolute paths to compile files. If __FILE__ macros are +# used in the source code(ASSERT), the binary will contain many invalid paths. +# This saves some memory, stops exposing build systems locations in binaries, +# make failure logs more deterministic and most importantly makes builds more +# failure logs more deterministic and most importantly makes builds more +# deterministic. Debuggers usually have a path mapping feature to ensure the +# files are still found. +if((NOT MSVC) AND (NOT CONFIG_ARCH_TOOLCHAIN_GHS)) + if(CONFIG_OUTPUT_STRIP_PATHS) + add_compile_options(-fmacro-prefix-map=${NUTTX_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_APPS_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_BOARD_ABS_DIR}=) + add_compile_options(-fmacro-prefix-map=${NUTTX_CHIP_ABS_DIR}=) + endif() +endif() + # Support CMake to define additional configuration options if(EXTRA_FLAGS)