[CMake] How does one create a nonfatal error in cmake_install.cmake?

R. Sage r14 at thinhorn.com
Tue Apr 18 15:13:19 EDT 2017


Under CMake 2.8.7, I am trying to produce an install error similarly to how
I would use SEND_ERROR in a normal CMakeLIsts.txt and I successfully insert
message(SEND_ERROR...) into the cmake_install.cmake and it produces a
message, but unfortunately upon hitting the message(SEND_ERROR ...), it
stops install execution immediately.  I have also tested under CMake 3.5.1
and I get the same results as the target system (2.8.7).

Below is a complete example that reproduces the issue.  The behavior is
that 'make install' terminates immediately after the SEND_ERROR message,
before issuing any other messages (the example uses messages as the install
steps).  I edited the cmake_install.cmake to experiment with different
message types and each type either returns status 0 (success) or aborts
immediately without continuing.

Lacking a nonfatal error, I guess I'll have to separate out the custom
installation to be run manually outside of the CMake-controlled 'make
install'.

Thanks,
Randy Sage


---- Example CMakeLists.txt ----

cmake_minimum_required (VERSION 2.8.7)
project (INSTALL_ERROR_DEMO)

install(CODE "execute_process (
      COMMAND \"touch\" \"/dev/null/cannot/exist\"
      ERROR_VARIABLE _err
      RESULT_VARIABLE _res
)
if (NOT \${_res} EQUAL \"0\")
  message( SEND_ERROR \"err: \${_err}, res: \${_res}\")
  message( INFO \" Proceeding with any remaining steps, but 'make
install' will fail\")
endif ()"
  COMPONENT compname
)

install(CODE "message( INFO \" Hypothetical later install step\")"
  COMPONENT compname
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170418/884a3d0f/attachment.html>


More information about the CMake mailing list