Menu

#15 Exit status not set correctly if cmake fails

5.0
closed
build (8)
2025-02-10
2025-02-07
No

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.

Related

Tickets: #15

Discussion

  • Brad Lanam

    Brad Lanam - 2025-02-07
    • labels: --> build
    • status: open --> accepted
    • assigned_to: Brad Lanam
     
  • Brad Lanam

    Brad Lanam - 2025-02-07

    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.

     
  • Ryan Carsten Schmidt

    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.

     
    • Brad Lanam

      Brad Lanam - 2025-02-07

      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:

      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.


      [tickets:#15] Exit status not set correctly if cmake fails

      Status: accepted
      5.0: 5.0
      Labels: build
      Created: Fri Feb 07, 2025 09:19 PM UTC by Ryan Carsten Schmidt
      Last Updated: Fri Feb 07, 2025 09:40 PM UTC
      Owner: Brad Lanam

      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.


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/diskinfo-di/tickets/15/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

      Related

      Tickets: #15

  • Brad Lanam

    Brad Lanam - 2025-02-08

    Fixed in 5.0.5

     
  • Brad Lanam

    Brad Lanam - 2025-02-10
    • status: accepted --> closed
     
  • Brad Lanam

    Brad Lanam - 2025-02-10

    Fixed in 5.0.5

     

Log in to post a comment.

MongoDB Logo MongoDB