Exit status not set correctly if cmake fails
advanced disk information utility
Brought to you by:
bll123
If I run make and the build fails, the exit status is still set to 0; it should be set to non-zero when a failure occurs.
For example, if I edit CMakeLists.txt to add the line "foo" before all other lines, to cause a build failure, and then try to make, I get this:
% make PREFIX=/tmp; echo $?
cmake \
-DCMAKE_C_COMPILER=cc \
-DCMAKE_INSTALL_PREFIX="/tmp" \
-DDI_BUILD:STATIC=Release \
-DDI_VERSION:STATIC=5.0.3 \
-DDI_LIBVERSION:STATIC=5.0.3 \
-DDI_SOVERSION:STATIC=5 \
-DDI_RELEASE_STATUS:STATIC=production \
-DDI_USE_MATH:STATIC= \
-S . -B build -Werror=deprecated
CMake Error at CMakeLists.txt:2:
Parse error. Expected "(", got newline with text "
".
-- Configuring incomplete, errors occurred!
make[3]: *** [cmake-unix] Error 1
cmake --build build --parallel
CMake Error at CMakeLists.txt:2:
Parse error. Expected "(", got newline with text "
".
-- Configuring incomplete, errors occurred!
make[4]: *** [cmake_check_build_system] Error 1
make[3]: *** [cmake-build] Error 2
make[2]: *** [cmake-all] Error 2
make[1]: [switcher] Error 2 (ignored)
0
The result from echo $? should not have been 0.
I believe I know what's wrong and how to fix it. I will probably get to it Monday, as I have to look into an issue in my other software on Saturday.
With version 5.0.4, you should be able to create a cmake only portfile and bypass my wonky Makefile entirely.
Oh thanks! Being able to run cmake directly would certainly fix it. I've also submitted a stopgap fix for MacPorts that might also avoid the problem by running the cmake-unix, cmake-build, and cmake-install targets directly rather than getting to them through the switcher target: https://github.com/macports/macports-ports/pull/27594
I tried briefly to solve the Makefile problem... Several of the targets have rules that invoke multiple commands each, without using
|| exit $?after each command; however, I was not successful in identifying all of the places where that should be added and decided to move on to the aforementioned workaround instead.Sorry about that. Yeah, the makefile is a bit messy (but it works). And
I have to keep it BSD-Make, Solaris-Make (not sure if it is), and /bin/sh
compliant.
Be aware that cmake-unix is using an internal COMP variable, not CC.
On Fri, Feb 7, 2025 at 2:04 PM Ryan Carsten Schmidt ryandesign@users.sourceforge.net wrote:
Related
Tickets:
#15Fixed in 5.0.5
Fixed in 5.0.5