How to set -DCMAKE_BUILD_TYPE=Release in CMake Settings?
Answered
All I want to do is to go to "CMake Settings..." or "Preferences->Build...->Make" and have one Profile called "Debug" and one profile called "Release".
The profile "Debug" was already there. So I added a profile "Release".
I needed to add one custom cmake option "-DBUILD_FORX=ON". I also made sure it still says "-DCMAKE_BUILD_TYPE=Release" in the cmake options.
I I change configuration to release, CLion still runs cmake with "-DCMAKE_BUILD_TYPE=Debug" even though I explicitly changed that to "-DCMAKE_BUILD_TYPE=Release"
Is this a bug? If yes it is a terrible bug.
Please sign in to leave a comment.
I found the solution myself. If you click on CMake in the bottom left of the main window, then there are two tabs on the top of the textfield that shows the Cmake output. The tabs show a colorful triangle icon and are labeled by the profile names "Debug" and "Release". So to build with -DCMAKE_BUILD_TYPE=Release, I just have to make sure I activate the "Release" tab, and similarly for "Debug". It is just hard to find and see if you don't know where it is.
I have circled the solution here:
Hello! Please note that if you have two CMake profiles, you need to choose the one you want to use for building in the switcher: