add_custom_command: POST_BUILD command return value ignored when using the NMake generator
When using add_custom_command()
with the NMake generator, the return value of the executed command is simply ignored and the application is always built. When the return value is non-zero (which indicates a failure), the build process should fail. This is not the case when using the NMake generator.
---- Steps to reproduce ----
-
Create a dummy
main.cpp
and aCMakeLists.txt
that usesadd_custom_command()
like so:CMakeLists.txt
add_executable(app main.cpp) add_custom_command( TARGET app POST_BUILD COMMAND exit 1 )
-
Run CMake with
-G "NMake Makefiles"
.
---- Information ----
- CMake version: 3.29.2
- NMake version: 14.39.33523.0
- Platform: Windows 11 22H2
Edited by Adel Makhloufi