CMake Practice学习所遇问题及解决

问题1:cmake 的 helloworld中所遇到的问题

     本人使用的是Ubuntu18.04,直接在用户下的Desktop中建立了cmake文件夹。

      在cmake文件夹中创建了it文件夹,按照CMake Practice教程,在其中建立了main.cpp和CMakeLists.txt文件。

但是在输入相应的内容后,使用cmake . 后会提示错误:

CMake Error at CMakeLists.txt:5 (ADD_EXECUTABLE):
  Cannot find source file:

    main.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: hello
CMake Error: Cannot determine link language for target "hello".
-- Generating done

最终,发现问题是作者录入错误,应该在CMakeLists.txt文件中录入:

PROJECT (HELLO)
SET(SRC_LIST main.cpp)
MESSAGE(STATUS "This is BINARY dir " ${HELLO_BINARY_DIR})
MESSAGE(STATUS "This is SOURCE dir "${HELLO_SOURCE_DIR})
ADD_EXECUTABLE(hello ${SRC_LIST})

教程中,ADD_EXECUTABLE中,SRC_LIST并未加${},改正后,正常运行。

你可能感兴趣的:(SLAM学习,cmake,ubuntu)