ESP32-IDF – setting #define on a per config basis

Sysprogs forums Forums VisualGDB ESP32-IDF – setting #define on a per config basis

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #26133
    dedvalson
    Participant

    Hi,

    This seems really basic, but I don’t see an answer to it. I need to define multiple configurations in the Visual Studio configuration manager and have those reflected as defines in the c++ pre-processor.

    I can make the defines work by putting something like:

    CPPFLAGS += -DCONTROL2

    in the makefile but I need these to be defined per configuration.

    Am I missing something obvious?

    Don

    #26134
    dedvalson
    Participant

    It would also be really cool if IntelliSense could see these defines.

    #26147
    support
    Keymaster

    Hi,

    The easiest way to achieve this would be to use the CMake-based projects and add the following constructs to the CMakeLists.txt files:

    if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
    set(CONFIG_SPECIFIC_MACROS CONTROL2)
    endif()
    

    and then simply add ${CONFIG_SPECIFIC_MACROS} to the regular list of preprocessor macros via VS Project Properties. This will affect both build and IntelliSense.

    If it doesn’t work, please let us know and we will help you configure everything.

    #27253
    dedvalson
    Participant

    Hi,

    It took me a long time but I finally got my project converted to CMake. I tried your suggestion above. I had to change EQUAL to STREQUAL but then I ran into a problem I don’t see a way around.

    The CMAKE_BUILD_TYPE variable only seems to be able to have predefined values such as DEBUG or MINSIZEREL. These are project level build types. But all I am able to add is solution level builds that then utilize the existing project level build types. When I go to New Solution Configuration the Create new project configurations button is disabled. So I have more than one DEBUG build and more than one RELEASE build

    See the attached screenshots.

    Really I wouldn’t want to duplicate these anyway, the existing configurations are good and well defined. What I really need is a way to access the current <span style=”text-decoration-line: underline;”>Solution </span>level configuration. However, it does not appear that cmake has any variable that corresponds to that.

    I have attached a simple helloworld type project that illustrates the problem. Please let me know if you have a suggestion.

    Thanks

    Don

     

    Attachments:
    You must be logged in to view attached files.
    #27257
    support
    Keymaster

    Sorry, CMake-based projects currently only support the predefined set of configurations (such as Debug, Release, etc). In order to create multiple debug configurations, please consider creating multiple VisualGDB projects (.vgdbcmake) wrapping the same CMakeLists file. Then you can set additional per-project CMake definitions via VisualGDB Project Properties.

    #27260
    dedvalson
    Participant

    Thanks, that would work ok for me.

    Is it possible to create multiple projects as you suggest and keep them in a single VS solution?

    Thanks,

    Don

     

    #27261
    dedvalson
    Participant

    Never mind, I answered my own question. Yes, that works well. I can put them all in a solution file and choose which projects to build that way.

    Thanks for the suggestion.

     

    Don

     

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.