0
工作考虑下面的CMakeLists.txtcmake的:add_dependencies不与外部项目
cmake_minimum_required(VERSION 3.0)
project(xyz)
include(ExternalProject)
set(EXTSRC ${CMAKE_SOURCE_DIR}/external)
ExternalProject_Add(q
GIT_REPOSITORY
"https://github.com/sftrabbit/CppSamples-Samples.git"
SOURCE_DIR ${EXTSRC}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
add_executable(xyzbin
${EXTSRC}/1-common-tasks/ranges/range-iteration.cpp)
add_dependencies(xyzbin q)
我会想到的是,外部项目文件被下载,然后再执行我的目标开始进行配置。然而,这种情况并非如此。
当我在源目录中建立一个目录运行“cmake的..”,它产生:
(usual configure stuff above ....)
-- Check for working CXX compiler: /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
CMake Error at CMakeLists.txt:16 (add_executable):
Cannot find source file:
/home/janberq/Desktop/cmake_problem/external/1-common-tasks/ranges/range-iteration.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: xyzbin
CMake Error: Cannot determine link language for target "xyzbin".
-- Generating done
-- Build files have been written to: /home/janberq/Desktop/cmake_problem/build
看起来,CMake的第一个试图获取器语言,这是不可能在因为我没有源文件。
我尝试添加,
set_target_properties(xyzbin PROPERTIES LINKER_LANGUAGE CXX)
但它并没有在所有的工作,很遗憾。我能做些什么来解决这个错误?
P.S.我的cmake版本是3.5.2,os:ubuntu 16.10。
可能的重复[如何在CMake中包含来自第三方项目的选定源代码](http://stackoverflow.com/questions/29041008/howto-include-selected-sources-from-third-party-project-in-cmake ) – Tsyvarev