Hello im trying to add configuration specific definitions to my project but it doesn't seem to work the way i expect it to. My code works fine if i specify the configuration when i run cmake however this makes it a bit weird in visual studio since if i have something like the code below and specify -DCMAKE_BUILD_TYPE=Debug it will add the 'TestingDebug' define to all my configurations in visual studio which is not what i want.
if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DTestingDebug)
endif()
if (CMAKE_BUILD_TYPE STREQUAL Release)
add_definitions(-DTestingRel)
endif()
Is there a way to generate all of these at onces so when i change configuration in visual studio it will have the correct defines?
i've tried using the cmake --build {builddir} --config {config}
command because i read somewhere thats what you're supposed to use when trying to build for multi-configuration tools. The code below is what i used for my project but it doesn't seem to work either, idk if im just using it wrong or if there is something else i need to do.
cmake -S ../ -B ../Build/
cmake --build ../Build/ --config Debug
cmake --build ../Build/ --config Release