Commit graph

103 commits

Author SHA1 Message Date
Daniel Gibson
94b4289527 CMake: Detect all variations of the clang compiler (hopefully)
According to
https://cmake.org/cmake/help/v3.26/variable/CMAKE_LANG_COMPILER_ID.html
there's at least "Clang" (plain LLVM clang), "AppleClang", "ARMClang",
"FujitsuClang", "XLClang" and "IBMClang" (both of which are variations
of the clang/llvm-based IBM XL compiler).

This should detect all of them (I hope they all behave close enough
to normal clang to work..)

There's also "IntelLLVM", but I have no idea if that's based on Clang
or does its own thing based on LLVM.. I also doubt dhewm3 will ever
be built with any other clang-derivate than "Clang" and "AppleClang" :-p

fixes #510
2024-03-19 01:53:53 +01:00
Daniel Gibson
34db181b40 Fix build with Visual Studio's builtin CMake support
For some reason MSVCs integrated CMake doesn't set CMAKE_GENERATOR_PLATFORM
so my CPU arch detection magic in CMakeLists.txt didn't work in that case..
Now (when using MSVC) the CPU architecture (D3_ARCH) is set in
neo/sys/platform.h instead (NOTE: the sys/platform.h part was merged
 in "Sync sys/platform.h, incl. Workaround for MCST-LCC compiler").
2024-03-19 01:38:57 +01:00
Daniel Gibson
b3c1ddd5d7 CMake: Add GCC/clang-specific options: ASAN, FORCE_COLORED_OUTPUT
-DASAN=ON   enables the Address Sanitizer (ASan), if supported
-DFORCE_COLORED_OUTPUT=ON  forces GCC or Clang to use colors in their
                           messages, useful when building with ninja

Both options default to OFF (though when building with make in a
suitable terminal, GCC and clang automatically use colors)

(no UBSAN, that requires hardlinking the game with the executable,
 which is not possible in the SDK..)
2024-03-19 01:26:35 +01:00
Daniel Gibson
3170652e11 CMake: Fix D3_ARCH, theoretically support Windows on ARM
working around CMake (specifically CMAKE_SYSTEM_PROCESSOR) being useless
and related commits ported from dhewm3, up to including
"CMake: Fix typo in MSVC-specific CPU detection for x64"
2022-05-17 07:17:46 +02:00
Daniel Gibson
14e6d366bf Port CMake changes from dhewm3 (up to "Fix runtime assert on PPC OS X")
- (Hopefully) better workaround for miscompiled cross products, #147
  (-ffp-contract=off)
- GCC/Clang: Remove -fno-unsafe-math-optimizations
  (redundant as long as -ffast-math isn't used)
- Fix runtime assert on PPC OS X
  (-mone-byte-bool)
2022-05-17 07:17:46 +02:00
Daniel Gibson
2e2ca7c5d5 MSVC: Treat pointer truncation warnings as errors, adjust idCVar for that
All pointer<->integer conversion truncation warnings I'm aware of are
now enabled for MSVC, to hopefully finally get that tool code 64bit-clean.

I had to adjust the idCVar code for this - it should've been safe enough
(highly unlikely that a valid pointer is exactly 0xFFFFFFFF on 64bit),
but triggered those warnings - now it should behave the same as before
but the warnings (which are now errors) are silenced.
2022-05-17 07:17:46 +02:00
Daniel Gibson
3b7cc39f28 Fix Win32/VS build on Win64 hosts
Turns out that ${CMAKE_SYSTEM_PROCESSOR} is broken on Windows
(both for Visual Studio and for 32bit MinGW/msys shells which for some
 reason seem to output x86_64 in uname -a)
2021-02-22 04:30:03 +01:00
Daniel Gibson
372ae8bb73 Enable building on Apple Silicon
(based on the commit from Petter Uvesten in the main dhewm3 repo)
2021-01-18 00:51:48 +01:00
Daniel Gibson
2a649bd074 Suppress GCC8+ warnings about memcpy()/memset() on classes
.. with "no trivial copy-assignment".
All the cases I checked were harmless; as long as a class has no vptr
or owns memory (or other resources) that need to be handled properly
in the destructor, memcpy() and memset() aren't too dangerous.
2020-09-15 00:53:23 +02:00
Daniel Gibson
76529ab38f Port CMake-changes that were added to dhewm3 since the SDK was created
Make source files listing in VS usable (incl. fallback for old CMake)
CMake: Fix build in path with spaces
2020-09-06 04:09:12 +02:00
Daniel Gibson
00472d7286 CMake 2.8 is sufficient
this way I can build it in my wheezy chroot for release binaries
without upgrading cmake there.
2018-12-15 05:35:12 +01:00
Daniel Gibson
fb0708fad4 change engine version to "dhewm3 SDK 1.5.x"; no -ffast-math
it's only shown in the g_version CVar, but if we have this constant
in the SDK make it show something sensible.. and this SDK code should
be compatible with all dhewm 1.5.x releases (=> dhewm3 version will
be bumped to 1.6.x if game API compatibility is broken)

Also disabled (GCC/Clang-specific) -ffast-math - even with
 -fno-unsafe-math-optimizations I don't trust it.
2018-11-12 00:21:13 +01:00
Daniel Gibson
02417dcecf It builds with VS 2017 now 2018-09-02 01:25:23 +02:00
Daniel Gibson
4dd278d6fb Make game dll names and compiler defines for mods configurable
so mod authors can tell cmake to call it mymod.dll instead of base.dll
or d3xp.dll

and the compiler defines are also easily configurable now

I also added a comment to EndLevel.cpp, which was released with the GPL
source (and in d3xp/ it already existed in the SDK), but has not been
used to build the dlls.
2018-08-26 04:47:00 +02:00
Daniel Gibson
53db277bae Make it build as SDK
I created this repo from the original dhewm3 repo, but I used
git filter-branch to kill all the files that are not needed to just
build base.dll and d3xp.dll (or .so or .dylib or whatever).
So this is basically just the files the original Doom3 SDK had, but
taken from dhewm3 instead (and thus GPL licensed and patched for
64bit-support etc) + some dhewm3 specific stuff + CMakeLists.txt
to build them.

The git filter-branch details:

filter-branch -f --prune-empty --tree-filter /tmp/killkill.sh @

## /tmp/killkill.sh:

#!/bin/sh

find . -exec /tmp/removeothers.sh {} \;

exit 0

## /tmp/removeothers.sh:

#!/bin/bash

FNAME="$1"

if [[ $FNAME == \./\.git* ]] || [[ $FNAME == \./d3xp/* ]] || [[ $FNAME == \./game/* ]]
then
	#echo "ignoring $FNAME"
	exit 0
fi

if ! grep -Fxq "$FNAME" /tmp/d3sdklist.txt
then
	#echo "REMOVING $FNAME"
	rm -rf "$FNAME"
fi

exit 0

## /tmp/d3sdklist.txt was is just a textfile with one path per line with
   all the files (and directories!) I wanted to keep, like:

.
..
./sys/platform.h
./framework/Game.h
./config.h.in
./CMakeLists.txt
## ... and all the relevant files from the SDK
2018-08-26 01:43:10 +02:00
Yamagi Burmeister
aa40145157 Lower release build optimizations from -O3 to -O2.
In the last few weeks I've played again through the game and kept an eye
on small oddities. And there're a lot of them. For example some GUIs and
videos getting stuck after the first frame (issue #192) or being unable
to protect the guy with the lamp in Alpha Labs 3. Some digging proved
that most - if not all - of these problems are caused by the compilers
optimization level. When build with -O2 both g++ 8.1 and clang 6.0.0 are
producing working code. g++ 8.1 with -O3 has some small, hard to notice
oddities, clang 6.0.0 with -O3 shows a lot of them. Since there's not
measurable difference between -O3 and -O2 just go down to the later:

x doom_o3.txt
+ doom_o2.txt
+----------------------------------------------------------------------+
|                                                               +      |
|                                      +                        *      |
|x                                     *           x            *      |
|                 |_____________________|___A______M__A_________M___|_||
+----------------------------------------------------------------------+

    N        Min           Max        Median           Avg        Stddev
x   5        173           178           177         176.4     2.0736441
+   5        176           178           178         177.2     1.0954451
2018-08-20 01:46:40 +02:00
Kalamatee
b86dac5719 use the correct extension for x86 2018-08-20 01:46:40 +02:00
Kalamatee
2fb870b13f import AROS changes 2018-08-20 01:46:39 +02:00
David Carlier
45d826d31c make it compilable under openbsd 2018-08-20 01:46:39 +02:00
svdijk
c95cce323a Win32: Add an icon to the dhewm3 executable 2018-08-20 01:46:38 +02:00
Daniel Gibson
ff09de0aaa Prepare for 1.4.0 release, make SDL2 default, update README
The version will be 1.4.0 because it's not compatible with
Doom3 1.3.1 mod DLLs.

(Note that this commit doesn't mean 1.4.0 is done, I might do some
 minor changes before tagging the Release!)
2018-08-20 01:46:38 +02:00
Daniel Gibson
7e39919bd5 Remove jpeg_memory_src hack that worked around old libjpeg versions
Because Debian Squeeze's libjpeg6 didn't have jpeg_mem_src(), we added
jpeg_memory_src() to provide the functionality.
This shouldn't be needed anymore and without it we can drop libjpeg code
from our repo.

Fixes #110
2018-08-20 01:46:38 +02:00
Daniel Gibson
6aea4b59fb Use updated minizip version for unzip
The implementation is now in framework/minizip/*
instead of framework/Unzip.cpp

This was version 0.15beta, now we use 1.1 from
zlib 1.2.7/contrib/minizip

Some code had to be adjusted for this, but it got
cleaner on the way
2018-08-20 01:46:38 +02:00
Kevin Doyon
44004d8bbc Fix SDL2 compile-errors, made it work on Win64
.. when compiled with MSVC2012
2018-08-20 01:46:37 +02:00
Daniel Gibson
1ea1a299fb Silence "unknown pragma" warning in MSVC
Appeared quite often due to the #pragma GCC diagnostic ...
stuff in Str.h and List.h
2018-08-20 01:46:37 +02:00
Daniel Gibson
a1f72df989 Win32: Statically link libgcc and libstdc++
Else one needs to copy those files from mingw32.. and I see no reason
not to statically link them.
2018-08-20 01:46:37 +02:00
Daniel Gibson
4fc06760aa Fix dedicated server for Windows
* the OpenAL function definitions mustn't include __declspec(dllimport)
  => fixed by pretending to compile OpenAL statically
* glimp.cpp shouldn't be used in dedicated-only mode (as it was already
  the case on Linux and OSX)
  => No special handling for ID_DEDICATED needed in glimp.cpp, as it's not
   used anyway
* add APIENTRY to every gl function in stub_gl.cpp for compatibility
  with windows headers and MSVC
* remove GL/gl.h #include from win_local.h as it's not needed
* in qgl.h, when building dedicated server for windows, redefine WINGDIAPI
  to nothing for SDL_opengl.h #include to get rid off __declspec(dllimport)
  by using #pragma push_macro and pop_macro, because our stub is no dll.

Fixes https://github.com/dhewm/dhewm3/issues/39
2018-08-20 01:46:37 +02:00
dhewg
a5f5270f8e Add SDL2 support for the build system
Defaults to off, tree doesn't yet compile with SDL2.
2018-08-20 01:46:36 +02:00
dhewg
68c38d452b cmake: set SDL_BUILDING_LIBRARY for win32 and osx
While that's a lie it makes FindSDL skip SDLmain, which we have
in tree and compile ourselves.
2018-08-20 01:46:36 +02:00
dhewg
2f42541154 Don't link against OpenGL
Dynamically load all symbols at runtime.
This in in preparation for SDL2/OpenGLES.
2018-08-20 01:46:36 +02:00
dhewg
4e90fff060 Remove the deprecated arb renderer 2018-08-20 01:46:36 +02:00
dhewg
17d609564a Remove the deprecated nv20 renderer 2018-08-20 01:46:36 +02:00
dhewg
ff99aa9477 Remove the deprecated nv10 renderer 2018-08-20 01:46:36 +02:00
dhewg
3d27d4776c Remove the ATI fragment shader emulation
This was only used by the r200 renderer on OSX.
2018-08-20 01:46:36 +02:00
dhewg
4859d1837b Remove the deprecated r200 renderer 2018-08-20 01:46:36 +02:00
dhewg
755bffe601 Delete util_stub.cpp
Unused.
2018-08-20 01:46:36 +02:00
dhewg
17b42bb46e cmake: indent whitespace fixes 2018-08-20 01:46:36 +02:00
dhewg
ffbbcaf726 cmake: Whitespace fixes for consistency 2018-08-20 01:46:36 +02:00
dhewg
9d9ba03b90 cmake: default to build d3xp 2018-08-20 01:46:36 +02:00
dhewg
105aec84e1 cmake: Remove fugly hack to compile 32bit binaries
This doesn't work on multiarch systems. A proper cmake toolchain file
has to be used instead.
2018-08-20 01:46:36 +02:00
dhewg
28ff955897 cmake: Fix error when curl is not found
Set the library name to an empty string to prevent this error:

CMake Error: The following variables are used in this project, but they
are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the
CMake files:
CURL_LIBRARY (ADVANCED)
2018-08-20 01:46:36 +02:00
dhewg
a3456b9004 cmake: Use GNUInstallDirs
Provides configure style overwritable path settings.
Include a fallback for cmake versions without GNUInstallDirs.
2018-08-20 01:46:35 +02:00
dhewg
95c34a8a00 Get rid of the signal handler
SDL covers this via e.g. SDL_QUIT event on ctrl+c.
2018-08-20 01:46:35 +02:00
dhewg
f6b6f1df97 Correct the cpu type for 64bit msvc 2018-08-20 01:46:35 +02:00
dhewg
f4f8319316 Disable warning 4267 for msvc
Spams the console due to 32bit data types on 64bit.
2018-08-20 01:46:35 +02:00
dhewg
d75c2654c0 Get rid of empty sys/linux/dedicated.cpp 2018-08-20 01:46:35 +02:00
dhewg
5db94cb6a0 Get rid of win_cpu.cpp
All unused now.
2018-08-20 01:46:35 +02:00
dhewg
04bea1b10f Use system zlib 2018-08-20 01:46:35 +02:00
dhewg
d250bf9262 Initial make install target for *nix
cmake fails it, so *nix only.
2018-08-20 01:46:34 +02:00
dhewg
ed099aa128 Remove all gamepak FileSystem<->Async[Client|Server] code 2018-08-20 01:46:34 +02:00