[CMake] INSTALL CODE Error Results and Termination

David Hauck davidh at netacquire.com
Wed Nov 13 14:21:05 EST 2013


Hi Jean-christophe,
 
On chris.fillionr at kitware.com], Jean-Christophe Fillion-Robin wrote:
> Hi David,
> 
> You could look at the generated file named "cmake_install.cmake" to
> have a better idea of what could be wrong ...

Well, this just has the following:

IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
  EXECUTE_PROCESS (
      COMMAND ant ...
      WORKING_DIRECTORY /home/david/src/java
      #OUTPUT_VARIABLE _out
      ERROR_VARIABLE _err
      #RESULT_VARIABLE _res
   )
   MESSAGE( FATAL_ERROR "err: ")
ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")

IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
  MESSAGE("out: , err: , res: ...")
ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")

So it looks like the variable(s) is(are) being expanded (in the first case) prior to running the 'ant' command. Any ideas why this might be?

Thanks,
-David

PS: I'm surprised that this isn't something that many, many CMake authors need/require (i.e., the ability to terminate or otherwise operate on the results of an "install code..." sequence). Especially given the availability of the error, output, and result variable arguments to the execute_process command. What is the proper syntax/pattern for this?

> As a side note, there is also an issue with command like
> "install(CODE|SCRIPT ..." there are always executed first in a given
> directory. See [1] (Note that I couldn't find a issue in the tracker
> referencing that problem ... will create one if no body find it)
> 
> 
> Hth
> Jc
> 
> [1]
> https://github.com/Slicer/Slicer/blob/95f48d89d0806cd30b0cf58b20b77901
> 63 cec1c8/CMake/SlicerCPack.cmake#L81-86
> 
> On Wed, Nov 13, 2013 at 1:41 PM, David Hauck <davidh at netacquire.com>
> wrote:
> 	Hi Kornel,
> 
> 	On Wednesday, November 13, 2013 10:26 AM, cmake- bounces at cmake.org
> wrote: 	> Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David
> Hauck 	> <davidh at netacquire.com> 	>> Hello, 	>> 	>> I've been using
> several "install (CODE "EXECUTE_PROCESS ...")" 	>> constructs 	> in my
> top-level CMakeLists.txt file. However, I've been unable to 	>
> capture/operate on any exit status of the embedded command. 	>
> Unfortunately, documentation/searches haven't turned up any useful 	>
> pointers. The closest I've come is a pointer in the following thread:
> 	>> http://www.cmake.org/pipermail/cmake/2011-July/045475.html However,
> 	>> I've not been able to sufficiently read between the lines to get
> this 	>> working. 	>> 	>> Does anyone have any thoughts on how to get
> something like the 	>> following working: 	>> 	>>    install (CODE
> "EXECUTE_PROCESS ( 	>>       COMMAND ant ... 	>>       WORKING_DIRECTORY
> ${PROJECT_SOURCE_DIR}/java 	>>       ERROR_VARIABLE _err 	> 	> Didn't
> you mean 'RESULT_VARIABLE' here?
> 
> 	No, I really do mean ERROR_VARIABLE (unless, of course, this variable
> does not include the non-zero exit status of the EXECUTE_PROCESS
> command?).
> 
> 	BTW, I'm still curious about the (dual 'code') construct generally.
> Specifically, if I do the following I never see the fatal error
> message (so I'm wondering if there's still something wrong regarding
> the scoping of the message command)?
> 
> 	   install (CODE "EXECUTE_PROCESS (
> 	      COMMAND ant ...
> 	      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/java
> 	      ERROR_VARIABLE _err
> 
> 	   )
> 	   MESSAGE( FATAL_ERROR \"err: ${_err}\")
> 
> 	BTW, the following doesn't work either (each of the variables is empty):
> 
> 	   install (CODE "EXECUTE_PROCESS (
> 	      COMMAND ant ...
> 	      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/java
> 
> 	      OUTPUT_VARIABLE _out
> 	      ERROR_VARIABLE _err
> 	      RESULT_VARIABLE _res
> 	   )
> 	   Install (CODE "MESSAGE( STATUS \"out: ${_out}, err: ${_err},
> res: ${_res}...\")")
> 
> 	-David
> 
> 	>>    )
> 	>>    If (${_err})
> 	>>       MESSAGE( FATAL_ERROR \"err: ${_err}\")
> 	>>    endif ()")
> 	>> Thanks!
> 	>> -David
> 	>>
> 	>       Kornel


More information about the CMake mailing list