0
votes

I am trying to configure PCL With visual studio but I am facing an error when using cmake. I am using pcl 1.8 with VS 2013 and cmake 3.14. I could successfully did the configuration step but when I move to generate, I do face add_executable error.

this is my cmakelists

cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 
project(cloud_viewer)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS}) 
link_directories(${PCL_LIBRARY_DIRS}) 
add_definitions(${PCL_DEFINITIONS})

add_executable (cloud_viewer cloud_viewer.cpp) 
target_link_libraries (cloud_viewer ${PCL_LIBRARIES})

This is the error I get:

CMake Error at CMakeLists.txt:11 (add_executable): Cannot find source file: cloud_viewer.cpp Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx CMake Error at CMakeLists.txt:11 (add_executable): No SOURCES given to target: cloud_viewer


Image that shows both CMakelists.txt and cloud_viewer being in the same folder

[enter image description here

Could anyone help me solving it. thanks in advance.

1
Please paste your CMakeLists code here, instead of an image.Hatted Rooster
Also, the error is pretty self explanatory. It can't find the cpp file you want to add.Hatted Rooster
I have pasted the CMakeLists code. the ccp file is created and i don't know why it can't find it. Is there anything I should follow to get the error solved?Adnan
@Adnan With this syntax, you should place the cloud_viewer.cpp right next to the CMakeLists.txtGuillaume Racicot
@GuillaumeRacicot this is actually what I did. cloud_viewer.cpp is right next to the CMakeLists.txtAdnan

1 Answers

3
votes

Looking at your screenshot, you should name your file cloud_viewer.cpp, not cloud_viewer.ccp. Be careful about the extension: cpp vs ccp


On a side note, try using the cmake taget based system instead of the directory based:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 
project(cloud_viewer)

find_package(PCL 1.2 REQUIRED)

add_executable(cloud_viewer cloud_viewer.cpp) 
target_link_libraries(cloud_viewer PUBLIC ${PCL_LIBRARIES})
target_compile_definitions(cloud_viewer PUBLIC ${PCL_DEFINITIONS})
target_include_directories(cloud_viewer PUBLIC ${PCL_INCLUDE_DIRS})