from CmakeCache.txt to CMakeLists.txt

Hi Team,

I generated all the build files in the build directory and edited the options using ccmake gui on Ubuntu 20.04 system.

How do I generate the CMakeLists file again from the build files in the build direcotry? ccmake provides an option ‘g’ and I can build the modified files using the command make in the build direcotry.


You can’t generate a CMakeLists.txt file from CMakeCache.txt, it only goes in the other direction. The “generate” you see in ccmake (or in CMake GUI, for that matter) refers to generating the project files for the generator you are using (e.g. the Makefiles or Ninja project files). If you run the cmake command line tool, configure and generate are both run for you. With ccmake and CMake GUI, you can run these two steps individually. You always have to run configure at least once before you can generate though.

When you edit options in ccmake or in CMake GUI, you need to then run the configure step and then the generate step. Running configure will also update the CMakeCache.txt with the values you changed.