[CMake] Tests with assert and Release build type

Ruslan Baratov ruslan_baratov at yahoo.com
Mon Dec 21 14:03:21 EST 2015


On 20-Dec-15 01:31, Magnus Therning wrote:
> Ruslan Baratov writes:
>
>> How about using RelWithDebInfo? See:
>> http://stackoverflow.com/a/28124715/2288008
> Hmm, I'm probably missing something but how does that solve the issue
> with some targets requiring NDEBUG to be *undefined* and other targets
> requiring NDEBUG to be defined?
I don't think that building targets with different NDEBUG values is a 
good idea. More correct approach will be to introduce custom macro to 
allow checks (i.e. FOO_NDEBUG/FOO_DEBUG).

>
> /M
>
>> On 18-Dec-15 20:55, Magnus Therning wrote:
>>> I'm sure I'm not the first one to run into the conflict between a desire
>>> to test the code shipped to customers and the desire to at the same time
>>> define NDEBUG to make sure tests don't have their `assert` turned into
>>> NOOPs.
>>>
>>> Is there some nice way of handling this?
>>>
>>> I can always remove -DNDEBUG from the CFLAGS for tests (possibly by
>>> defining a new macro, `ADD_EXECUTABLE_TEST()` or something). Another
>>> option is to `#undef NDEBUG` in the source of tests.
>>>
>>> If there's some more or less standard way to address this I'd like to
>>> use that.
>>>
>>> /M
>>>
>>> --
>>> Magnus Therning              OpenPGP: 0x927912051716CE39
>>> email: magnus at therning.org   jabber: magnus at therning.org
>>> twitter: magthe               http://therning.org/magnus
>>>
>>> There's a big difference between making something easy to use and
>>> making it productive.
>>>        -- Adam Bosworth
>>>
>>>
>
> --
> Magnus Therning              OpenPGP: 0x927912051716CE39
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
>
> C++ is history repeated as tragedy. Java is history repeated as farce.
>       -- Scott McKay



More information about the CMake mailing list