Sysprogs forums › Forums › VisualGDB › ESP32-IDF – setting #define on a per config basis
- This topic has 6 replies, 2 voices, and was last updated 4 years, 10 months ago by dedvalson.
-
AuthorPosts
-
October 10, 2019 at 13:07 #26133dedvalsonParticipant
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
October 10, 2019 at 13:25 #26134dedvalsonParticipantIt would also be really cool if IntelliSense could see these defines.
October 12, 2019 at 04:47 #26147supportKeymasterHi,
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.
January 25, 2020 at 15:03 #27253dedvalsonParticipantHi,
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 buildSee 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.January 25, 2020 at 16:53 #27257supportKeymasterSorry, 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.
January 26, 2020 at 13:41 #27260dedvalsonParticipantThanks, 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
January 26, 2020 at 13:54 #27261dedvalsonParticipantNever 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
-
AuthorPosts
- You must be logged in to reply to this topic.