ExternalProject_Add CONFIGURE_COMMAND不能包含双引号

时间:2014-07-03 16:58:21

标签: windows openssl cmake 64-bit

我尝试使用CMake在64位Windows上编译和构建OpenSSL。这是代码。

set(VS_ENV_SETUP "\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" amd64")
set(OPENSSL_CONFIGURE perl\ Configure\ VC-WIN64A)
set(OPENSSL_CONFIGURE ${VS_ENV_SETUP}\ &&\ ${OPENSSL_CONFIGURE})
set(OPENSSL_MAKE  ms\\do_win64a\ &&\ nmake\ -f\ ms\\ntdll.mak)

message(STATUS ${OPENSSL_CONFIGURE})
message(STATUS ${OPENSSL_MAKE})

ExternalProject_Add(openssl
PREFIX openssl
#-- Download Step ----------
SOURCE_DIR ${CMAKE_SOURCE_DIR}/ext/openssl
#URL ${CMAKE_SOURCE_DIR}/ext/openssl
#--Configure step ----------
CONFIGURE_COMMAND ${OPENSSL_CONFIGURE}
#--Build Step ----------
BUILD_COMMAND ${OPENSSL_MAKE}
BUILD_IN_SOURCE 1
#--install Step ----------
INSTALL_COMMAND ""} 
)

endif()

打印出的消息表示围绕vcvarsall.bat的文件名扭曲的一组双引号,如:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 && perl Configure VC-WIN64A

但是当我将该命令作为参数放在ExternalProject_Add中时,它会抱怨

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/ExternalProject.cmake:1032
(add_custom_command):COMMAND may not contain literal quotes: "C:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\vcvarsall.bat" amd64  && perl Configure VC-WIN64A

如果我没有引用该命令,在建造过程中它不会被认为是一个完整的命令:(

解决方案或解决方法是什么?

1 个答案:

答案 0 :(得分:1)

您无需保护*.bat个文件,VS_ENV_SETUP是一个以;分隔的列表,所以它可以这样:

set(VS_ENV_SETUP "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat" amd64)

BTW 1

您可以使用unix样式目录分隔符来避免无休止的\\

set(VS_ENV_SETUP "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/vcvarsall.bat" amd64)

BTW 2

您可以使用*_COMMAND代替COMMAND来扩展&&步骤(至少在此特定情况下):

ExternalProject_Add(
    ...
    # configure begin --
    CONFIGURE_COMMAND ${VS_ENV_SETUP}
    COMMAND perl Configure VC-WIN64A
    # -- end
    ...
)