linux - CMake错误 "attempted to write a file ... into a source directory."

标签 linux ubuntu cmake trinitycore

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

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 已安装

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。

如何解决该错误?

最佳答案

正如评论中已经指出的,该消息

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

是项目的CMakeLists.txt中设置的CMAKE_DISABLE_SOURCE_CHANGES变量的结果。此设置激活检查,CMake 项目不会在源目录下创建任何文件。 (此变量设置的更精确描述请参见that answer)。

通常情况下,设置CMAKE_DISABLE_SOURCE_CHANGES变量会伴随着设置CMAKE_DISABLE_IN_SOURCE_BUILD变量,字面意思是:

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

解决方案是在与源目录不同的构建目录源代码外构建项目。

例如这样:

cd <project-dir>
mkdir build
cd build
cmake ..

关于linux - CMake错误 "attempted to write a file ... into a source directory.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52191556/

相关文章:

linux - 是否可以传递 linux bash 脚本的内部命令请求的参数?

linux - 打开 "An error was encountered while saving the command history"Matlab报错

github - 找不到 OpenSSL,尝试设置 OpenSSL 根文件夹的路径

c++ - Clang 与 CLion : Cannot get compiler information

c++ - 在64位linux机器上使用32位.a库文件

linux - 通过awk合并两个文件后空格成为制表符

c++ - QT 需要一个编译器设置来构建

c - linux设置串口中断

java - 使用Eclipse执行脚本文件

c++ - 为什么我不能链接到boost的线程库?