diff options
author | leha-bot <leha-bot@yandex.ru> | 2024-01-02 18:13:53 (GMT) |
---|---|---|
committer | leha-bot <leha-bot@yandex.ru> | 2024-01-16 07:41:31 (GMT) |
commit | 4f160f7906ef8075dad54b9bf2e0ba204a1c41fc (patch) | |
tree | 26f32b99c60046b8f1ff0836433dc9273175fe71 | |
parent | b62dcbf5d2f99dd5f258be9955df6ed605657f70 (diff) | |
download | CMake-4f160f7906ef8075dad54b9bf2e0ba204a1c41fc.zip CMake-4f160f7906ef8075dad54b9bf2e0ba204a1c41fc.tar.gz CMake-4f160f7906ef8075dad54b9bf2e0ba204a1c41fc.tar.bz2 |
cmakemain: Return the SCRIPT_MODE exit code if it was set
We determine it via checking cmake.Run() return code and
ScriptModeExitCode. If ScriptModeExitCode is zero, then we would return
1 if retcode was non-zero. Otherwise it will be returned if retcode was
also non-zero.
-rw-r--r-- | Source/cmake.cxx | 2 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 32064b4..7ab7600 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2820,7 +2820,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) if (cmSystemTools::GetErrorOccurredFlag()) { return -1; } - return 0; + return this->HasScriptModeExitCode() ? this->GetScriptModeExitCode() : 0; } // If MAKEFLAGS are given in the environment, remove the environment diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ced83dc..8462734 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -389,13 +389,16 @@ int do_cmake(int ac, char const* const* av) } } - // Always return a non-negative value. Windows tools do not always - // interpret negative return values as errors. + // Always return a non-negative value (except exit code from SCRIPT_MODE). + // Windows tools do not always interpret negative return values as errors. if (res != 0) { + auto scriptModeExitCode = + cm.HasScriptModeExitCode() ? cm.GetScriptModeExitCode() : 0; + res = scriptModeExitCode ? scriptModeExitCode : 1; #ifdef CMake_ENABLE_DEBUGGER - cm.StopDebuggerIfNeeded(1); + cm.StopDebuggerIfNeeded(res); #endif - return 1; + return res; } #ifdef CMake_ENABLE_DEBUGGER cm.StopDebuggerIfNeeded(0); |