cmake认为变量是一个目录

时间:2017-02-14 19:56:07

标签: cmake trilinos

我正在尝试使用建议的cmake路由安装trilinos软件包。我对cmake没有任何经验,但我找到了一个示例bash脚本。当我尝试执行此脚本时,我收到错误

CMake错误:源目录“/ home / USER / code / packages / trilinos_build / MPI_EXEC:FILEPATH = / usr / bin / pkg / mpiexec”不存在。 指定--help用于使用,或按CMake GUI上的帮助按钮。

我检查了cmake doc,我很确定语法是否正确,我缺少什么?

#!/bin/bash

# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source
TRILINOS_BUILD_PATH=./

#
# You can invoke this shell script with additional command-line
# arguments.  They will be passed directly to CMake.
#
EXTRA_ARGS=$@

#
# Each invocation of CMake caches the values of build options in a
# CMakeCache.txt file.  If you run CMake again without deleting the
# CMakeCache.txt file, CMake won't notice any build options that have
# changed, because it found their original values in the cache file.
# Deleting the CMakeCache.txt file before invoking CMake will insure
# that CMake learns about any build options you may have changed.
# Experience will teach you when you may omit this step.
#
rm -f CMakeCache.txt

#
# Enable all primary stable Trilinos packages.
#
cmake \
  -D CMAKE_INSTALL_PREFIX:FILEPATH="${TRILINOS_BUILD_PATH}/mpi" \
  -D CMAKE_BUILD_TYPE:STRING=RELEASE \
  -D Trilinos_ENABLE_TESTS:BOOL=OFF \
  -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
  -D TPL_ENABLE_MPI:BOOL=ON \
  -D MPI_EXEC:FILEPATH="/usr/bin/pkg/mpiexec" \


$EXTRA_ARGS \
$TRILINOS_PATH

1 个答案:

答案 0 :(得分:0)

我和cmake有类似的问题,这是因为白色进入最后一行和$ EXTRA_ARGS \之间。只需删除空行,错误就会消失。

所以你的文件应该是这样的:

#!/bin/bash

# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source
TRILINOS_BUILD_PATH=./

#
# You can invoke this shell script with additional command-line
# arguments.  They will be passed directly to CMake.
#
EXTRA_ARGS=$@

#
# Each invocation of CMake caches the values of build options in a
# CMakeCache.txt file.  If you run CMake again without deleting the
# CMakeCache.txt file, CMake won't notice any build options that have
# changed, because it found their original values in the cache file.
# Deleting the CMakeCache.txt file before invoking CMake will insure
# that CMake learns about any build options you may have changed.
# Experience will teach you when you may omit this step.
#
rm -f CMakeCache.txt

#
# Enable all primary stable Trilinos packages.
#
cmake \
  -D CMAKE_INSTALL_PREFIX:FILEPATH="${TRILINOS_BUILD_PATH}/mpi" \
  -D CMAKE_BUILD_TYPE:STRING=RELEASE \
  -D Trilinos_ENABLE_TESTS:BOOL=OFF \
  -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
  -D TPL_ENABLE_MPI:BOOL=ON \
  -D MPI_EXEC:FILEPATH="/usr/bin/pkg/mpiexec" \
$EXTRA_ARGS \
$TRILINOS_PATH

此外,如果您在-D选项之间按#注释任何行,则会显示相同的错误。在cmake之后\所有行必须是连续的。

希望它有所帮助!