2

I got errors after update CMake to version 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 is installed

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++ is installed too. Ubuntu Version 14.04.5.

How to solve that error?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
GoE
  • 586
  • 1
  • 8
  • 19
  • Did you remove build directory and run cmake again? – theoden8 Sep 05 '18 at 18:42
  • yes, but it's the same error – GoE Sep 05 '18 at 18:45
  • 1
    The first error - " file attempted to write a file:" - looks suspicious. Show your code up to the `project()` call. – Tsyvarev Sep 05 '18 at 18:55
  • @Tsyvarev Where can i find this? I never used cmake before... it's the TrinityCore Projekt – GoE Sep 05 '18 at 19:06
  • Looks like the OP set `CMAKE_DISABLE_IN_SOURCE_BUILD` and/or `CMAKE_DISABLE_SOURCE_CHANGES` (see [this SO answer](https://stackoverflow.com/a/10306476/1896169)) – Justin Sep 05 '18 at 19:10
  • @GoE It's the CMakeLists.txt file in the root directory of the project – Justin Sep 05 '18 at 19:11
  • 1
    My crystal ball says that you set `CMAKE_DISABLE_IN_SOURCE_BUILD` and/or `CMAKE_DISABLE_SOURCE_CHANGES`, then tried to do an in-source build. In other words, from the root directory of the project, you just wrote `cmake .`. Create a `build` subdirectory and run cmake inside there. For a decent project structure (it's still a WIP), see https://github.com/vector-of-bool/vector-of-bool.github.io/blob/master/_drafts/project-layout.md – Justin Sep 05 '18 at 19:18
  • @Justin: You guess seems to be right, TrinityCore's [CMakeLists.txt](https://github.com/TrinityCore/TrinityCore/blob/master/CMakeLists.txt) sets exactly those variables. – Tsyvarev Sep 05 '18 at 20:13
  • Does this answer your question? [CMAKE\_MAKE\_PROGRAM not found](https://stackoverflow.com/questions/6141608/cmake-make-program-not-found) – Vic Seedoubleyew Aug 19 '20 at 12:27

1 Answers1

2

As already noted in the comments, the message

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

is a result of CMAKE_DISABLE_SOURCE_CHANGES variable set in the project's CMakeLists.txt. This setting activates the check, that CMake project won't create any file under the source directory. (More precise description of this variable setting see in that answer).

Normally, setting CMAKE_DISABLE_SOURCE_CHANGES variable is accompanied with setting CMAKE_DISABLE_IN_SOURCE_BUILD variable, with literal meaning:

The project should NOT be built in-source.

Solution is to build the project out-of-source, in the build directory which differs from the source one.

E.g. that way:

cd <project-dir>
mkdir build
cd build
cmake ..
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153