externalproject_add 没有在正确的目录中查找?

externalproject_add does not look in the right directory?

出于某种原因,我在使用 cmake 和外部项目的配置步骤时遇到了问题。它以某种方式使用了与我指定的路径不同的路径?

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    CONFIGURE_COMMAND   ${SOURCE_DIR}/configure
    BUILD_IN_SOURCE     0
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

但是当我成功的时候

make 
[ 11%] Built target record
[ 22%] Built target spectogram
[ 33%] Built target database
[ 44%] Built target match
[ 55%] Built target cmakeDemo
[ 61%] Performing update step for 'project_portaudio'
Current branch master is up to date.
[ 66%] Performing configure step for 'project_portaudio'
/bin/sh: /configure: No such file or directory
make[2]: *** [src/include/record/lib/portaudio/src/project_portaudio-stamp/project_portaudio-configure] Error 127
make[1]: *** [src/include/record/CMakeFiles/project_portaudio.dir/all] Error 2
make: *** [all] Error 2

从这里可以看出。配置步骤应该在 ${SOURCE_DIR} 而不是 ${stamp_dir}

怎么会?

您可能想使用 <SOURCE_DIR> 而不是 ${SOURCE_DIR}

后一个是指CMake变量,很少有,前者会展开到一个目录,赋值为一个 SOURCE 一个用于 ExternalProject 的。