Issue
I have been getting the messsage
Re-run cmake no build system arguments
And various failures of my nascent CMake build system. I have also googled and found about a dozen results where that error message appears, but none of those hits tell you what the specific message means. Most of these cases are on the websites of specific projects, so the specific project maintainers just skip over hours of analysis and spit out a reason for the message, which the project user is happy to use.
I have also stumbled onto the CMake source code line which emits this text.
if (this->CheckBuildSystemArgument.empty()) {
if (verbose) {
cmSystemTools::Stdout("Re-run cmake no build system arguments\n");
}
return 1;
}
So an argument is empty. This doesn't explain anything because a minimal valid invocation of 'cmake' is
cmake .
It's not the best invocation:
cmake ..
is regarded as much better by CMake mavens, assuming that the current directory is empty and the parent has CMakeLists.txt. People who use CMake all the time will recognize that there isn't normally a 'build system argument' on the command line. If you search the cmake.org documentation there is no documentation of such concept as a "build system" or "build system argument".
The build system I am trying to bring into existence is a bit complex to faithfully summarize here. So instead I would like to learn what this message actually means and some idea of how I could make it go away. I tried minimizing my build system to fix a different problem, in fact, and I didn't even reproduce the problem. Also that minimization was in an outer layer, which is in fact a Makefile and covered an issue of controlling things with environment variables.
So, could someone tell me what "Re-run cmake no build system arguments" means?
Solution
To start off with some context, there is plenty of info in the CMake documentation about build systems, as this is CMake's primary function. CMake is a build system generator. From the documentation, a summary of CMake's role with regard to build systems:
A buildsystem describes how to build a project’s executables and libraries from its source code using a build tool to automate the process. For example, a buildsystem may be a
Makefile
for use with a command-line make tool or a project file for an Integrated Development Environment (IDE). In order to avoid maintaining multiple such buildsystems, a project may specify its buildsystem abstractly using files written in the CMake language. From these files CMake generates a preferred buildsystem locally for each user through a backend called a generator.
With that in mind, CMake tries to make things easy by checking the build system for us. This way, if we update our CMake files, we don't have to remember to re-run CMake and regenerate the build system. This "build system check" runs by default when invoking cmake
from the command line. But, it will also run when you build your code (e.g. by running make
), to verify your build system is up-to-date.
You can actually see the special pre-defined CMake target that checks your build system. For Makefile-based build systems, it will look something like this in your Makefile:
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 0
.PHONY : cmake_check_build_system
The undocumented CMake command line option --check-build-system
followed by the CMakeFiles/Makefile.cmake
is the "build system argument" you were seeking.
This message:
Re-run cmake no build system arguments
appears when running cmake
because CMake still internally performs a build system check. In this case, the --check-build-system
argument is not provided so CMake always regenerates as expected. So, it is not an error message, but simply a verbose log message giving a little more information about what CMake is doing.
For what it's worth, this "build system check" should occur with all CMake build systems. For example, Visual Studio creates a ZERO_CHECK
target which has the same behavior. It uses the --check-stamp-list
command line option (also undocumented) instead to check to ensure your project/solution is up-to-date.
Another note: you can disable CMake's automatic build system check by switching the CMAKE_SUPPRESS_REGENERATION
variable to ON
. Just place this at the bottom of your top-level CMake file:
set(CMAKE_SUPPRESS_REGENERATION ON)
Of course, CMake will always regenerate when you invoke cmake
directly. But when this variable is ON
, the special regeneration target will be removed (cmake_check_build_system
for Makefiles, ZERO_CHECK
for Visual Studio, etc).
Answered By - Kevin Answer Checked By - Cary Denson (WPSolving Admin)