Re: [CMake] INSTALL CODE Error Results and Termination
Hi Jean-christophe, On chris.filli...@kitware.com], Jean-Christophe Fillion-Robin wrote: > Hi, > > You also need to add the "if" statement into the "CODE" parameter, for > example something like this ... > > install(CODE "If (NOT \${_res} EQUAL "0") > message( FATAL_ERROR \"out: \${_out}, err: \${_err}, res: > \${_res}\") > > endif() > ") Perfect, thx (just fixed up the double-quote escaping a bit and things worked fine). > To keep things simpler, you could also look at "INSTALL(SCRIPT ...)" > it would allow you to avoid escaping. You would just need to configure > the script using "configure_file". Hmmm, OK, I'll look into reviewing this to see how things differ. Thanks, -David > Hth > Jc > > On Wed, Nov 13, 2013 at 2:57 PM, David Hauck > wrote: > On Wednesday, November 13, 2013 11:42 AM, David Hauck wrote:> Hi > Jean-christophe, > > On chris.filli...@kitware.com], > Jean-Christophe > Fillion-Robin wrote: > > >> Hi David,>> >> You need to escape the "$" sign otherwise the > "_err", "_out" and "_res" >> variables are resolved to an empty string. > >> >> Here is an example of what you could do: >> > -8<---8<-->> > cmake_minimum_required(VERSION 2.8.9) >> >> install(CODE > "execute_process (>> COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" > >> OUTPUT_VARIABLE _out >> ERROR_VARIABLE _err>> > RESULT_VARIABLE _res >> )" >>) >> install(CODE > "message( > STATUS \"out: \${_out}, err: \${_err}, res: >> \${_res}...\")") > -8<---8<--> > > > Aha! This was probably obvious to you and Kornel, but it "escaped" > me ;). > > Brilliant, this is working fine now. > > One last item here: I'm now able to see the resulting variable values > in the message command output, but I'd now like to enclose this in an 'if' > command. Something like: > > install(CODE "execute_process ( > COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" > OUTPUT_VARIABLE _out > ERROR_VARIABLE _err > RESULT_VARIABLE _res > )" > ) > > If (NOT \${_res} EQUAL "0") # escaping here has not effect one way or > the other... > install(CODE "message( FATAL_ERROR \"out: \${_out}, err: > \${_err}, res: \${_res}\")") > endif () > > However, the resulting cmake_install.cmake has the following (meaning > the fatal error message will always be executed regardless of the > value of '_res"): > > IF(NOT CMAKE_INSTALL_COMPONENT OR > "${CMAKE_INSTALL_COMPONENT}" > STREQUAL "Unspecified") > > MESSAGE( FATAL_ERROR "out: ${_out}, err: ${_err}, res: ${_res}...") > > ENDIF(NOT CMAKE_INSTALL_COMPONENT OR > "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") > > Is there a way to do this? > > -David > > > Thanks to both of you for your help, > > -David > > > >> Hth >> Jc >> >> On Wed, Nov 13, 2013 at 2:29 PM, David Hauck >>> wrote: >> Hi Kornel, >> > > >> On Wednesday, November 13, 2013 11:08 AM, cmake- > boun...@cmake.org >> wrote: > Am Mittwoch, 13. November 2013 um > 18:41:03, schrieb David > > >> Hauck>>> Hi Kornel, > On Wednesday, > >> November 13, 2013 10:26 AM, cmake- > boun...@cmake.org > wrote: >>> Am > >> Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > >> 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?). > > > If you run 'cmake --help-command >> execute_process', you see: ... If > > RESULT_VARIABLE is given the >> variable will be set to contain the
Re: [CMake] INSTALL CODE Error Results and Termination
Hi, You also need to add the "if" statement into the "CODE" parameter, for example something like this ... install(CODE "If (NOT \${_res} EQUAL "0") message( FATAL_ERROR \"out: \${_out}, err: \${_err}, res: \${_res}\") endif() ") To keep things simpler, you could also look at "INSTALL(SCRIPT ...)" it would allow you to avoid escaping. You would just need to configure the script using "configure_file". Hth Jc On Wed, Nov 13, 2013 at 2:57 PM, David Hauck wrote: > On Wednesday, November 13, 2013 11:42 AM, David Hauck wrote: > > Hi Jean-christophe, > > > > On chris.filli...@kitware.com], Jean-Christophe Fillion-Robin wrote: > >> Hi David, > >> > >> You need to escape the "$" sign otherwise the "_err", "_out" and "_res" > >> variables are resolved to an empty string. > >> > >> Here is an example of what you could do: > >> -8<---8<-- > >> cmake_minimum_required(VERSION 2.8.9) > >> > >> install(CODE "execute_process ( > >> COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" > >> OUTPUT_VARIABLE _out > >> ERROR_VARIABLE _err > >> RESULT_VARIABLE _res > >> )" > >>) > >> install(CODE "message( STATUS \"out: \${_out}, err: \${_err}, res: > >> \${_res}...\")") -8<---8<-- > > > > Aha! This was probably obvious to you and Kornel, but it "escaped" me ;). > > Brilliant, this is working fine now. > > One last item here: I'm now able to see the resulting variable values in > the message command output, but I'd now like to enclose this in an 'if' > command. Something like: > > install(CODE "execute_process ( > COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" > OUTPUT_VARIABLE _out > ERROR_VARIABLE _err > RESULT_VARIABLE _res > )" >) > If (NOT \${_res} EQUAL "0") # escaping here has not effect one way or the > other... >install(CODE "message( FATAL_ERROR \"out: \${_out}, err: \${_err}, res: > \${_res}\")") > endif () > > However, the resulting cmake_install.cmake has the following (meaning the > fatal error message will always be executed regardless of the value of > '_res"): > > IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL > "Unspecified") > MESSAGE( FATAL_ERROR "out: ${_out}, err: ${_err}, res: ${_res}...") > ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL > "Unspecified") > > Is there a way to do this? > > -David > > > Thanks to both of you for your help, > > -David > > > >> Hth > >> Jc > >> > >> On Wed, Nov 13, 2013 at 2:29 PM, David Hauck > >> wrote: > >> Hi Kornel, > >> > >> On Wednesday, November 13, 2013 11:08 AM, cmake- boun...@cmake.org > >> wrote: > Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David > >> Hauck>>> Hi Kornel, >> > >> On Wednesday, > >> November 13, 2013 10:26 AM, cmake- > boun...@cmake.org wrote: > >>> Am > >> Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck >>> > >> 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?). > > If you run 'cmake --help-command > >> execute_process', you see: ... If> RESULT_VARIABLE is given the > >> variable will be set to contain the > result of running the processes. > >> This will be an integer return code > from the last child or a > string > >> describing an error condition. ... So, > if this is not "0", then > you > >> have an error condition. > >> > >> Yes, I see this. I also assumed that the ERROR_VARIABLE would be > >> returning non-zero text as well in this case. I will change to using > >> RESULT_VARIABLE, but, in both cases, it seems that I'm referencing > >> the variable incorrectly (either syntactically or in the incorrect > >> context) since this/these is/are always . > >> > >> >> BTW, I'm still curious about the (dual 'code') construct > generally. > >> >> Specifi
Re: [CMake] INSTALL CODE Error Results and Termination
On Wednesday, November 13, 2013 11:42 AM, David Hauck wrote: > Hi Jean-christophe, > > On chris.filli...@kitware.com], Jean-Christophe Fillion-Robin wrote: >> Hi David, >> >> You need to escape the "$" sign otherwise the "_err", "_out" and "_res" >> variables are resolved to an empty string. >> >> Here is an example of what you could do: >> -8<---8<-- >> cmake_minimum_required(VERSION 2.8.9) >> >> install(CODE "execute_process ( >> COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" >> OUTPUT_VARIABLE _out >> ERROR_VARIABLE _err >> RESULT_VARIABLE _res >> )" >>) >> install(CODE "message( STATUS \"out: \${_out}, err: \${_err}, res: >> \${_res}...\")") -8<---8<-- > > Aha! This was probably obvious to you and Kornel, but it "escaped" me ;). > Brilliant, this is working fine now. One last item here: I'm now able to see the resulting variable values in the message command output, but I'd now like to enclose this in an 'if' command. Something like: install(CODE "execute_process ( COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" OUTPUT_VARIABLE _out ERROR_VARIABLE _err RESULT_VARIABLE _res )" ) If (NOT \${_res} EQUAL "0") # escaping here has not effect one way or the other... install(CODE "message( FATAL_ERROR \"out: \${_out}, err: \${_err}, res: \${_res}\")") endif () However, the resulting cmake_install.cmake has the following (meaning the fatal error message will always be executed regardless of the value of '_res"): IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") MESSAGE( FATAL_ERROR "out: ${_out}, err: ${_err}, res: ${_res}...") ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") Is there a way to do this? -David > Thanks to both of you for your help, > -David > >> Hth >> Jc >> >> On Wed, Nov 13, 2013 at 2:29 PM, David Hauck >> wrote: >> Hi Kornel, >> >> On Wednesday, November 13, 2013 11:08 AM, cmake- boun...@cmake.org >> wrote: > Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David >> Hauck>>> Hi Kornel, >> >> On >> Wednesday, >> November 13, 2013 10:26 AM, cmake- > boun...@cmake.org wrote: >>> Am >> Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck >>> >> 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?). > > If you run 'cmake --help-command >> execute_process', you see: ... If> RESULT_VARIABLE is given the >> variable will be set to contain the > result of running the processes. >> This will be an integer return code > from the last child or a >> string >> describing an error condition. ... So, > if this is not "0", then you >> have an error condition. >> >> Yes, I see this. I also assumed that the ERROR_VARIABLE would be >> returning non-zero text as well in this case. I will change to using >> RESULT_VARIABLE, but, in both cases, it seems that I'm referencing >> the variable incorrectly (either syntactically or in the incorrect >> context) since this/these is/are always . >> >> >> 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}\") > > Never did this. When >> do >> you want to see the message? >> >> Ideally, I want to be able to test for the result of this variable >> (either ERROR_VARIABLE or RESULT_VARIABLE) after the execu
Re: [CMake] INSTALL CODE Error Results and Termination
Hi Jean-christophe, On chris.filli...@kitware.com], Jean-Christophe Fillion-Robin wrote: > Hi David, > > You need to escape the "$" sign otherwise the "_err", "_out" and "_res" > variables are resolved to an empty string. > > Here is an example of what you could do: > -8<---8<-- > cmake_minimum_required(VERSION 2.8.9) > > install(CODE "execute_process ( > COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" > OUTPUT_VARIABLE _out > ERROR_VARIABLE _err > RESULT_VARIABLE _res > )" >) > install(CODE "message( STATUS \"out: \${_out}, err: \${_err}, res: > \${_res}...\")") -8<---8<-- Aha! This was probably obvious to you and Kornel, but it "escaped" me ;). Brilliant, this is working fine now. Thanks to both of you for your help, -David > Hth > Jc > > On Wed, Nov 13, 2013 at 2:29 PM, David Hauck > wrote: > Hi Kornel, > > On Wednesday, November 13, 2013 11:08 AM, cmake- boun...@cmake.org > wrote:> Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David > Hauck >>> Hi Kornel, >> >> On > Wednesday, > November 13, 2013 10:26 AM, cmake-> boun...@cmake.org wrote: >>> Am > Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck >>> > 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?).> > If you run 'cmake --help-command execute_process', you > see: ... If > RESULT_VARIABLE is given the variable will be set to > contain the > result of running the processes. This will be an integer > return code > from the last child or a string describing an error > condition. ... So,> if this is not "0", then you have an error > condition. > > Yes, I see this. I also assumed that the ERROR_VARIABLE would be > returning non-zero text as well in this case. I will change to using > RESULT_VARIABLE, but, in both cases, it seems that I'm referencing the > variable incorrectly (either syntactically or in the incorrect > context) since this/these is/are always . > > >> 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}\")> > Never did this. When > do you > want to see the message? > > Ideally, I want to be able to test for the result of this variable > (either ERROR_VARIABLE or RESULT_VARIABLE) after the execute_process > command completes (during 'make install') to determine its result and > to terminate (with error message) when the command fails. > > Thanks, > -David > > > As I understand your code, only in call of cmake, e.g. at > configuration time. > > > > Kornel -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Hi David, You need to escape the "$" sign otherwise the "_err", "_out" and "_res" variables are resolved to an empty string. Here is an example of what you could do: -8<---8<-- cmake_minimum_required(VERSION 2.8.9) install(CODE "execute_process ( COMMAND ${CMAKE_COMMAND} -E echo \"Hello\" OUTPUT_VARIABLE _out ERROR_VARIABLE _err RESULT_VARIABLE _res )" ) install(CODE "message( STATUS \"out: \${_out}, err: \${_err}, res: \${_res}...\")") -8<---8<-- Hth Jc On Wed, Nov 13, 2013 at 2:29 PM, David Hauck wrote: > Hi Kornel, > > On Wednesday, November 13, 2013 11:08 AM, cmake-boun...@cmake.org wrote: > > Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David Hauck > > > >> Hi Kornel, > >> > >> On Wednesday, November 13, 2013 10:26 AM, cmake- > > boun...@cmake.org wrote: > >>> Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > >>> > 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?). > > > > If you run 'cmake --help-command execute_process', you see: ... If > > RESULT_VARIABLE is given the variable will be set to contain the > > result of running the processes. This will be an integer return code > > from the last child or a string describing an error condition. ... So, > > if this is not "0", then you have an error condition. > > Yes, I see this. I also assumed that the ERROR_VARIABLE would be returning > non-zero text as well in this case. I will change to using RESULT_VARIABLE, > but, in both cases, it seems that I'm referencing the variable incorrectly > (either syntactically or in the incorrect context) since this/these is/are > always . > > >> 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}\") > > > > Never did this. When do you want to see the message? > > Ideally, I want to be able to test for the result of this variable (either > ERROR_VARIABLE or RESULT_VARIABLE) after the execute_process command > completes (during 'make install') to determine its result and to terminate > (with error message) when the command fails. > > Thanks, > -David > > > As I understand your code, only in call of cmake, e.g. at configuration > time. > > > > Kornel > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- +1 919 869 8849 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Hi Kornel, On Wednesday, November 13, 2013 11:08 AM, cmake-boun...@cmake.org wrote: > Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David Hauck > >> Hi Kornel, >> >> On Wednesday, November 13, 2013 10:26 AM, cmake- > boun...@cmake.org wrote: >>> Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck >>> 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?). > > If you run 'cmake --help-command execute_process', you see: ... If > RESULT_VARIABLE is given the variable will be set to contain the > result of running the processes. This will be an integer return code > from the last child or a string describing an error condition. ... So, > if this is not "0", then you have an error condition. Yes, I see this. I also assumed that the ERROR_VARIABLE would be returning non-zero text as well in this case. I will change to using RESULT_VARIABLE, but, in both cases, it seems that I'm referencing the variable incorrectly (either syntactically or in the incorrect context) since this/these is/are always . >> 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}\") > > Never did this. When do you want to see the message? Ideally, I want to be able to test for the result of this variable (either ERROR_VARIABLE or RESULT_VARIABLE) after the execute_process command completes (during 'make install') to determine its result and to terminate (with error message) when the command fails. Thanks, -David > As I understand your code, only in call of cmake, e.g. at configuration time. > > Kornel -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Hi Jean-christophe, On chris.filli...@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 > wrote: > Hi Kornel, > > On Wednesday, November 13, 2013 10:26 AM, cmake- boun...@cmake.org > wrote:> Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David > Hauck >>> 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 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Am Mittwoch, 13. November 2013 um 18:41:03, schrieb David Hauck > Hi Kornel, > > On Wednesday, November 13, 2013 10:26 AM, cmake-boun...@cmake.org wrote: > > Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > > > >> 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?). If you run 'cmake --help-command execute_process', you see: ... If RESULT_VARIABLE is given the variable will be set to contain the result of running the processes. This will be an integer return code from the last child or a string describing an error condition. ... So, if this is not "0", then you have an error condition. > 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}\") Never did this. When do you want to see the message? As I understand your code, only in call of cmake, e.g. at configuration time. Kornel signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Hi David, You could look at the generated file named "cmake_install.cmake" to have a better idea of what could be wrong ... 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/95f48d89d0806cd30b0cf58b20b7790163cec1c8/CMake/SlicerCPack.cmake#L81-86 On Wed, Nov 13, 2013 at 1:41 PM, David Hauck wrote: > Hi Kornel, > > On Wednesday, November 13, 2013 10:26 AM, cmake-boun...@cmake.org wrote: > > Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > > > >> 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 > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- +1 919 869 8849 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Hi Kornel, On Wednesday, November 13, 2013 10:26 AM, cmake-boun...@cmake.org wrote: > Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > >> 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 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL CODE Error Results and Termination
Am Mittwoch, 13. November 2013 um 18:12:26, schrieb David Hauck > 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? >) >If (${_err}) > MESSAGE( FATAL_ERROR \"err: ${_err}\") >endif ()") > > Thanks! > -David > Kornel signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake