[SDL3.x] make / cmake Build Parameters

I once managed to do it with cmake or make and a parameter that opened a configuration dialog.
You could turn various options on and off. E.g. Wayland support.
But I can’t remember how I managed this.

Does anyone know how it worked?

cmake-gui ?

You can also provide these options through the command line interface like this -D SDL_WAYLAND=ON. These options can be found in CMakeLists.txt

These options can be found in CMakeLists.txt

You mean these lines?
I guess you can list them somehow with `cmake -???``.

...
set_option(SDL_ASSEMBLY            "Enable assembly routines" ${SDL_ASSEMBLY_DEFAULT})
dep_option(SDL_AVX                 "Use AVX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_AVX2                "Use AVX2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
...

cmake-gui ?

It wasn’t this tool, it was on the console by typing cmake ??? or make ???.

make edit_cache :grin: ?

Including these, yes.

cmake -LAH but this will include many other cache variables

Or cmake -LAH | grep -B1 '^SDL' to filter only SDL options.
I guess that might be more appropriate for you.

That’s almost it.
But only that I installed the following beforehand.
sudo apt install cmake-qt-gui.
But what I had open looked similar to the GUI tool, only that it ran in the console.

I believe ccmake (note the second c) comes with default cmake installation, it requires no graphical interface. Have you tried to call it directly? ccmake . in the build directory.

1 Like

Thanks
It was exactly this interface, just strange that it had worked without ccmake.

I now had to install it with sudo apt install cmake-curses-gui .

In the meantime, I know how to change the parameters in a build path with ccmake . or cmake-gut . .

I now change the following with cmake-gui

FREETYPE_INCLUDE_DIR_freetype usr/include/freetype2 → /usr/local/include/freetype2

Is it possible to change this value at the beginning, before you get to the first build folder?
So with the first make command?

So you’re talking about SDL_ttf?
FREETYPE_INCLUDE_DIR comes from the Freetype CMake package and is not used by SDL_ttf. SDL_ttf links Freetype with the CMake target, and if you want to change the used Freetype library you should refer to lines 218-257 (commit df316fa) of CMakeLists.txt.

Anyway, back to your question, as I said before, you can set the value of cache variables during initial configuration with the -D option:
-D <var>[:<type>]=<value> = Create or update a cmake cache entry.
For example cmake -D variable=value .

This is what I have now done, I entered it manually with -Dxxx, note the last 2 lines.

cmake -S ../SDL_ttf -B . \
  -DCMAKE_CXX_COMPILER="/usr/bin/x86_64-w64-mingw32-g++" \
  -DCMAKE_C_COMPILER="/usr/bin/x86_64-w64-mingw32-gcc" \
  -DCMAKE_RC_COMPILER="/usr/bin/x86_64-w64-mingw32-windres" \
  -DCMAKE_FIND_ROOT_PATH="/usr/x86_64-w64-mingw32" \
  -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \
  -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="ONLY" \
  -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" \
  -DCMAKE_SYSTEM_NAME="Windows" \
  -DFREETYPE_INCLUDE_DIR_freetype2="/usr/local/include/freetype2" \
  -DFREETYPE_INCLUDE_DIR_ft2build="/usr/local/include/freetype2"

I have now done this, I entered it manually with -Dxxx, note the last 2 lines.

But the error still occurs as described here: Build SDL3_ttf.DLL from Linux

But when I check it with cmake-gui, the changes have been applied. Now I just have to click [Generate] without changing anything and there is a working Makefile

  1. You should use mingw-cmake for cross-compiling

find_pacakge/importing Freetype subdirectory will override this variable.

What do you mean by “mingw-cmake” ?
I can’t find this anywhere with google.

It’s an alias for a script to call cmake with mingw compiler/paths configured.
After some research I found out that it only exists in Arch Linux packages, sorry for the disinformation :grin:.
About Freetype, you should either use it vendored (-DSDL3TTF_FREETYPE_VENDORED=ON) or set FREETYPE_DIR environment variable (not cache one, see /usr/share/cmake/Modules/FindFreetype.cmake). I guess FREETYPE_DIR=/usr/local/ cmake ... should do the trick for you.

BTW, installing cross-compiling libraries in /usr/local (intended for host software) is a very bad idea. You should maintain a separate prefix for each target, like /usr/x86_64-w64-mingw32/.

I’ve made some progress in the meantime.
You can use cmake-gui to change parameters for the later make.
You can also pass this directly with make.

cmake ../mathgl-8.0.1/ -Denable-glut="true" -Denable-fltk="true" -Denable-qt="true"

Instead of true you can also use on or 1.

What I still don’t know is, is there any way to use cmake to check what is possible?
Now I still have to look in the CMakeLists.txt to see what is in cmake_dependent_option().

See also
https://cmake.org/cmake/help/latest/command/if.html#constant

Usually there are two ways: read the project’s documentation or read the cmake file :grin: . Some CMake projects are very complex and use packages which have their own documentation and so on.
Options are specified with option command (and sometimes with plain set) and it’s trivial to find them as cache entries with trick I presented before.
I guess you should check CMake’s discourse https://discourse.cmake.org/