在Win7上使用cmake版本3.7.0-rc3,我可以使用ExternalProject_Add_Step运行以下代码没问题。但是在Ubuntu16上使用cmake版本3.7.0,我收到错误:
add_custom_command given APPEND option with output "ExternalProjects/Stamp/boost/boost-CONFIGURE" which is not already a custom command output.
这是重现问题的简化代码。
ExternalProject_Add(
boost
URL https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz/download
URL_HASH MD5=6f4571e7c5a66ccc3323da6c24be8f05
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add_Step(
boost UNIX_CONFIGURE DEPENDEES DOWNLOAD DEPENDERS CONFIGURE
WORKING_DIRECTORY "<SOURCE_DIR>" COMMAND ./bootstrap.sh
)
罪魁祸首似乎是DEPENDERS CONFIGURE
。如果我把它拿出来,那就行了。但是......我希望能够指定步骤CONFIGURE依赖于此自定义步骤,而在Windows上我可以,但在Ubuntu上我无法做到。有什么想法吗?
答案 0 :(得分:2)
我没有在documentation中看到它,但您只是遇到了一个区分大小写的问题。将您的CMakeLists.txt
修改为:
❯ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.7)
include(ExternalProject)
ExternalProject_Add(
boost
URL https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz/download
URL_HASH MD5=6f4571e7c5a66ccc3323da6c24be8f05
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add_Step(
boost UNIX_CONFIGURE DEPENDEES download DEPENDERS configure
WORKING_DIRECTORY "boost-prefix/src/boost/" COMMAND ./bootstrap.sh
)
请注意&#34;下载&#34;和&#34;配置&#34; ExternalProject_Add_Step()
中的❯ cmake ..
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/nega/foo/build
❯ make
Scanning dependencies of target boost
[ 11%] Creating directories for 'boost'
[ 22%] Performing download step (download, verify and extract) for 'boost'
-- verifying file...
file='/Users/nega/foo/build/boost-prefix/src/boost_1_62_0.tar.gz'
-- File already exists and hash match (skip download):
file='/Users/nega/foo/build/boost-prefix/src/boost_1_62_0.tar.gz'
MD5='6f4571e7c5a66ccc3323da6c24be8f05'
-- extracting...
src='/Users/nega/foo/build/boost-prefix/src/boost_1_62_0.tar.gz'
dst='/Users/nega/foo/build/boost-prefix/src/boost'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] Performing UNIX_CONFIGURE step for 'boost'
Building Boost.Build engine with toolset darwin... tools/build/src/engine/bin.macosxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /Users/nega/i3/virtenv
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html
[ 44%] No update step for 'boost'
[ 55%] No patch step for 'boost'
[ 66%] No configure step for 'boost'
[ 77%] No build step for 'boost'
[ 88%] No install step for 'boost'
[100%] Completed 'boost'
[100%] Built target boost
现在已经落后了。现在,cmake并成功完成。
boost-prefix/src/boost-stamp
现在,查看构建目录的❯ v boost-prefix/src/boost-stamp
total 32
drwxr-xr-x 15 nega staff 510 Dec 20 12:29 ./
drwxr-xr-x 6 nega staff 204 Dec 20 12:28 ../
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-UNIX_CONFIGURE
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-build
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-configure
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-done
-rw-r--r-- 1 nega staff 0 Dec 20 12:28 boost-download
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-install
-rw-r--r-- 1 nega staff 0 Dec 20 12:28 boost-mkdir
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-patch
-rw-r--r-- 1 nega staff 0 Dec 20 12:29 boost-update
-rw-r--r-- 1 nega staff 173 Dec 20 12:18 boost-urlinfo.txt
-rw-r--r-- 1 nega staff 4424 Dec 20 12:18 download-boost.cmake
-rw-r--r-- 1 nega staff 1611 Dec 20 12:28 extract-boost.cmake
-rw-r--r-- 1 nega staff 0 Dec 20 12:28 verify-boost.cmake
:
❯ grep -i unix ../CMakeLists.txt
boost uNiX_CoNFiGuRe DEPENDEES download DEPENDERS configure
❯ make | grep -i unix
[ 33%] Performing uNiX_CoNFiGuRe step for 'boost'
❯ find boost-prefix/src/boost-stamp | grep -i unix
boost-prefix/src/boost-stamp/boost-uNiX_CoNFiGuRe
你会注意到每一步都有一个&#34;文件标记&#34;以它命名。默认步骤全部为小写,您的自定义步骤&#34; UNIX_CONFIGURE&#34;是大写的,就像你定义它一样。如果您将自定义步骤与大小写混合,则可以将其作为输出。
make
另外,请查看[ 22%] Performing download step (download, verify and extract) for 'boost'
[....]
[ 33%] Performing uNiX_CoNFiGuRe step for 'boost'
[....]
[ 44%] No update step for 'boost'
[ 55%] No patch step for 'boost'
[ 66%] No configure step for 'boost'
[ 77%] No build step for 'boost'
[ 88%] No install step for 'boost'
[100%] Completed 'boost'
[100%] Built target boost
输出。
ExternalProject
所有默认步骤均以小写形式引用。
在CMake的{{1}}模块中,请参阅小写的默认步骤。