我试图制作运行CMake的PowerShell脚本。这是我的示例代码(最后展示$CMAKE_OPTIONS = @{
"DBUILD_opencv_java:BOOL" = "OFF"
"DBUILD_opencv_python:BOOL" = "OFF"
"DBUILD_opencv_python2:BOOL" = "OFF"
"DBUILD_opencv_python3:BOOL" = "OFF"
"DBUILD_TESTS:BOOL" = "OFF"
"DBUILD_PERF_TESTS:BOOL" = "OFF"
"DBUILD_DOCS:BOOL" = "OFF"
"DBUILD_EXAMPLES:BOOL" = "OFF"
"DINSTALL_CREATE_DISTRIB:BOOL" = "ON"
}
# ... add something from user input
cmake -G $CMAKE_CONFIG_GENERATOR -DOPENCV_EXTRA_MODULES_PATH=$myRepo/opencv_contrib/modules -DCMAKE_INSTALL_PREFIX=$myRepo/install/$REPO_SOURCE $myRepo/$REPO_SOURCE @CMAKE_OPTIONS
):
foo = bar
但是我收到了一个错误:
命令行参数中的解析错误:-DBUILD_opencv_python:BOOL:OFF
应该是:VAR:type = value
CMake错误:未提供cmake脚本。
CMake错误:处理参数的问题。中止。
似乎不是写论据foo:bar
而是&cmake -p "myargs" $CMAKE_OPTIONS_STRING
。
如何在调用外部程序时正确地展开参数?或者我是否必须使用字符串连接和client = Mysql2::Client.new(:host => host, :username => username, :password => password, :database => database)
的旧方法?
答案 0 :(得分:3)
对于外部程序,使用数组,而不是哈希表:
$CMAKE_OPTIONS = @(
"-DBUILD_opencv_java:BOOL=OFF",
"-DBUILD_opencv_python:BOOL=OFF",
"-DBUILD_opencv_python2:BOOL=OFF",
"-DBUILD_opencv_python3:BOOL=OFF",
"-DBUILD_TESTS:BOOL=OFF",
"-DBUILD_PERF_TESTS:BOOL=OFF",
"-DBUILD_DOCS:BOOL=OFF",
"-DBUILD_EXAMPLES:BOOL=OFF",
"-DINSTALL_CREATE_DISTRIB:BOOL=ON"
)
cmake ... @CMAKE_OPTIONS