Reputation:
I have added custom target to my CMakeLists.txt
add_custom_target (
patch
COMMAND echo "Creating build"
COMMAND cd ${CMAKE_BINARY_DIR} && sudo bash a.sh
COMMAND cd ${CMAKE_BINARY_DIR} && sudo bash b.sh name
COMMAND cd ${CMAKE_BINARY_DIR} && sudo bash b.sh address
DEPENDS authorise
DEPENDS copy
)
What happen in above case is, I have terminated the execution of a.sh
with exit 0
on certain condition, but after terminating that script cmake
is moving further to execute b.sh
What I want is, when I terminated from first script, the execution of cmake target
also has to be terminate. I don't want to go for b.sh
to execute it.
Is there any way that we can stop or terminate the execution of CMAKE target
any help will be appreciated
Upvotes: 0
Views: 579
Reputation: 34401
A series of COMMAND
s in add_custom_target
is translated to cmd1 && cmd2 && cmd3
.
So, instead of exiting with code 0, you have to return something else. Catch Ctrl+C signal in your shell scripts and return non-zero code:
trap ctrl_c INT
function ctrl_c() {
exit 1
}
Upvotes: 1