Facing the same problem, I've found a solution to it.
The idea is to use the CDT Build Output Parser that
... relies on verbose build output of your build where all these options are actually printed by make.
Then, what you need to do is to make your build command verbose, so that the call of the compiler is printed into the output with all the arguments, and call the build from Eclipse.
I've found the answer in the article from Eclipse here: https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php
Quoting the part that explains it (focus on point 2.):
CDT will try to discover include paths and pre-processor symbols automatically for supported tool chains. There are 2 main ways to discover those:
Built-in Settings. CDT will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output of this special run. Most compilers provide such an option to print built-in include paths and symbols. Built-in settings are implied and do not get passed to compiler during regular compilation.
Build Output Parser (BOP). Another method that CDT employs is to analyze build output of the regular build with Build Output Parser. Often, include paths are supplied to the compiler with -I options, and macros with -D options and BOP will try to find those in the output. That method relies on verbose build output of your build where all these options are actually printed by make.
Now what's necessary is to:
Example build output (a single file compilation command) for an embedded ARM MCU target could look something like this:
[C++] Building file: src/your_source_file.cpp
arm-none-eabi-g++ -c -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -std=c++17 -pedantic -Wall -Werror -W... -fno-exceptions -f... -Isrc -I... -DUSE_FULL_LL_DRIVER=1 -DARM_MATH_CM4=1 -D... -g -O3 src/your_source_file.cpp -o _build/release/your_source_file.o
Notes to the output example above: