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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

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

R. Sage
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'.

Randy Sage

---- Example CMakeLists.txt ----
cmake_minimum_required (VERSION 2.8.7)

install(CODE "execute_process (
      COMMAND \"touch\" \"/dev/null/cannot/exist\"
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


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: