Defining preprocessor options using Visual Studio Code

I'm transitioning from SES to Visual Studio Code.

In SES, I can define multiple builds and then define preprocessor options (eg. -DOPTION1) for each build definition

I don't see a way to do this when using the nRF Connect SDK and Visual Studio Code.

(Note:  I know how to specify defines using the CMakeLists.txt file for all builds (using add_definitions(-DOPTION1) , but not on a "per-build" basis).

I'm using the NRF CONNECT extension in Visual Studio Code.


Parents Reply
  • Upon further testing...   This doesn't seem to work.

    If I use the syntax you suggest, I get an error during the build process.    To fix the error, I must use a syntax like:


    But this isn't seen when my source files are compiled.

    I have been successful at using a line in the CMakeLists.txt file:


    but this adds the define project-wide (not per build option)

    Am I doing something wrong?