CMake custom target macro definition
Posted: Wed Apr 29, 2020 3:45 am
I'm currently trying to migrate my build system from GNU make to Cmake. In my original Makefile, i had multiple different targets that were just invoking the `build` target with different flags controlling portions of the code.
For example, i may have a target like:
this way I'd be able to enable/disable certain functionality by changing the targets
A common use of these flags was to enable/disable additional debugging helpers. The UNIT_TESTING flag would switch my main() function to invoke the unit-tester runner and also enable additional unit-testing drivers.
Is there a way I can do this in CMake+Ninja+idf_ext.py ? I know i can create custom targets via CMake, and I can set some define_cache_entry via idf_ext.py, but I just can't seem to put it all together. Thanks!
tl;dr I enabled additional helper code via the flag UNIT_TESTING which also enabled the unity driver; compiling all this code was done via a make target, trying to accomplish the same thing with CMake+Ninja.
For example, i may have a target like:
Code: Select all
foo:
CFLAGS='-DFOO=1' $(MAKE) all
bar:
CFLAGS='-DBAR=1' $(MAKE) all
tests:
CFLAGS='-DUNIT_TESTING' $(MAKE) TEST_COMPONENTS='my_component' flash monitor
Code: Select all
make tests
Is there a way I can do this in CMake+Ninja+idf_ext.py ? I know i can create custom targets via CMake, and I can set some define_cache_entry via idf_ext.py, but I just can't seem to put it all together. Thanks!
tl;dr I enabled additional helper code via the flag UNIT_TESTING which also enabled the unity driver; compiling all this code was done via a make target, trying to accomplish the same thing with CMake+Ninja.