BeeOnRope
BeeOnRope

Reputation: 65056

Disable cmake reconfiguring itself from generated build files

Let's say you use cmake with the Makefile generator (the exact generator doesn't really matter here, most do this).

The generated Makefile from cmake will build your project, only rebuilding the parts that have changed. As part of this, the Makefile also checks if any of the cmake related files have changed (e.g., CMakeLists.txt) before running the build and in that case cmake is reconfigured to pick up the changes. So make can call cmake in this case.

Is it possible to disable this behavior so that the generated make files will not call back into cmake?

The context is that if you invoke the original cmake command using some kind of wrapper script that sets up a special environment for cmake, a later call to cmake from make won't have this special environment and may do the wrong thing.

Upvotes: 0

Views: 284

Answers (1)

Alex Reinking
Alex Reinking

Reputation: 20046

The context is that if you invoke the original cmake command using some kind of wrapper script that sets up a special environment for cmake, a later call to cmake from make won't have this special environment and may do the wrong thing.

This is a bug in your project, not a misfeature of CMake. Anything in your project that is derived from the environment ought to be cached. This typically happens automatically when you use built-in find_* commands. A pragmatic suggestion: don't read environment variables except to cache them, either directly or via the HINTS arguments to find_*.

Is it possible to disable this behavior so that the generated make files will not call back into cmake?

No.

Upvotes: 1

Related Questions