set(CMAKE_CXX_STANDARD_REQUIRED ON)
This makes C++14 a requirement and prevents a "decay" to C++98 when the
compiler does not support C++14. RetDec and related tools require C++14 to
build, so the sooner the build fails the better.
set(CMAKE_CXX_EXTENSIONS OFF)
This disables the use of compiler-specific extensions. For example, by default,
CMake passes -std=gnu++14 to GCC on Linux. We want to build with -std=c++14 to
prevent use of non-portable compiler extensions, which is what the disabling of
this option does.
Linux/macOS: Enable warnings.
MSVC: For the moment, suppress all warnings when building with MSVC on Windows
because there are too many warnings that clutter the build output (#106). We
should definitely investigate the warnings, fix them, and then enable their
emission (e.g. with replacing /W0 with /W3).
In timestampToDate(), std::localtime() is called to convert the timestamp into
a date and time. Since std::localtime() is timezone-aware, we have to force a
specific timezone (UTC) in tests to make them timezone-agnostic. After each
test is run, we set the timezone back to its original value.
At the moment, we (unofficially) support also macOS, so differentiate only
between Windows and UNIX by defining the following two symbolic constants:
* OS_WINDOWS
* OS_UNIX
The new version can be built faster:
Original version:
real 0m11.028s
user 0m10.241s
sys 0m0.782s
Latest version:
real 0m5.178s
user 0m4.753s
sys 0m0.425s
As a related change, this commit adds missing dependencies between the
gtest_main, gmock, and gmock_main libraries. In the original version,
libgmock.a contained libgtest.a and libgmock_main.a contained libgmock.a. Now,
libgmock.a is without libgtest.a and libgmock_main.a is without libgmock.a.
Thus, if one wants to link gmock_main, he or she has to also link gmock and
gtest. This has been reflected in the dependencies.
Based on #21:
The scripts will also fail on Cygwin, due to Cygwin's virtual paths (c:
becomes /cygdrive/c/, and so on), which are not transformed by readlink.
Instead, one needs to use cygpath, to get the real windows path. So I've
added get_realpath to retdec-utils.sh, to check if the scripts are running
on Cygwin, and if they do, to use cygpath -ma (-a = absolute path, and -m =
mixed, i.e., forward slashes rather than backward slashes). Otherwise it
just uses readlink.
Based on #21:
Right now, the scripts used by retdec (e.g. retdec-decompiler.sh) will fail
if they're symlinked, i.e., retdec-decompiler.sh symlinked to
~/bin/retdec-decompiler, because both ${BASH_SOURCE} and $0 will always
point at the symlinked path, rather than the original, so $SCRIPT_DIR would
become invalid.
This is easy enough to fix, by doing dirname "$(readlink -e "$0")", rather
than the pretty ancient style of cding to dirname "$0" (pretty sure this
has been out of date since the inception of Linux itself ...).