ubuntu cmake..中出现Could not find cmake module file Error required internal CMake variable not set,的问题

发布时间 2023-06-05 18:11:58作者: DoubleLi

ubuntu cmake…中出现的问题

在写一个helloworld的小工程,然后cmakelists如下

cmake_minimum_required( VERSION 2.8)
project (hello world)
add_executable(helloworld main.cpp)

执行cmake…
结果出现报错

CMake Error: Could not find cmake module file: CMakeDetermineworldCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_world_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_world_COMPILER
CMake Error: Could not find cmake module file: /home/south/code/123/CMakeFiles/3.16.3/CMakeworldCompiler.cmake
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_world_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_world_COMPILER to the full path to the compiler, or to the compiler
  name if it is in the PATH.


CMake Error: Could not find cmake module file: CMakeworldInformation.cmake
CMake Error: CMAKE_world_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/south/code/123/CMakeFiles/CMakeOutput.log".

上网找了很多的相关问题,有说需要用yum安装cmake的还有说是版本问题的
一一试过都不行,最后发现问题出在project()里面不能有空格。。。。。。。。

空格删掉最终cmake …成功

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/south/code/123

任重而道远啊…