您为库pugixml调用了ADD_LIBRARY,而没有任何源文件

时间:2019-05-08 02:05:28

标签: cmake

我正在使用quickrank:https://github.com/hpclab/quickrank。编译时出现错误

 cmake .. -DCMAKE_CXX_COMPLIER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Release
You have called ADD_LIBRARY for library pugixml without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: Cannot determine link language for target "pugixml".
CMake Error: CMake can not determine linker language for target: pugixml
CMake Error: CMake can not determine linker language for target: pugixml
-- Generating done
-- Build files have been written to: /home/students/s4438236/quickrank/build_
s4438236@moss:~/quickrank/build_$ make
make[2]: *** No rule to make target `CMakeFiles/pugixml.dir/build'.  Stop.
make[1]: *** [CMakeFiles/pugixml.dir/all] Error 2
make: *** [all] Error 2

我确实在lib\pugixml文件夹下找到了源文件,如何解决此错误?

1 个答案:

答案 0 :(得分:0)

调用add_library CMake命令时,必须为此目标提供源文件。如果我们检查顶级CMakeLists.txt文件,就会看到发生错误的地方:

# external libraries
file(GLOB_RECURSE pugixml_sources ${CMAKE_SOURCE_DIR}/lib/pugixml/src/*.cpp)
add_library(pugixml STATIC ${pugixml_sources})

CMake错误表明pugixml_sources变量为空,这暗示/lib/pubixml可能也为空。如果您最初没有使用git clone运行--recursive命令,则不会获得pugixml子模块。

看到您所说的pugixml源现在就在那里,我建议删除您的CMake缓存和CMake构建文件夹。从头开始再次运行CMake可能会允许它查看pugixml源文件。