[CMake] Fail target if buildtype is not RelWithDebInfo

Petr Kmoch petr.kmoch at gmail.com
Wed Aug 27 07:48:34 EDT 2014


Hi Thomas,

you should be able to make this work using the variable CMAKE_CFG_INTDIR:

if (WIN32)
  add_custom_target(msi-installer
    COMMAND IF NOT "${CMAKE_CFG_INTDIR}" == "RELWITHDEBINFO" (echo
"msi-installer only works for build type RELWITHDEBINFO" && exit 1)
    COMMAND ...)
endif()

Petr


On Wed, Aug 27, 2014 at 1:21 PM, Thomas Sondergaard <ts at medical-insight.com>
wrote:

> 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
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140827/ff4b4212/attachment.html>


More information about the CMake mailing list