Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用CMake,如何在';进行安装';并且仍然运行以后的安装步骤?_Cmake - Fatal编程技术网

使用CMake,如何在';进行安装';并且仍然运行以后的安装步骤?

使用CMake,如何在';进行安装';并且仍然运行以后的安装步骤?,cmake,Cmake,如何生成安装错误并在以后执行makeinstall步骤 通常使用CMake,我会使用消息(SEND_ERROR“ERROR message”)创建错误并继续运行后面的步骤。但是,当我使用install(code…指令将其插入cmake_install.cmake时,同一行立即中止执行make install,并且不执行后面的步骤 在CMake 2.8.7下,我被要求更新一个自定义安装步骤以继续其余的安装。我的客户有一个MATLAB安装步骤,它在某些系统上失败,希望在开发人员决定如何继续时减轻对他

如何生成安装错误并在以后执行
makeinstall
步骤

通常使用CMake,我会使用
消息(SEND_ERROR“ERROR message”)
创建错误并继续运行后面的步骤。但是,当我使用
install(code…
指令将其插入cmake_install.cmake时,同一行立即中止执行
make install
,并且不执行后面的步骤

在CMake 2.8.7下,我被要求更新一个自定义安装步骤以继续其余的安装。我的客户有一个MATLAB安装步骤,它在某些系统上失败,希望在开发人员决定如何继续时减轻对他们的影响。在下面的示例中,我将“matlab”“args”替换为“touch”“/dev/null/cannot/exist”,因此任何人都应该能够重现问题()

具体问题

我可以成功地在写入cmake_install.cmake的
make install
说明中插入一些内容,方法是:

  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 mycomponentname
  )
这将在cmake_install.cmake中产生以下结果:

IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "mycomponentname")
  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 ()
ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "mycomponentname")
结果输出

[previous output]
...
CMake Error at cmake_install.cmake:82 (message):
  err: touch: cannot touch `/dev/null/cannot/exist': Not a directory

  , res: 1


make: *** [install] Error 1

real    0m3.041s
user    0m1.660s
sys     0m0.436s
注意:它立即中止,甚至不执行下一条信息行。

不会
消息(状态“错误消息”)
do?对我来说“生成安装错误”意味着
make install
返回非零返回值不会
消息(状态“错误消息”)
do?To me“生成安装错误”表示
make install
返回非零返回值