Sandburg
Sandburg

Reputation: 871

How to rerun previous CMake command line?

Is there a special command of CMake to ask it to rerun the previous command (stored in CMakeCache)?

Example:

# 1st time
cmake -DBUILD_TESTING=OFF "-GVisual Studio 15 2017 Win64" ..   #and many other

# 2nd in another session
cmake --rerun   #what I'm asking

Upvotes: 0

Views: 877

Answers (1)

Alex Reinking
Alex Reinking

Reputation: 19946

Assuming you're in the directory containing the CMakeCache.txt, it's just cmake .

All of the -D and -G flags are stored in corresponding variables in the cache when CMake first runs. Assuming it exited normally and the cache exists, then rerunning CMake on the build directory will use the same settings.

Where things might get hairy is if the CMakeLists.txt in question sniffs the environment in a computation that isn't cached appropriately. Since the CMake cache is not the environment, the effect of running that same command might not be what you expect. It is your responsibility to track the environment in which you run CMake.

Upvotes: 3

Related Questions