ubuntu CMake错误“试图写入文件...到源目录中”

u5rb5r59  于 2023-08-03  发布在  其他
关注(0)|答案(1)|浏览(124)

更新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。
如何解决这个错误?

kmbjn2e3

kmbjn2e31#

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

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变量,字面意思为:

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

解决方案是在不同于 *source目录 * 的 *build目录 * 中构建项目out-of-source
例如:

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

相关问题