When cmake
encounters an error, sometimes it does not stop instantly but continues to process all CMake files. It is only at the end of the treatment that we learn that there is an error, so we have to go back up the whole log to see where it is located.
Is there any option, variable or means to stop CMake just after the first error?
Clarification: I'm not trying to stop the compilation of source code but the CMake generation (e.g. on Linux the generation of the Makefiles).
Here is an example (this is not my real project, this is specifically designed to generate errors). My file CMakeLists.txt:
cmake_minimum_required(VERSION 3.6)
project(test)
set_property(TARGET foo PROPERTY PROP1 TRUE)
set_property(TARGET bar PROPERTY PROP2 TRUE)
And when i run cmake .
I get the output :
CMake Error at CMakeLists.txt:3 (set_property):
set_property could not find TARGET foo. Perhaps it has not yet been
created.
CMake Error at CMakeLists.txt:4 (set_property):
set_property could not find TARGET bar. Perhaps it has not yet been
created.
-- Configuring incomplete, errors occurred!
What I would like to know is if cmake
has the possibility to stop just after the first reported error.
-Werror=dev
? Or, for errors you produce yourself,if(ERR_COND) message( FATAL_ERROR "Fatal error, exiting." )
?