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