4

In our project we use CMake with two different build targets: Debug and Release.

Clion does provide two extra build targets: RelWithDebInfo and MinSizeRel. Now, when Clion creates the CMake cache (for all 4, we only use 2) it fails, because we do not allow other build targets besides of debug or release.

Your first workaround is to use this on the main CMakeList.txt:

if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug|Release")
    return()
endif()

But is it possible to disable these two configuration from Clion by default?

Viatorus
  • 1,804
  • 1
  • 18
  • 41
  • I would assume that what works for Visual Studio - changing `CMAKE_CONFIGURATION_TYPES` - also does work for Clion. See e.g. ["Cmake generators for Visual Studio do not set CMAKE_CONFIGURATION_TYPES"](http://stackoverflow.com/questions/31661264/cmake-generators-for-visual-studio-do-not-set-cmake-configuration-types). – Florian Jul 27 '16 at 10:38

2 Answers2

9

CLion by default generates these 4 configurations. So to force it to generate only Debug and Release use set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) in your CMake. Documentation.

nastasiak2512
  • 1,857
  • 14
  • 14
  • I've set this to only build RelWithDebInfo. However, I notice there is also a `__default__` created alongside RelWithDebInfo in the cmake products. Is there any way to consolidate so only one configuration is run? – Hayk Martiros Oct 05 '16 at 00:12
  • Default is some specific configuration necessary for CLion. But right now (2016.3) CLion builds only one configuration at a time. Check - https://blog.jetbrains.com/clion/2016/10/clion-2016-3-eap-cmake-overload-resolution/#cmake – nastasiak2512 Dec 14 '16 at 12:43
2

If you are looking for clear CLion only solution without changing CMakeLists go to File->Settings->Build,Execution,Deployment->CMake and remove configurations you don't want to deal with. enter image description here

kyb
  • 7,233
  • 5
  • 52
  • 105