[CMake] Fail target if buildtype is not RelWithDebInfo
Thomas Sondergaard
ts at medical-insight.com
Wed Aug 27 07:21:02 EDT 2014
Hi,
I have a custom target that is only enabled on Windows and it only works
with buildtype RelWithDebInfo. When a developer accidentally runs it
under a different configuration it doesn't fail in a very obvious way,
and I'd like to improve that, if possible. I am using the "Visual Studio
12" (2013) generator.
I imagine something like this
if (WIN32)
add_custom_target(msi-installer
COMMAND if NOT "%CMAKE_BUILD_TYPE%" ==
"RELWITHDEBINFO" (echo "msi-installer only works for build type
RELWITHDEBINFO" && exit 1)
COMMAND ...)
endif()
But that requires the CMAKE_BUILD_TYPE to be in the environment. Is
there a way to do what I want?
Thanks,
Thomas
More information about the CMake
mailing list