Hello, I generally use scons for building Wesnoth, but from time to time I come across situations for which cmake is more flexible, such as making alternate builds besides an optimized/debug pair with gcc.
So I have found two problems with the cmake recipe, which I'm unsure are
caused by my front-end (ccmake) or cmake version (2.8.12.1). One of these is
actually bug previously reported to the tracker.
1) cmake by default passes -DNDEBUG to the compiler when the build type is not
Debug, by including the flag in the CMAKE_CXX_FLAGS_MINSIZEREL,
CMAKE_CXX_FLAGS_RELEASE, and CMAKE_CXX_FLAGS_RELWITHDEBINFO options unless
asked to do otherwise. Defining NDEBUG results in assert() statements not
being compiled in, which has various side-effects in our code base starting
with bug #21030; the fact that we use assert() as a bug detection mechanism
pretty much *everywhere* means that players compiling with cmake a non-Debug
configuration will never hit assertion failures even in the event of a bug,
which may cause code to continue running even when it is actually broken.
If there is a way to exclude -DNDEBUG from the default settings, that would
probably be advisable. As an alternative, we could have NDEBUG undefined by
some global header that will be always included before cassert/assert.h.
2) While trying to change the CMAKE_CXX_FLAGS option in ccmake (the ncurses
frontend) with clang set as my compiler, every time I hit 'c' to run the
configuration again before generating Makefiles this option was reset to the
(Wesnoth-mandated, I presume) default of "-std=c++98 -W -Wall -Werror -Wno-
strict-aliasing -Wno-unused-local-typedefs -Wno-literal-suffix", making it
harder to experiment with the compiler flags for all builds. For most other
software using cmake I've compiled, the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS
option default to empty and they aren't reset whenever the cmake configuration
step runs.
In fact, I just tried directly using cmake on the command line like this:
$ cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_FLAGS=-march=native ../..
Then I took a look at the resulting CMakeCache.txt:
CMAKE_CXX_FLAGS:STRING=' -std=c++98 -W -Wall -Werror -Wno-strict-aliasing -
Qunused-arguments -Wno-mismatched-tags -Wno-null-conversion -Wno-overloaded-
virtual '
The -march=native switch was nowhere to be found.
Aren't CMAKE_CXX_COMPILER and CMAKE_CXX_FLAGS normally intended to be set by
the user as necessary? Hard-coding them only because I want to use clang
doesn't seem good form to me. Then again, I know nothing about cmake
conventions.
--
Regards
Ignacio Riquelme Morelle <shadowm>
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Wesnoth-dev mailing list [email protected] https://mail.gna.org/listinfo/wesnoth-dev
