cmake release builds don't disable assertions (NDEBUG)
freebsd at grem.de
Mon Feb 6 22:53:34 UTC 2017
On Mon, 06 Feb 2017 22:27:01 +0100
Raphael Kubo da Costa <rakuco at FreeBSD.org> wrote:
> Michael Gmelin <freebsd at grem.de> writes:
> > While debugging an unexpected assertion problem, I noticed that
> > ports using cmake don't set -NDEBUG, even when building in Release
> > mode.
> > Is this intentional?
> Is it the software you're porting that checks for DEBUG or some
> library it uses?
> CMake code should check for CMAKE_BUILD_TYPE and adjust the compiler
> flags accordingly (if at all); so if the software itself is checking
> for DEBUG but not passing (or omitting it) I'd say the bug is there,
> not in Mk/Uses/cmake.mk.
Well, cmake.mk overwrites the meaning of CMAKE_CXX_FLAGS_RELEASE with
the content of CXXFLAGS, are you sure that doing this is the right
thing to do?
I sampled a couple of smaller projects that use cmake in the ports tree
and it seems like many projects don't do anything special to prevent
assertions or debug code when built using CMAKE_BUILD_TYPE=Release,
which makes me think that the authors depend on the default behaviour
of cmake, which includes "-NDEBUG" in Release mode (AFAIK default flags
for build types are also compiler and platform dependent, so it kind of
makes sense to rely on the defaults, doesn't it?).
More information about the freebsd-ports