'Select CMake's release mode from command line on any platform

I'm looking to set CMake's release mode from the command-line on any platform. I found e.g. here that the details are slightly different on the different platforms. But to simplify CI-setup I'm looking to execute the same command on Unix and Windows. I tried:

cmake . -DCMAKE_BUILD_TYPE=RELEASE
cmake --build .

But then I get on Windows:

Manually-specified variables were not used by the project:

   CMAKE_BUILD_TYPE

Is it even possible? If so, what should I use?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source