Search code examples
c++linuxmakefilecmakeobject-files

No object file from cmake


I have a C++ program I'm trying to make with CMake. The cmake part seems to go well, I get the following messages when I run cmake .. in the build directory:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/program/build

But when I run make -i, I get the following errors:

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

So am I missing a step somewhere? Do I have to manually create the object file in CMakeLists.txt somewhere? Thanks!

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)

Solution

  • Maybe, the matter is in the -i option?

    -i, --ignore-errors
        Ignore all errors in commands executed to remake files.