我有一个 C++ 程序,正在尝试使用 CMake 制作。 cmake 部分似乎进展顺利,当我在构建目录中运行 cmake .. 时,我收到以下消息:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/program/build
但是当我运行 make -i 时,出现以下错误:
Scanning dependencies of target project
[100%] Building CXX object CMakeFiles/project.dir/project.cpp.o
Linking CXX executable project
c++: error: CMakeFiles/project.dir/project.cpp.o: No such file or directory
[100%] Built target project
那么我是不是在某个地方错过了一步?我是否必须在 CMakeLists.txt 中的某处手动创建目标文件?谢谢!
CMakeLists.txt:
cmake_minimum_required (VERSION 3.0)
project (Project)
#include header files
include_directories(~/project)
set(SOURCES project.cpp ~/project/pmddatadescription.h ~/project/pmdsdk2.h ~/project/pmdsdk2common.h ~/project/stdafx.h)
# PCL
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
# VTK
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
# add the executable
add_executable(project project.cpp ${SOURCES})
#link installed libraries
target_link_libraries (project ${PCL_LIBRARIES})
target_link_libraries(project ${VTK_LIBRARIES})
#link .so libraries
target_link_libraries(project ~/project/libpmdaccess2.so)
最佳答案
也许问题出在-i
选项上?
-i, --ignore-errors
Ignore all errors in commands executed to remake files.
关于c++ - cmake 没有目标文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24763675/