2

I think default configuration types one can describe like this:

Debug          : w/ debug symbols, w/o optimization
Release        : w/o debug symbols, w/ optimization
RelWithDebInfo : w/ debug symbols, w/ optimization
MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries

But I need new one:

MyConf         : w/o debug symbols, w/o optimization

So, how to create it?

1 Answer 1

8

About table

Configurations in terms of gcc/clang compilers (CMake 3.4.1):

  • Debug: -g
  • Release: -O3 -DNDEBUG
  • RelWithDebInfo: -O2 -g -DNDEBUG
  • MinSizeRel: -Os -DNDEBUG

It means:

  +---------------+--------------+--------------+----------+
  |               | optimization | assert works | stripped |
  +---------------+--------------+--------------+----------|
  |     Debug     |     no       |     yes      |    no    |
  |    Release    |    full      |      no      |   yes    |
  | RelWithDebInfo|    good      |      no      |    no    |
  |   MinSizeRel  |    size      |      no      |   yes    |
  +---------------+--------------+--------------+----------+

So I don't agree with your MinSizeRel description because in this case I think both MinSizeRel and Release are stripped.

About question

As far as I understand you want no extra flags at all (no -g, -O* or -DNDEBUG). For Makefile-like generators:

> cmake -H. -B_builds -DCMAKE_BUILD_TYPE=MyConf -DCMAKE_CXX_FLAGS_MYCONF=""
> cmake --build _builds

For generators like Visual Studio you need to use CMAKE_CONFIGURATION_TYPES (see this answer):

> cmake -H. -B_builds -DCMAKE_CONFIGURATION_TYPES="Release;Debug;RelWithDebInfo;MinSizeRel;MyConf" -DCMAKE_CXX_FLAGS_MYCONF="/Od" -DCMAKE_EXE_LINKER_FLAGS_MYCONF=""
> cmake --build _builds --config MyConf
2
  • Thanks @ruslo! I think that's is what I need. But what this args for cmake do: cmake -H. -B_builds
    – JeriX
    Commented Jan 24, 2015 at 12:02
  • 1
    @ruslo Not sure if this is something that has changed with CMake versions, but for some time now, I've seen RelWithDebInfo have NDEBUG defined by default, which means asserts become no-ops. This is on both Linux and OS X with gcc/clang. Perhaps you could re-check and update your answer if this is indeed the case? Commented Dec 19, 2015 at 21:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.