关于linux:Ubuntu cmake更新后出现错误

Ubuntu cmake errors after update

将cmake更新到版本3.12.1后出现错误

1
2
3
4
5
6
7
8
9
10
11
CMake Error at /usr/local/share/cmake-3.12/Modules/CMakeDetermineSystem.cmake:174 (file):
  file attempted to write a file:
  /home/wow/TrinityCore/CMakeFiles/CMakeOutput.log into a source directory.
Call Stack (most recent call first):
  CMakeLists.txt:19 (project)


CMake Error: CMake was unable to find a build program corresponding to"Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

make已安装

1
2
3
4
5
6
7
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu

g。 Ubuntu版本14.04.5

有什么帮助或想法吗?

谢谢!


正如评论中已经提到的那样,消息

1
file attempted to write a file ... into a source directory

是在项目的CMakeLists.txt中设置的CMAKE_DISABLE_SOURCE_CHANGES变量的结果。此设置激活检查,即CMake项目不会在源目录下创建任何文件。 (有关此变量设置的更详细说明,请参见该答案。)。

通常,设置CMAKE_DISABLE_SOURCE_CHANGES变量与设置CMAKE_DISABLE_IN_SOURCE_BUILD变量相伴,其字面含义:

该项目不应在源代码中构建。

解决方案是在与源目录不同的build目录中以非源方式构建项目。

例如这样:

1
2
3
4
cd <project-dir>
mkdir build
cd build
cmake ..