after clicking configure I was asked to click a generator but it didn't work

I’ve never used CMake before. I am using it now to generate files for a computer graphics tutorial which uses OpenGL. I believe the tutorial is trying to compile all of the example projects and opengl binaries using a CMakelists.txt.

step 1. I set the “where is the source code” line to the location of the cmakelists.txt file provided by the tutorial.

step 2. I set the "where to build binaries’ line to a directory called “build” in the same folder as the cmakelists.txt file. (the tutorial didn’t say where to put them)

step 3. I clicked the configure button

At that point it asked me to choose a generator from a list. I don’t even know what a generator is and a websearch didn’t help.

step 4. I arbitrarily chose a codeblocks generator because codeblocks is the IDE I use. There were 5 options for codeblocks generators.

At this point, CMake gave me error messages

CMake Deprecation Warning:
Support for “Extra Generators” like

CodeBlocks

is deprecated and will be removed from a future version of CMake. IDEs may
use the cmake-file-api(7) to view CMake-generated project build trees.

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 has been removed from CMake.

Update the VERSION argument value. Or, use the … syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by or earlier.

Or, add to try configuring anyway.

Configuring incomplete, errors occurred!

I don’t know what to do from here. I don’t know how to try a different generator. I don’t know how to add -DCMAKE_POLICY_VERSION_MINIMUM=3.5. Even if I knew how to try a different generator I have no frame of reference to decide which option to choose.

CMake assumes a lot of base knowledge in how to build C++ programs generally, and most of the documentation and the tutorial are geared towards people who only need to learn to “spell” the operations in CMake’s language.

CMake is a configuration program, like autoconf or meson, it does not directly build any programs. It exists to figure out how a program can be built in the current environment, whether that be a Windows, Mac, or Linux machine, and figures out the correct way to invoke various pieces of the toolchain like compilers, linkers, archivers, and other programs involved in building a C++ program.

If CMake successfully figures all these things out, it “generates” a build system to actually perform the work. A build system is a program that knows how to run all the steps that CMake has determined are necessary to create the C++ program. When CMake is asking you to select a “generator”, it’s asking you to tell it what build system you would like it to create.

There are many generators, but today only a handful are considered relevant. These are the Visual Studio generators, the XCode generator, the Ninja generator, and the Unix Makefile generator. Each of these correlate to their associated build system, so the Visual Studio generator creates files that can be used with Visual Studio, etc.

The warning you’re seeing is because using CodeBlocks as a build system isn’t very popular these days, so the generator for it has been deprecated and will eventually be removed. You’ll be better off using one of the other build systems I mentioned, depending on your platform. You can still use CodeBlocks as an IDE; this only means a different program will run the commands to build your code.

The error you’re seeing about compatibility with CMake 3.5 is because compatibility with versions older than this were removed in CMake 4.0. The fix is easy, in your cmake_minimum_required(VERSION) line, change the version to something newer than 3.5. Good advice for beginners is to set this number to whatever CMake version you’re currently using.

1 Like

thank you for the reply. Where would I find that line to change it, in the cmakefile.txt? And what would I change it to, 4.1(the version of CMake I just downloaded)?

I’ve been programming on and off for about 40 years and things change so fast it is hard to keep up. I went to college for programming yet still feel so helpless trying to figure out how to adapt to the convention du jour. I feel like I need to go to college again but who can afford that?

We can find the line that needs to be changed from the error message:

CMake Error at CMakeLists.txt:1

This tells us that there is an error in the file named CMakeLists.txt, and the :1 tells us the error has occurred on the first line of that file. This format is common, you will be familiar with it from any compiler error messages you may have seen in the past.

So on the first line of your CMakeLists.txt you have a command of the form:

cmake_minimum_required(VERSION X.Y)

Where X.Y is some version number lower than 3.5. You should change this to a version number >= 3.5. My recommendation is to use 4.1, as that is the verison you are currently using, so it makes sense that you would be targetting that as your compatibility profile.

As you gain experience with CMake, you may wish to target older versions for compatibility with platforms that ship older versions of CMake by default. Cross that bridge when you come to it, it is an unimportant consideration for a newcomer to CMake.

1 Like

thank you again.

I tried it and got new errors.

In the bottom panel it says “CMake Error at CMakeLists.txt:11 (message):
GLM is a header only library, no need to build it. Set the option
GLM_TEST_ENABLE with ON to build and run the test bench”

which appears to be a copied line from line 11 of the cmakefiles.txt

Does that mean I should delete the lines of that if statement? Lines 9-12 are an if statement.

option(GLM_TEST_ENABLE “GLM test” OFF)
if(NOT GLM_TEST_ENABLE)
message(FATAL_ERROR “GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench”)
endif()

in the middle box…
CMAKE_BUILD_TYPE
CMAKE_CODEBLOCKS_COMPILER_ID
CMAKE_CODEBLOCKS_EXECUTABLE-NOTFOUND
CMAKE_CODEBLOCKS_MAKE_ARGUMENTS
CMAKE_GNUtoMS
C:/Program Files (x86)/glm
GLM_TEST_ENABLE

You’re using a truly ancient release of GLM, circa 2014 or older, the last release with that code in it was 0.9.5.3. Back then GLM didn’t support being consumed via add_subdirectory() (for whatever reason).

I would use a release from this decade and follow their instructions for how to consume the library. A standard install (via whatever mechanism, vcpkg is popular) and find_package(glm CONFIG REQUIRED) is typical.

The GLM ReadMe has good documentation on how it wants to be consumed.

1 Like

a new release of GLM? In my experience new versions and old versions often don’t work together. I.e. I just downloaded new versions of glfw3 which made all of my old programs not work and I can’t even get a new program to work with them.

perhaps vcpkg is just what I need but what does it do with all of the .h .lib .a .dll? Would each program have its own set of binaries? I don’t suppose its output could go into system or system32 because it sounds like it would break lots of things.

If you want to stick with the usage from that era, GLM 0.9.5.3 and older expects to be vendored into your codebase and the includes added to your targets via target_include_directories().

This was never very good practice and why that error conditional was removed 10+ years ago, but it’s how the code would have been used back then.

1 Like

I appreciate your help but I think I’m just gonna abandon the idea of making this work.