Post build step only for release build
cmake, post-build-event
Solution
For Makefile-based generators you can check the `CMAKE_BUILD_TYPE` variable and act upon its value:
if(CMAKE_BUILD_TYPE STREQUAL Debug)
message(STATUS "Do debug stuff")
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
message(STATUS "Do release stuff")
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
message(STATUS "Do release with debug info stuff")
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
message(STATUS "Do minimal size release stuff")
endif()
For Visual Studio based builds, this SO question seems to suggest that `CMAKE_BUILD_TYPE` also works with VS 2005+.
Problem
I'm trying to setup a post-build command for CMake, which I have done using the ADD_CUSTOM_COMMAND directive as stated in the CMake documentation. What I'd like to do though, is only have the post-build run if I am creating a release build of my executable. How does one accomplish this?