c++ - cmake 没有目标文件

标签 c++ linux makefile cmake object-files

我有一个 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/

相关文章:

c++ - 计算快速排序中的比较次数

linux - 帮助 %es 注册 x86 到 x86_64 汇编代码端口

c++ - Linux 进程可以拥有的最小进程 ID 是多少?

linux - GCC 错误消息 "Error: unsupported for ` mov'"是什么意思?

android - 使用Gradle开发Android AOSP应用

c++ - gcc 4.9.0 不接受 std::unique_ptr<void>

c++ - 堆损坏 : what happens if I don't close a (Q)file?

c++ - 如何在不设置值的情况下通知 C++ future?

c++ - 如何使用交叉链接器而不是 native 链接器

c++ - 正确编写我的 C++ Makefile 的问题