diff --git a/samples/application_development/external_lib/CMakeLists.txt b/samples/application_development/external_lib/CMakeLists.txt index 20cda9c55c6..23985cb2519 100644 --- a/samples/application_development/external_lib/CMakeLists.txt +++ b/samples/application_development/external_lib/CMakeLists.txt @@ -19,8 +19,12 @@ zephyr_get_system_include_directories_for_lang_as_string(C system_includes) zephyr_get_compile_definitions_for_lang_as_string( C definitions) zephyr_get_compile_options_for_lang_as_string( C options) +if(DEFINED CMAKE_C_COMPILER_TARGET) + set(target_flag "--target=${CMAKE_C_COMPILER_TARGET}") +endif() + set(external_project_cflags - "${includes} ${definitions} ${options} ${system_includes}" + "${target_flag} ${includes} ${definitions} ${options} ${system_includes}" ) include(ExternalProject)