2022-12-29 00:40:20 +00:00
cmake_minimum_required(VERSION 2.6...3.22 FATAL_ERROR)
2012-01-14 17:38:44 +00:00
project(dhewm3)
2011-12-12 18:15:16 +00:00
# TODO
2012-07-03 20:06:40 +00:00
# osx: place game .dylib's in the bundle (next to the binary)
2011-12-12 18:15:16 +00:00
# osx: -weak_framework ?
# maybe add these as options:
# TARGET_MONO
# SETUP
# SDK -D_D3SDK
# don't add these as options, but document them?
# IDNET_HOST -DIDNET_HOST=\\"%s\\"' % IDNET_HOST
# DEBUG_MEMORY -DID_DEBUG_MEMORY', '-DID_REDIRECT_NEWDELETE
# LIBC_MALLOC -DUSE_LIBC_MALLOC=0
# ID_NOLANADDRESS -DID_NOLANADDRESS
2015-10-03 07:17:30 +00:00
# fallback for cmake versions without add_compile_options
if(NOT COMMAND add_compile_options)
function(add_compile_options)
foreach(arg ${ARGN})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${arg}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}" PARENT_SCOPE)
endforeach()
endfunction()
endif()
2018-12-15 04:49:19 +00:00
option(LINUX_RELEASE_BINS "Set RPATH to \$ORIGIN/libs/ for Linux binary releases" OFF)
2011-12-12 18:15:16 +00:00
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sys/cmake")
2018-12-15 04:49:19 +00:00
if(LINUX_RELEASE_BINS)
message(STATUS "Setting RPATH to \$ORIGIN/libs/ so you can put dependencies in there")
2022-05-16 03:43:47 +00:00
set(CMAKE_SKIP_RPATH OFF CACHE BOOL "Skip RPATH" FORCE)
2018-12-15 04:49:19 +00:00
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/libs")
set(ldflags "${ldflags} -Wl,-z,origin") # not sure this is even needed, but shouldn't hurt
else()
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
endif()
2011-12-12 18:15:16 +00:00
2015-06-20 19:30:46 +00:00
set(DHEWM3BINARY "dhewm3")
2011-12-22 10:53:33 +00:00
include(CheckCXXCompilerFlag)
2012-07-09 20:52:05 +00:00
include(GNUInstallDirs OPTIONAL RESULT_VARIABLE GNUINSTALLDIRS)
2011-12-12 18:15:16 +00:00
option(CORE "Build the core" ON)
2012-07-03 17:26:41 +00:00
option(BASE "Build the base game code" ON)
2012-07-09 21:12:07 +00:00
option(D3XP "Build the d3xp game code" ON)
2019-01-07 04:19:20 +00:00
if(MSVC)
2021-05-06 00:07:41 +00:00
option(TOOLS "Build the tools game code (Visual Studio+SDL2 only)" OFF)
2019-01-07 01:42:00 +00:00
endif()
2011-12-12 18:15:16 +00:00
option(DEDICATED "Build the dedicated server" OFF)
option(ONATIVE "Optimize for the host CPU" OFF)
2015-09-27 01:08:30 +00:00
option(SDL2 "Use SDL2 instead of SDL1.2" ON)
2020-07-12 23:33:40 +00:00
option(REPRODUCIBLE_BUILD "Replace __DATE__ and __TIME__ by hardcoded values for reproducible builds" OFF)
2011-12-12 18:15:16 +00:00
2021-06-22 20:38:45 +00:00
option(HARDLINK_GAME "Compile gamecode into executable (no game DLLs)" OFF)
2022-12-29 00:40:20 +00:00
if(NOT MSVC) # GCC/clang or compatible, hopefully
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF)
option(ASAN "Enable GCC/Clang Adress Sanitizer (ASan)" OFF) # TODO: MSVC might also support this, somehow?
option(UBSAN "Enable GCC/Clang Undefined Behavior Sanitizer (UBSan), implies HARDLINK_GAME" OFF)
if(UBSAN AND NOT HARDLINK_GAME)
message(STATUS "UBSAN requires linking the gamecode into the executable, will enable HARDLINK_GAME")
set(HARDLINK_GAME ON)
endif()
endif()
2012-07-09 21:31:35 +00:00
if(NOT CMAKE_SYSTEM_PROCESSOR)
2011-12-12 18:15:16 +00:00
message(FATAL_ERROR "No target CPU architecture set")
endif()
2012-07-09 21:31:35 +00:00
if(NOT CMAKE_SYSTEM_NAME)
2011-12-12 18:15:16 +00:00
message(FATAL_ERROR "No target OS set")
endif()
# target cpu
set(cpu ${CMAKE_SYSTEM_PROCESSOR})
2021-09-13 07:06:47 +00:00
# Originally, ${CMAKE_SYSTEM_PROCESSOR} was supposed to contain the *target* CPU, according to CMake's documentation.
# As far as I can tell this has always been broken (always returns host CPU) at least on Windows
# (see e.g. https://cmake.org/pipermail/cmake-developers/2014-September/011405.html) and wasn't reliable on
# other systems either, for example on Linux with 32bit userland but 64bit kernel it returned the kernel CPU type
# (e.g. x86_64 instead of i686). Instead of fixing this, CMake eventually updated their documentation in 3.20,
# now it's officially the same as CMAKE_HOST_SYSTEM_PROCESSOR except when cross-compiling (where it's explicitly set)
# So we gotta figure out the actual target CPU type ourselves.. (why am I sticking to this garbage buildsystem?)
if(NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR))
# special case: cross-compiling, here CMAKE_SYSTEM_PROCESSOR should be correct, hopefully
# (just leave cpu at ${CMAKE_SYSTEM_PROCESSOR})
elseif(MSVC)
2022-12-30 03:45:46 +00:00
# because all this wasn't ugly enough, it turned out that, unlike standalone CMake, Visual Studio's
# integrated CMake doesn't set CMAKE_GENERATOR_PLATFORM, so I gave up on guessing the CPU arch here
# and moved the CPU detection to MSVC-specific code in neo/sys/platform.h
2021-09-13 07:06:47 +00:00
else() # not MSVC and not cross-compiling, assume GCC or clang (-compatible), seems to work for MinGW as well
execute_process(COMMAND ${CMAKE_C_COMPILER} "-dumpmachine"
RESULT_VARIABLE cc_dumpmachine_res
OUTPUT_VARIABLE cc_dumpmachine_out)
if(cc_dumpmachine_res EQUAL 0)
2021-10-12 17:59:40 +00:00
string(STRIP ${cc_dumpmachine_out} cc_dumpmachine_out) # get rid of trailing newline
message(STATUS "`${CMAKE_C_COMPILER} -dumpmachine` says: \"${cc_dumpmachine_out}\"")
2021-09-13 07:06:47 +00:00
# gcc -dumpmachine and clang -dumpmachine seem to print something like "x86_64-linux-gnu" (gcc)
# or "x64_64-pc-linux-gnu" (clang) or "i686-w64-mingw32" (32bit mingw-w64) i.e. starting with the CPU,
# then "-" and then OS or whatever - so use everything up to first "-"
string(REGEX MATCH "^[^-]+" cpu ${cc_dumpmachine_out})
2021-10-12 17:59:40 +00:00
message(STATUS " => CPU architecture extracted from that: \"${cpu}\"")
2021-02-22 01:48:39 +00:00
else()
2021-09-13 07:06:47 +00:00
message(WARNING "${CMAKE_C_COMPILER} -dumpmachine failed with error (code) ${cc_dumpmachine_res}")
message(WARNING "will use the (sometimes incorrect) CMAKE_SYSTEM_PROCESSOR (${cpu}) to determine D3_ARCH")
2021-02-22 01:48:39 +00:00
endif()
2021-02-07 05:10:19 +00:00
endif()
2021-09-13 07:06:47 +00:00
if(cpu STREQUAL "powerpc")
set(cpu "ppc")
2022-01-16 16:55:11 +00:00
elseif(cpu STREQUAL "aarch64")
# "arm64" is more obvious, and some operating systems (like macOS) use it instead of "aarch64"
set(cpu "arm64")
2021-09-13 07:06:47 +00:00
elseif(cpu MATCHES "i.86")
set(cpu "x86")
elseif(cpu MATCHES "[aA][mM][dD]64" OR cpu MATCHES "[xX]64")
set(cpu "x86_64")
2022-01-16 16:55:11 +00:00
elseif(cpu MATCHES "[aA][rR][mM].*") # some kind of arm..
# On 32bit Raspbian gcc -dumpmachine returns sth starting with "arm-",
# while clang -dumpmachine says "arm6k-..." - try to unify that to "arm"
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # sizeof(void*) == 8 => must be arm64
set(cpu "arm64")
else() # should be 32bit arm then (probably "armv7l" "armv6k" or sth like that)
set(cpu "arm")
endif()
2021-09-13 07:06:47 +00:00
endif()
2011-12-12 18:15:16 +00:00
# target os
2012-07-09 21:31:35 +00:00
if(APPLE)
2011-12-12 18:15:16 +00:00
set(os "macosx")
else()
string(TOLOWER "${CMAKE_SYSTEM_NAME}" os)
endif()
2022-12-30 03:45:46 +00:00
add_definitions(-DD3_OSTYPE="${os}" -DD3_SIZEOFPTR=${CMAKE_SIZEOF_VOID_P})
2021-02-07 05:10:19 +00:00
2022-12-30 03:45:46 +00:00
if(MSVC)
# for MSVC D3_ARCH is set in code (in neo/sys/platform.h)
message(STATUS "Setting -DD3_SIZEOFPTR=${CMAKE_SIZEOF_VOID_P} -DD3_OSTYPE=\"${os}\" - NOT setting D3_ARCH, because we're targeting MSVC (VisualC++)")
# make sure ${cpu} isn't (cant't be) used by CMake when building with MSVC
unset(cpu)
else()
add_definitions(-DD3_ARCH="${cpu}")
message(STATUS "Setting -DD3_ARCH=\"${cpu}\" -DD3_SIZEOFPTR=${CMAKE_SIZEOF_VOID_P} -DD3_OSTYPE=\"${os}\" ")
2021-02-22 01:48:39 +00:00
2022-12-30 03:45:46 +00:00
if(cpu MATCHES ".*64.*" AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
# tough luck if some CPU architecture has "64" in its name but uses 32bit pointers
message(SEND_ERROR "CMake thinks sizeof(void*) == 4, but the target CPU ${cpu} looks like a 64bit CPU!")
message(FATAL_ERROR "If you're building in a 32bit chroot on a 64bit host, switch to it with 'linux32 chroot' or at least call cmake with linux32 (or your OSs equivalent)!")
endif()
2021-02-22 01:48:39 +00:00
endif()
2011-12-12 18:15:16 +00:00
# build type
2012-07-09 21:31:35 +00:00
if(NOT CMAKE_BUILD_TYPE)
2011-12-12 18:15:16 +00:00
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
2012-01-14 17:38:44 +00:00
# precompiled libraries from the dhewm3-libs repo
2012-07-09 21:31:35 +00:00
if(DHEWM3LIBS)
if(CMAKE_CROSSCOMPILING)
2012-01-14 17:38:44 +00:00
set(CMAKE_FIND_ROOT_PATH ${DHEWM3LIBS})
2012-01-07 14:37:52 +00:00
else()
2012-01-14 17:38:44 +00:00
set(ENV{CMAKE_PREFIX_PATH} ${DHEWM3LIBS})
2012-01-07 14:37:52 +00:00
endif()
# these are too stupid, give them a hint
2012-01-14 17:38:44 +00:00
set(ENV{OPENALDIR} ${DHEWM3LIBS})
set(ENV{SDLDIR} ${DHEWM3LIBS})
2012-07-19 18:05:38 +00:00
set(ENV{SDL2DIR} ${DHEWM3LIBS})
2012-01-07 14:37:52 +00:00
endif()
2019-04-07 22:59:31 +00:00
if(CMAKE_MAJOR_VERSION LESS 3 OR ( CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_VERSION LESS 8 ))
# cmake < 3.8 doesn't support source_group(TREE ...) so replace it with a dummy
# (it's only cosmetical anyway, to make source files show up properly in Visual Studio)
function(source_group)
endfunction()
message(STATUS "Using CMake < 3.8, doesn't support source_group(TREE ...), replacing it with a dummy")
message(STATUS " (this is only relevants for IDEs, doesn't matter for just compiling dhewm3)")
#else()
# message(STATUS "Using CMake >= 3.8, supports source_group(TREE ...)")
endif()
2011-12-12 18:15:16 +00:00
# libs
2012-07-04 15:46:41 +00:00
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
2011-12-12 18:15:16 +00:00
find_package(OpenAL REQUIRED)
include_directories(${OPENAL_INCLUDE_DIR})
2012-07-19 18:05:38 +00:00
if (SDL2)
# skip SDL2main
if(APPLE OR WIN32)
set(SDL2_BUILDING_LIBRARY TRUE)
endif()
find_package(SDL2 REQUIRED)
2021-01-24 03:10:18 +00:00
include_directories(${SDL2_INCLUDE_DIR})
set(SDLx_LIBRARY ${SDL2_LIBRARY})
2012-07-19 18:05:38 +00:00
else()
2012-07-20 14:24:20 +00:00
# skip SDLmain
2012-07-19 18:05:38 +00:00
if(APPLE OR WIN32)
set(SDL_BUILDING_LIBRARY TRUE)
endif()
find_package(SDL REQUIRED)
include_directories(${SDL_INCLUDE_DIR})
set(SDLx_LIBRARY ${SDL_LIBRARY})
2012-07-20 14:24:20 +00:00
endif()
2011-12-20 15:12:17 +00:00
2020-07-12 23:33:40 +00:00
if(REPRODUCIBLE_BUILD)
# don't use __DATE__ and __TIME__ macros so builds are reproducible
add_definitions(-DID_REPRODUCIBLE_BUILD)
endif()
2012-01-14 13:24:28 +00:00
find_package(CURL QUIET)
2012-07-09 21:31:35 +00:00
if(CURL_FOUND)
2012-01-14 13:24:28 +00:00
set(ID_ENABLE_CURL ON)
2011-12-12 18:15:16 +00:00
include_directories(${CURL_INCLUDE_DIR})
2021-07-17 16:24:46 +00:00
message(STATUS "libcurl found and enabled")
2011-12-12 18:15:16 +00:00
else()
2021-06-02 23:38:17 +00:00
message(WARNING "libcurl not found, server downloads won't be available (apart from that dhewm3 will work)")
2012-01-14 13:24:28 +00:00
set(ID_ENABLE_CURL OFF)
2012-07-09 20:57:13 +00:00
set(CURL_LIBRARY "")
2011-12-12 18:15:16 +00:00
endif()
2019-01-07 01:42:00 +00:00
if(MSVC)
# This is required for tools on windows.
find_package(MFC)
2019-01-07 04:19:20 +00:00
if(TOOLS AND NOT MFC_FOUND)
message(SEND_ERROR "MFC ('Microsoft Foundation Classes for C++') couldn't be found, but is needed for TOOLS!")
message(FATAL_ERROR "If you're using VS2013, you'll also need the 'Multibyte MFC Library for Visual Studio 2013': https://www.microsoft.com/en-us/download/details.aspx?id=40770 (VS2015 and 2017 include that in the default MFC package)")
endif()
2021-05-12 05:56:57 +00:00
else() # not MSVC
if(NOT WIN32)
# libbacktrace support - TODO: might work with MinGW? we don't have a crash handler for win32 though..
include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES backtrace)
check_c_source_compiles( "#include <backtrace.h>
int main() { backtrace_create_state(NULL, 0, NULL, NULL); return 0; }" HAVE_LIBBACKTRACE )
2021-06-02 23:38:17 +00:00
unset(CMAKE_REQUIRED_LIBRARIES)
2021-05-12 05:56:57 +00:00
if(HAVE_LIBBACKTRACE)
set(sys_libs ${sys_libs} backtrace)
add_definitions(-DD3_HAVE_LIBBACKTRACE)
message(STATUS "Using libbacktrace")
2021-06-02 23:38:17 +00:00
else()
message(WARNING "libbacktrace wasn't found. It's not required but recommended, because it provides useful backtraces if dhewm3 crashes")
2021-05-12 05:56:57 +00:00
endif()
endif() # NOT WIN32
endif() # not MSVC
2019-01-07 01:42:00 +00:00
2011-12-12 18:15:16 +00:00
# compiler specific flags
2012-07-09 21:31:35 +00:00
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
2015-10-03 07:17:30 +00:00
add_compile_options(-pipe)
add_compile_options(-Wall)
2011-12-12 18:15:16 +00:00
2012-07-09 21:31:35 +00:00
if(NOT CMAKE_CROSSCOMPILING AND ONATIVE)
2015-10-03 07:17:30 +00:00
add_compile_options(-march=native)
2012-07-09 21:31:35 +00:00
elseif(NOT APPLE AND cpu STREQUAL "x86")
2015-10-03 07:17:30 +00:00
add_compile_options(-march=pentium3)
2011-12-12 18:15:16 +00:00
endif()
2022-12-29 00:40:20 +00:00
if(FORCE_COLORED_OUTPUT)
if(CMAKE_COMPILER_IS_GNUCC)
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()
2018-11-05 03:16:08 +00:00
set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -D_DEBUG -O0")
2011-12-15 16:48:59 +00:00
set(CMAKE_C_FLAGS_DEBUGALL "-g -ggdb -D_DEBUG")
2012-01-18 23:45:15 +00:00
set(CMAKE_C_FLAGS_PROFILE "-g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer")
2021-06-17 02:14:18 +00:00
set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-math-errno -fno-trapping-math -fomit-frame-pointer")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -ggdb -O2 -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-math-errno -fno-trapping-math -fomit-frame-pointer")
2011-12-21 23:08:10 +00:00
set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL})
2012-01-18 23:45:15 +00:00
set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
2011-12-12 18:15:16 +00:00
2015-10-03 07:17:30 +00:00
add_compile_options(-fno-strict-aliasing)
2021-05-31 19:37:31 +00:00
# dear idiot compilers, don't fuck up math code with useless FMA "optimizations"
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100839)
add_compile_options(-ffp-contract=off)
2021-06-22 20:38:45 +00:00
2022-12-29 00:40:20 +00:00
if(ASAN)
# if this doesn't work, ASan might not be available on your platform, don't set ASAN then..
add_compile_options(-fsanitize=address)
set(sys_libs ${sys_libs} -fsanitize=address)
endif()
if(UBSAN)
# if this doesn't work, UBSan might not be available on your platform, don't set UBSAN then..
add_compile_options(-fsanitize=undefined)
set(sys_libs ${sys_libs} -fsanitize=undefined)
endif()
2011-12-12 18:15:16 +00:00
2015-06-20 19:30:46 +00:00
if(NOT AROS)
CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility)
if(NOT cxx_has_fvisibility)
message(FATAL_ERROR "Compiler does not support -fvisibility")
endif()
add_compile_options(-fvisibility=hidden)
2011-12-12 18:15:16 +00:00
endif()
# TODO fix these warnings
2015-10-03 07:17:30 +00:00
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-switch)
add_compile_options(-Wno-format-security)
2011-12-12 18:15:16 +00:00
2011-12-22 10:53:33 +00:00
CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual)
2012-07-09 21:31:35 +00:00
if(cxx_has_Woverload_virtual)
2015-10-03 07:17:30 +00:00
add_compile_options(-Woverloaded-virtual)
2011-12-12 18:15:16 +00:00
endif()
2021-02-22 01:48:39 +00:00
# shut up about using memcpy() on classes, in the cases doom3 uses it it seems to be fine
CHECK_CXX_COMPILER_FLAG("-Wno-class-memaccess" cxx_has_Wno-class-memaccess)
if(cxx_has_Wno-class-memaccess)
add_compile_options(-Wno-class-memaccess)
endif()
2011-12-12 18:15:16 +00:00
2015-06-20 19:30:46 +00:00
if(AROS)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".aros-${cpu}")
add_definitions(-DIOAPI_NO_64)
elseif(APPLE)
2011-12-12 18:15:16 +00:00
add_definitions(-DMACOS_X=1)
2012-07-09 21:31:35 +00:00
if(cpu STREQUAL "x86_64")
2019-01-15 15:07:08 +00:00
add_compile_options(-arch x86_64 -mmacosx-version-min=10.9)
set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.9")
2021-02-07 05:10:19 +00:00
elseif(cpu STREQUAL "arm64")
2020-11-01 22:08:45 +00:00
add_compile_options(-arch arm64 -mmacosx-version-min=11.0)
set(ldflags "${ldflags} -arch arm64 -mmacosx-version-min=11.0")
2012-07-09 21:31:35 +00:00
elseif(cpu STREQUAL "x86")
2011-12-22 10:53:33 +00:00
CHECK_CXX_COMPILER_FLAG("-arch i386" cxx_has_arch_i386)
2012-07-09 21:31:35 +00:00
if(cxx_has_arch_i386)
2015-10-03 07:17:30 +00:00
add_compile_options(-arch i386)
2011-12-23 16:29:05 +00:00
set(ldflags "${ldflags} -arch i386")
2011-12-12 18:15:16 +00:00
endif()
2015-10-03 07:17:30 +00:00
add_compile_options(-mmacosx-version-min=10.4)
2011-12-23 16:29:05 +00:00
set(ldflags "${ldflags} -mmacosx-version-min=10.4")
2012-07-09 21:31:35 +00:00
elseif(cpu STREQUAL "ppc")
2011-12-22 10:53:33 +00:00
CHECK_CXX_COMPILER_FLAG("-arch ppc" cxx_has_arch_ppc)
2012-07-09 21:31:35 +00:00
if(cxx_has_arch_ppc)
2021-08-26 20:39:54 +00:00
add_compile_options(-arch ppc -mone-byte-bool)
set(ldflags "${ldflags} -arch ppc -mone-byte-bool")
2011-12-12 18:15:16 +00:00
endif()
2015-10-03 07:17:30 +00:00
add_compile_options(-mmacosx-version-min=10.4)
2011-12-23 16:29:05 +00:00
set(ldflags "${ldflags} -mmacosx-version-min=10.4")
2011-12-12 18:15:16 +00:00
else()
message(FATAL_ERROR "Unsupported CPU architecture for OSX")
endif()
2012-07-18 22:41:19 +00:00
set(sys_libs ${sys_libs} "-framework Carbon -framework Cocoa -framework IOKit")
2012-09-05 19:45:03 +00:00
elseif(WIN32)
set(ldflags "${ldflags} -static-libgcc -static-libstdc++")
2015-10-03 07:17:30 +00:00
elseif(os STREQUAL "linux")
set(sys_libs ${sys_libs} dl)
2019-01-13 17:26:04 +00:00
elseif(os STREQUAL "freebsd")
find_library(EXECINFO_LIBRARIES execinfo /usr/lib /usr/local/lib)
set(sys_libs ${sys_libs} ${EXECINFO_LIBRARIES})
2011-12-12 18:15:16 +00:00
endif()
2012-07-09 21:31:35 +00:00
elseif(MSVC)
2020-08-02 02:41:45 +00:00
add_compile_options(/MP) # parallel build (use all cores, or as many as configured in VS)
2019-01-07 04:19:20 +00:00
2021-05-10 01:17:26 +00:00
add_compile_options(/W3) # TODO: was /W4, caused trouble with VS2019 (and/or its integrated CMake? or only HarrieVG's setup?)
2019-01-07 04:19:20 +00:00
add_compile_options(/we4840) # treat as error when passing a class to a vararg-function (probably printf-like)
2021-05-08 03:54:42 +00:00
# treat several kinds of truncating int<->pointer conversions as errors (for more 64bit-safety)
add_compile_options(/we4306 /we4311 /we4312 /we4302)
2021-05-10 01:17:26 +00:00
# ignore the following warnings:
2015-10-03 07:17:30 +00:00
add_compile_options(/wd4100) # unreferenced formal parameter
add_compile_options(/wd4127) # conditional expression is constant
add_compile_options(/wd4244) # possible loss of data
add_compile_options(/wd4245) # signed/unsigned mismatch
add_compile_options(/wd4267) # possible loss of data
add_compile_options(/wd4714) # 'function' marked as __forceinline not inlined
add_compile_options(/wd4996) # 'function': was declared deprecated
add_compile_options(/wd4068) # unknown pragma
2018-11-10 19:21:52 +00:00
add_compile_options(/wd4458) # declaration of 'variable' hides class member
2013-04-19 18:40:34 +00:00
add_definitions(-D_ALLOW_KEYWORD_MACROS) # because of the "#define private public" and "#define protected public" in TypeInfo.cpp
2011-12-22 16:53:25 +00:00
set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd")
set(CMAKE_C_FLAGS_RELEASE "/Ox /Oy /MD")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ox /Oy /Zi /MD")
set(CMAKE_C_FLAGS_MINSIZEREL "/Ox /Oy /Os /MD")
2011-12-12 18:15:16 +00:00
else()
message(FATAL_ERROR "Unsupported compiler")
endif()
2011-12-21 23:08:10 +00:00
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
2018-11-11 22:19:30 +00:00
# disable assertions in release builds
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG ${CMAKE_C_FLAGS_MINSIZEREL}")
2011-12-21 23:08:10 +00:00
2011-12-13 22:35:10 +00:00
# mingw and msvc
2012-07-09 21:31:35 +00:00
if(WIN32)
2021-05-10 01:17:26 +00:00
add_definitions(-DWINVER=0x0501)
add_definitions(-D_WIN32_WINNT=0x0501)
2011-12-13 22:35:10 +00:00
set(sys_libs ${sys_libs}
winmm
iphlpapi
wsock32
2015-10-03 07:17:30 +00:00
ole32
2011-12-13 22:35:10 +00:00
)
endif()
2012-07-09 20:52:05 +00:00
# fallback for cmake versions without GNUInstallDirs
if(GNUINSTALLDIRS MATCHES "NOTFOUND")
set(CMAKE_INSTALL_BINDIR "bin"
CACHE PATH "user executables (bin)")
set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}"
CACHE PATH "object code libraries (lib${LIB_SUFFIX})")
set(CMAKE_INSTALL_DATAROOTDIR "share"
CACHE PATH "read-only architecture-independent data root (share)")
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}"
CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_DATAROOTDIR CMAKE_INSTALL_DATADIR)
foreach(dir BINDIR LIBDIR DATAROOTDIR DATADIR)
2012-07-10 08:10:35 +00:00
if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
else()
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
endif()
2012-07-09 20:52:05 +00:00
endforeach()
2012-07-03 16:13:52 +00:00
endif()
2012-07-09 20:52:05 +00:00
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}/dhewm3")
set(datadir "${CMAKE_INSTALL_FULL_DATADIR}/dhewm3")
2012-01-14 12:56:19 +00:00
configure_file(
2012-07-10 08:10:35 +00:00
"${CMAKE_SOURCE_DIR}/config.h.in"
"${CMAKE_BINARY_DIR}/config.h"
2012-01-14 12:56:19 +00:00
)
2022-12-30 03:45:46 +00:00
if(NOT MSVC)
2012-01-14 13:51:37 +00:00
message(STATUS "Building ${CMAKE_BUILD_TYPE} for ${os}-${cpu}")
2022-12-30 03:45:46 +00:00
endif()
2011-12-12 18:15:16 +00:00
2012-07-09 21:31:35 +00:00
if(NOT APPLE AND NOT WIN32)
2012-07-09 20:52:05 +00:00
message(STATUS "The install target will use the following directories:")
message(STATUS " Binary directory: ${bindir}")
message(STATUS " Library directory: ${libdir}")
message(STATUS " Data directory: ${datadir}")
endif()
2011-12-12 18:15:16 +00:00
set(src_renderer
renderer/Cinematic.cpp
renderer/GuiModel.cpp
renderer/Image_files.cpp
renderer/Image_init.cpp
renderer/Image_load.cpp
renderer/Image_process.cpp
renderer/Image_program.cpp
renderer/Interaction.cpp
renderer/Material.cpp
renderer/MegaTexture.cpp
renderer/Model.cpp
renderer/ModelDecal.cpp
renderer/ModelManager.cpp
renderer/ModelOverlay.cpp
renderer/Model_beam.cpp
renderer/Model_ase.cpp
renderer/Model_liquid.cpp
renderer/Model_lwo.cpp
renderer/Model_ma.cpp
renderer/Model_md3.cpp
renderer/Model_md5.cpp
renderer/Model_prt.cpp
renderer/Model_sprite.cpp
renderer/RenderEntity.cpp
renderer/RenderSystem.cpp
renderer/RenderSystem_init.cpp
renderer/RenderWorld.cpp
renderer/RenderWorld_demo.cpp
renderer/RenderWorld_load.cpp
renderer/RenderWorld_portals.cpp
renderer/VertexCache.cpp
renderer/draw_arb2.cpp
renderer/draw_common.cpp
renderer/tr_backend.cpp
renderer/tr_deform.cpp
renderer/tr_font.cpp
renderer/tr_guisurf.cpp
renderer/tr_light.cpp
renderer/tr_lightrun.cpp
renderer/tr_main.cpp
renderer/tr_orderIndexes.cpp
renderer/tr_polytope.cpp
renderer/tr_render.cpp
renderer/tr_rendertools.cpp
renderer/tr_shadowbounds.cpp
renderer/tr_stencilshadow.cpp
renderer/tr_subview.cpp
renderer/tr_trace.cpp
renderer/tr_trisurf.cpp
renderer/tr_turboshadow.cpp
)
2019-01-06 04:55:10 +00:00
# I'm a bit sloppy with headers and just glob them in..
# they're only handled in CMake at all so they turn up in Visual Studio solutions..
# globs all the headers from ${PATHPREFIX}/ and adds them to ${SRCLIST}
function(add_globbed_headers SRCLIST PATHPREFIX)
file(GLOB_RECURSE tmp_hdrs RELATIVE "${CMAKE_SOURCE_DIR}" "${PATHPREFIX}/*.h")
set(${SRCLIST} ${tmp_hdrs} ${${SRCLIST}} PARENT_SCOPE)
endfunction()
add_globbed_headers(src_renderer "renderer")
2011-12-12 18:15:16 +00:00
set(src_framework
framework/CVarSystem.cpp
framework/CmdSystem.cpp
framework/Common.cpp
framework/Compressor.cpp
framework/Console.cpp
framework/DemoFile.cpp
framework/DeclAF.cpp
framework/DeclEntityDef.cpp
framework/DeclFX.cpp
framework/DeclManager.cpp
framework/DeclParticle.cpp
framework/DeclPDA.cpp
framework/DeclSkin.cpp
framework/DeclTable.cpp
framework/EditField.cpp
framework/EventLoop.cpp
framework/File.cpp
framework/FileSystem.cpp
framework/KeyInput.cpp
framework/UsercmdGen.cpp
framework/Session_menu.cpp
framework/Session.cpp
framework/async/AsyncClient.cpp
framework/async/AsyncNetwork.cpp
framework/async/AsyncServer.cpp
framework/async/MsgChannel.cpp
framework/async/NetworkSystem.cpp
framework/async/ServerScan.cpp
2012-12-31 16:23:27 +00:00
framework/minizip/ioapi.c
framework/minizip/unzip.cpp
2011-12-12 18:15:16 +00:00
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_framework "framework")
2011-12-12 18:15:16 +00:00
set(src_cm
cm/CollisionModel_contacts.cpp
cm/CollisionModel_contents.cpp
cm/CollisionModel_debug.cpp
cm/CollisionModel_files.cpp
cm/CollisionModel_load.cpp
cm/CollisionModel_rotate.cpp
cm/CollisionModel_trace.cpp
cm/CollisionModel_translate.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_cm "cm")
2011-12-12 18:15:16 +00:00
set(src_dmap
tools/compilers/dmap/dmap.cpp
tools/compilers/dmap/facebsp.cpp
tools/compilers/dmap/gldraw.cpp
tools/compilers/dmap/glfile.cpp
tools/compilers/dmap/leakfile.cpp
tools/compilers/dmap/map.cpp
tools/compilers/dmap/optimize.cpp
tools/compilers/dmap/output.cpp
tools/compilers/dmap/portals.cpp
tools/compilers/dmap/shadowopt3.cpp
tools/compilers/dmap/tritjunction.cpp
tools/compilers/dmap/tritools.cpp
tools/compilers/dmap/ubrush.cpp
tools/compilers/dmap/usurface.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_dmap "tools/compilers/dmap")
2011-12-12 18:15:16 +00:00
set(src_aas
tools/compilers/aas/AASBuild.cpp
tools/compilers/aas/AASBuild_file.cpp
tools/compilers/aas/AASBuild_gravity.cpp
tools/compilers/aas/AASBuild_ledge.cpp
tools/compilers/aas/AASBuild_merge.cpp
tools/compilers/aas/AASCluster.cpp
tools/compilers/aas/AASFile.cpp
tools/compilers/aas/AASFile_optimize.cpp
tools/compilers/aas/AASFile_sample.cpp
tools/compilers/aas/AASReach.cpp
tools/compilers/aas/AASFileManager.cpp
tools/compilers/aas/Brush.cpp
tools/compilers/aas/BrushBSP.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_aas "tools/compilers/aas")
2011-12-12 18:15:16 +00:00
set(src_roq
tools/compilers/roqvq/NSBitmapImageRep.cpp
tools/compilers/roqvq/codec.cpp
tools/compilers/roqvq/roq.cpp
tools/compilers/roqvq/roqParam.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_roq "tools/compilers/roqvq")
2011-12-12 18:15:16 +00:00
set(src_renderbump
tools/compilers/renderbump/renderbump.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_renderbump "tools/compilers/renderbump")
2011-12-12 18:15:16 +00:00
set(src_snd
sound/snd_cache.cpp
sound/snd_decoder.cpp
sound/snd_efxfile.cpp
sound/snd_emitter.cpp
sound/snd_shader.cpp
sound/snd_system.cpp
sound/snd_wavefile.cpp
sound/snd_world.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_snd "sound")
2011-12-12 18:15:16 +00:00
set(src_ui
ui/BindWindow.cpp
ui/ChoiceWindow.cpp
ui/DeviceContext.cpp
ui/EditWindow.cpp
ui/FieldWindow.cpp
ui/GameBearShootWindow.cpp
ui/GameBustOutWindow.cpp
ui/GameSSDWindow.cpp
ui/GuiScript.cpp
ui/ListGUI.cpp
ui/ListWindow.cpp
ui/MarkerWindow.cpp
ui/RegExp.cpp
ui/RenderWindow.cpp
ui/SimpleWindow.cpp
ui/SliderWindow.cpp
ui/UserInterface.cpp
ui/Window.cpp
ui/Winvar.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_ui "ui")
2011-12-12 18:15:16 +00:00
set(src_idlib
idlib/bv/Bounds.cpp
idlib/bv/Frustum.cpp
idlib/bv/Sphere.cpp
idlib/bv/Box.cpp
idlib/geometry/DrawVert.cpp
idlib/geometry/Winding2D.cpp
idlib/geometry/Surface_SweptSpline.cpp
idlib/geometry/Winding.cpp
idlib/geometry/Surface.cpp
idlib/geometry/Surface_Patch.cpp
idlib/geometry/TraceModel.cpp
idlib/geometry/JointTransform.cpp
idlib/hashing/CRC32.cpp
idlib/hashing/MD4.cpp
idlib/hashing/MD5.cpp
idlib/math/Angles.cpp
idlib/math/Lcp.cpp
idlib/math/Math.cpp
idlib/math/Matrix.cpp
idlib/math/Ode.cpp
idlib/math/Plane.cpp
idlib/math/Pluecker.cpp
idlib/math/Polynomial.cpp
idlib/math/Quat.cpp
idlib/math/Rotation.cpp
idlib/math/Simd.cpp
idlib/math/Simd_Generic.cpp
idlib/math/Simd_AltiVec.cpp
idlib/math/Simd_MMX.cpp
idlib/math/Simd_3DNow.cpp
idlib/math/Simd_SSE.cpp
idlib/math/Simd_SSE2.cpp
idlib/math/Simd_SSE3.cpp
idlib/math/Vector.cpp
idlib/BitMsg.cpp
idlib/LangDict.cpp
idlib/Lexer.cpp
idlib/Lib.cpp
idlib/containers/HashIndex.cpp
idlib/Dict.cpp
idlib/Str.cpp
idlib/Parser.cpp
idlib/MapFile.cpp
idlib/CmdArgs.cpp
idlib/Token.cpp
idlib/Base64.cpp
idlib/Timer.cpp
idlib/Heap.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_idlib "idlib")
2011-12-12 18:15:16 +00:00
set(src_game
game/AF.cpp
game/AFEntity.cpp
game/Actor.cpp
game/Camera.cpp
game/Entity.cpp
game/BrittleFracture.cpp
game/Fx.cpp
game/GameEdit.cpp
game/Game_local.cpp
game/Game_network.cpp
game/Item.cpp
game/IK.cpp
game/Light.cpp
game/Misc.cpp
game/Mover.cpp
game/Moveable.cpp
game/MultiplayerGame.cpp
game/Player.cpp
game/PlayerIcon.cpp
game/PlayerView.cpp
game/Projectile.cpp
game/Pvs.cpp
game/SecurityCamera.cpp
game/SmokeParticles.cpp
game/Sound.cpp
game/Target.cpp
game/Trigger.cpp
game/Weapon.cpp
game/WorldSpawn.cpp
game/ai/AAS.cpp
game/ai/AAS_debug.cpp
game/ai/AAS_pathing.cpp
game/ai/AAS_routing.cpp
game/ai/AI.cpp
game/ai/AI_events.cpp
game/ai/AI_pathing.cpp
game/ai/AI_Vagary.cpp
game/gamesys/DebugGraph.cpp
game/gamesys/Class.cpp
game/gamesys/Event.cpp
game/gamesys/SaveGame.cpp
game/gamesys/SysCmds.cpp
game/gamesys/SysCvar.cpp
game/gamesys/TypeInfo.cpp
game/anim/Anim.cpp
game/anim/Anim_Blend.cpp
game/anim/Anim_Import.cpp
game/anim/Anim_Testmodel.cpp
game/script/Script_Compiler.cpp
game/script/Script_Interpreter.cpp
game/script/Script_Program.cpp
game/script/Script_Thread.cpp
game/physics/Clip.cpp
game/physics/Force.cpp
game/physics/Force_Constant.cpp
game/physics/Force_Drag.cpp
game/physics/Force_Field.cpp
game/physics/Force_Spring.cpp
game/physics/Physics.cpp
game/physics/Physics_AF.cpp
game/physics/Physics_Actor.cpp
game/physics/Physics_Base.cpp
game/physics/Physics_Monster.cpp
game/physics/Physics_Parametric.cpp
game/physics/Physics_Player.cpp
game/physics/Physics_RigidBody.cpp
game/physics/Physics_Static.cpp
game/physics/Physics_StaticMulti.cpp
game/physics/Push.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_game "game")
2011-12-12 18:15:16 +00:00
set(src_d3xp
d3xp/AF.cpp
d3xp/AFEntity.cpp
d3xp/Actor.cpp
d3xp/Camera.cpp
d3xp/Entity.cpp
d3xp/BrittleFracture.cpp
d3xp/Fx.cpp
d3xp/GameEdit.cpp
d3xp/Game_local.cpp
d3xp/Game_network.cpp
d3xp/Item.cpp
d3xp/IK.cpp
d3xp/Light.cpp
d3xp/Misc.cpp
d3xp/Mover.cpp
d3xp/Moveable.cpp
d3xp/MultiplayerGame.cpp
d3xp/Player.cpp
d3xp/PlayerIcon.cpp
d3xp/PlayerView.cpp
d3xp/Projectile.cpp
d3xp/Pvs.cpp
d3xp/SecurityCamera.cpp
d3xp/SmokeParticles.cpp
d3xp/Sound.cpp
d3xp/Target.cpp
d3xp/Trigger.cpp
d3xp/Weapon.cpp
d3xp/WorldSpawn.cpp
d3xp/ai/AAS.cpp
d3xp/ai/AAS_debug.cpp
d3xp/ai/AAS_pathing.cpp
d3xp/ai/AAS_routing.cpp
d3xp/ai/AI.cpp
d3xp/ai/AI_events.cpp
d3xp/ai/AI_pathing.cpp
d3xp/ai/AI_Vagary.cpp
d3xp/gamesys/DebugGraph.cpp
d3xp/gamesys/Class.cpp
d3xp/gamesys/Event.cpp
d3xp/gamesys/SaveGame.cpp
d3xp/gamesys/SysCmds.cpp
d3xp/gamesys/SysCvar.cpp
d3xp/gamesys/TypeInfo.cpp
d3xp/anim/Anim.cpp
d3xp/anim/Anim_Blend.cpp
d3xp/anim/Anim_Import.cpp
d3xp/anim/Anim_Testmodel.cpp
d3xp/script/Script_Compiler.cpp
d3xp/script/Script_Interpreter.cpp
d3xp/script/Script_Program.cpp
d3xp/script/Script_Thread.cpp
d3xp/physics/Clip.cpp
d3xp/physics/Force.cpp
d3xp/physics/Force_Constant.cpp
d3xp/physics/Force_Drag.cpp
d3xp/physics/Force_Field.cpp
d3xp/physics/Force_Spring.cpp
d3xp/physics/Physics.cpp
d3xp/physics/Physics_AF.cpp
d3xp/physics/Physics_Actor.cpp
d3xp/physics/Physics_Base.cpp
d3xp/physics/Physics_Monster.cpp
d3xp/physics/Physics_Parametric.cpp
d3xp/physics/Physics_Player.cpp
d3xp/physics/Physics_RigidBody.cpp
d3xp/physics/Physics_Static.cpp
d3xp/physics/Physics_StaticMulti.cpp
d3xp/physics/Push.cpp
d3xp/Grabber.cpp
d3xp/physics/Force_Grab.cpp
)
2019-01-06 04:55:10 +00:00
add_globbed_headers(src_d3xp "d3xp")
2021-05-24 20:21:47 +00:00
set(src_debuggerServer
tools/debugger/DebuggerBreakpoint.h
tools/debugger/DebuggerBreakpoint.cpp
tools/debugger/DebuggerServer.h
tools/debugger/DebuggerServer.cpp
tools/debugger/DebuggerScript.h
tools/debugger/DebuggerScript.cpp
tools/debugger/DebuggerMessages.h
tools/debugger/debugger.cpp
)
2011-12-12 18:15:16 +00:00
set(src_core
${src_renderer}
${src_framework}
${src_cm}
${src_dmap}
${src_aas}
${src_roq}
${src_renderbump}
${src_snd}
${src_ui}
${src_tools}
)
set(src_stub_openal sys/stub/openal_stub.cpp)
set(src_stub_gl sys/stub/stub_gl.cpp)
2019-01-07 01:42:00 +00:00
set(src_tools
tools/guied/GEWindowWrapper_stub.cpp
)
# TODO: add_globbed_headers(src_tools "tools/guied")
# Begin normal tools code
if (TOOLS AND MFC_FOUND AND MSVC)
set(ALLOWRESOURCES ON)
# Common files.
file(GLOB src_comafx "tools/comafx/*.cpp")
2019-01-07 04:19:20 +00:00
add_globbed_headers(src_comafx "tools/comafx")
2019-01-07 01:42:00 +00:00
file(GLOB_RECURSE src_tools_common "tools/common/*.cpp")
2019-01-07 04:19:20 +00:00
add_globbed_headers(src_tools_common "tools/common")
2019-01-07 01:42:00 +00:00
#Compilers.
# DG: this is always added, why add it again? file(GLOB src_compiler_renderbump "neo/tools/compilers/renderbump/*.cpp")
file(GLOB src_compiler_roqvq "tools/compilers/roqvq/*.cpp") # FIXME: some of those were added before
add_globbed_headers(src_compiler_roqvq "tools/compilers/roqvq")
#tools
# Articulated Frame editor.
file(GLOB src_afeditor "tools/af/*.cpp")
add_globbed_headers(src_afeditor "tools/af")
# Declaration editor
file(GLOB src_decleditor "tools/decl/*.cpp")
add_globbed_headers(src_decleditor "tools/decl")
# GUI Editor.
file(GLOB src_gui_editor "tools/guied/*.cpp")
add_globbed_headers(src_gui_editor "tools/guied")
# Material editor
file(GLOB src_materialeditor "tools/materialeditor/*.cpp")
add_globbed_headers(src_materialeditor "tools/materialeditor")
# Particle Editor
file(GLOB src_particleeditor "tools/particle/*.cpp")
add_globbed_headers(src_particleeditor "tools/particle")
# PDA editor
file(GLOB src_pdaeditor "tools/pda/*.cpp")
add_globbed_headers(src_pdaeditor "tools/pda")
# Radiant ( Map editor )
file(GLOB src_map_editor "tools/radiant/*.cpp")
add_globbed_headers(src_map_editor "tools/radiant")
# Script editor
file(GLOB src_script_editor "tools/script/*.cpp")
add_globbed_headers(src_script_editor "tools/script")
2021-05-11 20:45:24 +00:00
# Script Debugger
2021-05-24 20:21:47 +00:00
set(src_debuggerClient
tools/debugger/DebuggerClient.h
tools/debugger/DebuggerClient.cpp
tools/debugger/DebuggerApp.h
tools/debugger/DebuggerApp.cpp
tools/debugger/DebuggerQuickWatchDlg.h
tools/debugger/DebuggerQuickWatchDlg.cpp
tools/debugger/DebuggerWindow.h
tools/debugger/DebuggerWindow.cpp
tools/debugger/DebuggerFindDlg.h
tools/debugger/DebuggerFindDlg.cpp
)
set(src_script_debugger
${src_debuggerServer}
${src_debuggerClient}
)
2019-01-07 01:42:00 +00:00
# sound editor?
file(GLOB src_sound_editor "tools/sound/*.cpp")
add_globbed_headers(src_sound_editor "tools/sound")
# The numerous tools in a nice list.
list(APPEND src_editor_tools
${src_comafx}
${src_tools_common}
${src_compiler_renderbump}
${src_afeditor}
${src_decleditor}
${src_gui_editor}
${src_materialeditor}
${src_particleeditor}
${src_pdaeditor}
${src_map_editor}
${src_script_editor}
${src_sound_editor}
2021-05-11 20:45:24 +00:00
${src_script_debugger}
2019-01-07 01:42:00 +00:00
"tools/edit_public.h"
"tools/edit_gui_common.h"
)
SET(CMAKE_MFC_FLAG 2)
2021-05-06 20:57:38 +00:00
set(TOOLS_DEFINES "ID_ALLOW_TOOLS;_AFXDLL")
2019-01-07 01:42:00 +00:00
else()
2021-05-24 20:21:47 +00:00
set(src_editor_tools "tools/edit_stub.cpp" "tools/edit_public.h" "tools/debugger/debugger_common.h")
list(APPEND src_editor_tools
${src_debuggerServer}
)
2019-01-07 01:42:00 +00:00
endif()
2015-06-20 19:30:46 +00:00
if(AROS)
set(DHEWM3BINARY "ADoom3")
set(sys_libs ${sys_libs} dll)
set(src_arosdll
sys/aros/dll/dllstartup.c
sys/aros/dll/dll.c
sys/aros/dll/dllimport.c
)
set(src_sys_base
sys/cpu.cpp
sys/threads.cpp
sys/events.cpp
sys/sys_local.cpp
sys/aros/aros_net.cpp
sys/aros/aros_signal.cpp
sys/aros/aros_main.cpp
sys/aros/aros_dos.cpp
)
set(src_sys_core
sys/glimp.cpp
)
elseif(APPLE)
2011-12-28 16:36:02 +00:00
set(OSX_RESOURCE_FILES
2015-10-03 07:17:30 +00:00
"${CMAKE_SOURCE_DIR}/sys/osx/Doom3.icns"
"${CMAKE_SOURCE_DIR}/sys/osx/Doom 3.rsrc"
2011-12-28 16:36:02 +00:00
)
set_source_files_properties(${OSX_RESOURCE_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
2011-12-12 18:15:16 +00:00
set(src_sys_base
2011-12-21 20:37:40 +00:00
sys/cpu.cpp
2011-12-20 17:46:08 +00:00
sys/threads.cpp
2011-12-31 15:38:45 +00:00
sys/events.cpp
2011-12-12 18:15:16 +00:00
sys/sys_local.cpp
sys/posix/posix_net.cpp
sys/posix/posix_main.cpp
)
set(src_sys_core
2011-12-31 15:38:45 +00:00
sys/glimp.cpp
2011-12-12 18:15:16 +00:00
sys/osx/DOOMController.mm
sys/osx/macosx_misc.mm
2011-12-28 16:36:02 +00:00
sys/osx/SDLMain.m
${OSX_RESOURCE_FILES}
2011-12-12 18:15:16 +00:00
)
2012-07-09 21:31:35 +00:00
elseif(WIN32)
2015-10-03 07:17:30 +00:00
2011-12-13 22:35:10 +00:00
set(src_sys_base
2011-12-21 20:37:40 +00:00
sys/cpu.cpp
2011-12-20 17:46:08 +00:00
sys/threads.cpp
2011-12-30 00:05:42 +00:00
sys/events.cpp
2011-12-13 22:35:10 +00:00
sys/sys_local.cpp
sys/win32/win_input.cpp
sys/win32/win_main.cpp
sys/win32/win_net.cpp
sys/win32/win_shared.cpp
sys/win32/win_syscon.cpp
2012-01-07 17:57:07 +00:00
sys/win32/SDL_win32_main.c
2011-12-13 22:35:10 +00:00
)
2019-01-07 01:42:00 +00:00
2019-01-06 04:55:10 +00:00
# adding the few relevant headers in sys/ manually..
set(src_sys_base ${src_sys_base}
sys/platform.h
sys/sys_local.h
sys/sys_public.h
sys/win32/win_local.h
)
2011-12-13 22:35:10 +00:00
set(src_sys_core
2012-08-28 19:01:21 +00:00
sys/glimp.cpp
2011-12-13 22:35:10 +00:00
)
2019-01-07 01:42:00 +00:00
if(TOOLS)
set(src_sys_core ${src_sys_core} "sys/win32/rc/doom.rc")
2019-01-07 04:19:20 +00:00
else()
# adding both .rc files breaks the build, but I think it only contains the icon
# and doom.rc also contains that (+icons for editor etc, AFAIK), so this is fine
set(src_sys_core ${src_sys_core} "${CMAKE_SOURCE_DIR}/sys/win32/rc/dhewm3.rc" )
2019-01-07 01:42:00 +00:00
endif()
2011-12-12 18:15:16 +00:00
else()
set(src_sys_base
2011-12-21 20:37:40 +00:00
sys/cpu.cpp
2011-12-20 17:46:08 +00:00
sys/threads.cpp
2011-12-29 19:36:25 +00:00
sys/events.cpp
2011-12-12 18:15:16 +00:00
sys/sys_local.cpp
sys/posix/posix_net.cpp
sys/posix/posix_main.cpp
sys/linux/main.cpp
)
set(src_sys_core
2011-12-29 18:19:57 +00:00
sys/glimp.cpp
2011-12-12 18:15:16 +00:00
)
endif()
2012-01-14 12:56:19 +00:00
include_directories(${CMAKE_BINARY_DIR})
2012-01-14 12:41:14 +00:00
include_directories(${CMAKE_SOURCE_DIR})
2011-12-12 18:15:16 +00:00
2011-12-31 17:16:21 +00:00
add_library(idlib STATIC ${src_idlib})
2015-06-20 19:30:46 +00:00
if (AROS)
add_library(dll STATIC ${src_arosdll})
2016-08-10 00:46:43 +00:00
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
set(AROS_ARCH "x86")
else()
set(AROS_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
2015-06-20 19:30:46 +00:00
else()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MINGW)
set_target_properties(idlib PROPERTIES COMPILE_FLAGS "-fPIC")
endif()
2011-12-16 18:35:50 +00:00
endif()
2019-01-06 04:55:10 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_idlib})
2021-06-22 20:38:45 +00:00
if(HARDLINK_GAME)
if(BASE)
set(src_core ${src_core} ${src_game})
set(game_includes "${CMAKE_SOURCE_DIR}/game")
if(D3XP)
message(WARNING "hardlinking the base game, d3xp will not be supported (disable BASE for D3XP support with HARDLINK_GAME)")
endif()
elseif(D3XP)
set(src_core ${src_core} ${src_d3xp})
set(game_includes "${CMAKE_SOURCE_DIR}/d3xp")
endif()
endif()# HARDLINK_GAME
2012-07-09 21:31:35 +00:00
if(CORE)
2015-06-20 19:30:46 +00:00
add_executable(${DHEWM3BINARY} WIN32 MACOSX_BUNDLE
2011-12-12 18:15:16 +00:00
${src_core}
${src_sys_base}
${src_sys_core}
2019-01-07 01:42:00 +00:00
${src_editor_tools}
2011-12-12 18:15:16 +00:00
)
2020-08-02 02:41:45 +00:00
if(MSVC AND CMAKE_MAJOR_VERSION GREATER 3 OR ( CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_VERSION GREATER_EQUAL 6 ))
# CMake >= 3.6 supports setting the default project started for debugging (instead of trying to launch ALL_BUILD ...)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${DHEWM3BINARY})
endif()
2011-12-12 18:15:16 +00:00
2019-01-07 01:42:00 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_sys_core} ${src_editor_tools})
2019-01-06 04:55:10 +00:00
2021-06-22 20:38:45 +00:00
if(HARDLINK_GAME)
set_target_properties(${DHEWM3BINARY} PROPERTIES COMPILE_DEFINITIONS "${TOOLS_DEFINES}")
target_include_directories(${DHEWM3BINARY} PRIVATE ${game_includes})
else()
2019-01-07 01:42:00 +00:00
set_target_properties(${DHEWM3BINARY} PROPERTIES COMPILE_DEFINITIONS "__DOOM_DLL__;${TOOLS_DEFINES}")
2021-06-22 20:38:45 +00:00
endif()
2015-06-20 19:30:46 +00:00
set_target_properties(${DHEWM3BINARY} PROPERTIES LINK_FLAGS "${ldflags}")
set_target_properties(${DHEWM3BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/sys/osx/Info.plist)
2011-12-31 17:16:21 +00:00
2015-06-20 19:30:46 +00:00
target_link_libraries(${DHEWM3BINARY}
2011-12-31 17:16:21 +00:00
idlib
2011-12-12 18:15:16 +00:00
${OPENAL_LIBRARY}
${CURL_LIBRARY}
2012-07-04 15:46:41 +00:00
${ZLIB_LIBRARY}
2012-07-19 18:05:38 +00:00
${SDLx_LIBRARY}
2011-12-12 18:15:16 +00:00
${sys_libs}
)
2012-07-04 00:17:34 +00:00
2012-07-09 21:31:35 +00:00
if(NOT APPLE AND NOT WIN32)
2015-06-20 19:30:46 +00:00
install(TARGETS ${DHEWM3BINARY}
2012-07-04 00:17:34 +00:00
RUNTIME DESTINATION "${bindir}"
LIBRARY DESTINATION "${libdir}"
ARCHIVE DESTINATION "${libdir}"
)
2012-07-09 21:31:35 +00:00
endif()
2011-12-12 18:15:16 +00:00
endif()
2012-07-09 21:31:35 +00:00
if(DEDICATED)
2015-06-20 19:30:46 +00:00
add_executable(${DHEWM3BINARY}ded WIN32 MACOSX_BUNDLE
2011-12-12 18:15:16 +00:00
${src_core}
${src_stub_openal}
${src_stub_gl}
${src_sys_base}
2021-05-24 20:21:47 +00:00
${src_debuggerServer}
2011-12-12 18:15:16 +00:00
)
2019-01-06 04:55:10 +00:00
2021-05-24 20:21:47 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_stub_openal} ${src_stub_gl} ${src_debuggerServer})
2011-12-12 18:15:16 +00:00
2021-06-22 20:38:45 +00:00
if(HARDLINK_GAME)
set_target_properties(${DHEWM3BINARY}ded PROPERTIES COMPILE_DEFINITIONS "ID_DEDICATED")
target_include_directories(${DHEWM3BINARY}ded PRIVATE ${game_includes})
else()
2015-06-20 19:30:46 +00:00
set_target_properties(${DHEWM3BINARY}ded PROPERTIES COMPILE_DEFINITIONS "ID_DEDICATED;__DOOM_DLL__")
2021-06-22 20:38:45 +00:00
endif()
2015-06-20 19:30:46 +00:00
set_target_properties(${DHEWM3BINARY}ded PROPERTIES LINK_FLAGS "${ldflags}")
target_link_libraries(${DHEWM3BINARY}ded
2011-12-31 17:16:21 +00:00
idlib
2011-12-12 18:15:16 +00:00
${CURL_LIBRARY}
2012-07-04 15:46:41 +00:00
${ZLIB_LIBRARY}
2012-07-19 18:05:38 +00:00
${SDLx_LIBRARY}
2011-12-12 18:15:16 +00:00
${sys_libs}
)
2012-07-04 00:17:34 +00:00
2012-07-09 21:31:35 +00:00
if(NOT APPLE AND NOT WIN32)
2015-06-20 19:30:46 +00:00
install(TARGETS ${DHEWM3BINARY}ded
2012-07-04 00:17:34 +00:00
RUNTIME DESTINATION "${bindir}"
LIBRARY DESTINATION "${libdir}"
ARCHIVE DESTINATION "${libdir}"
)
2012-07-09 21:31:35 +00:00
endif()
2011-12-12 18:15:16 +00:00
endif()
2021-06-22 20:38:45 +00:00
if(BASE AND NOT HARDLINK_GAME)
2015-06-20 19:30:46 +00:00
if (AROS)
add_executable(base sys/aros/dll/dllglue.c ${src_game})
2016-08-10 00:46:43 +00:00
set_target_properties(base PROPERTIES OUTPUT_NAME "base.aros-${AROS_ARCH}")
2015-06-20 19:30:46 +00:00
else()
add_library(base SHARED ${src_game})
endif()
2019-01-06 04:55:10 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_game})
2012-07-03 17:26:41 +00:00
set_target_properties(base PROPERTIES PREFIX "")
set_target_properties(base PROPERTIES COMPILE_DEFINITIONS "GAME_DLL")
2019-01-13 18:03:12 +00:00
target_include_directories(base PRIVATE "${CMAKE_SOURCE_DIR}/game")
2012-07-03 17:26:41 +00:00
set_target_properties(base PROPERTIES LINK_FLAGS "${ldflags}")
set_target_properties(base PROPERTIES INSTALL_NAME_DIR "@executable_path")
2015-06-20 19:30:46 +00:00
if (AROS)
target_link_libraries(base idlib dll)
else()
target_link_libraries(base idlib)
endif()
2012-07-04 00:17:34 +00:00
2012-07-09 21:31:35 +00:00
if(NOT APPLE AND NOT WIN32)
2012-07-04 00:17:34 +00:00
install(TARGETS base
RUNTIME DESTINATION "${bindir}"
LIBRARY DESTINATION "${libdir}"
ARCHIVE DESTINATION "${libdir}"
)
2012-07-09 21:31:35 +00:00
endif()
2011-12-12 18:15:16 +00:00
endif()
2021-06-22 20:38:45 +00:00
if(D3XP AND NOT HARDLINK_GAME)
2015-06-20 19:30:46 +00:00
if (AROS)
add_executable(d3xp sys/aros/dll/dllglue.c ${src_d3xp})
2016-08-10 00:46:43 +00:00
set_target_properties(d3xp PROPERTIES OUTPUT_NAME "d3xp.aros-${AROS_ARCH}")
2015-06-20 19:30:46 +00:00
else()
add_library(d3xp SHARED ${src_d3xp})
endif()
2019-01-06 04:55:10 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_d3xp})
2012-07-03 16:26:24 +00:00
set_target_properties(d3xp PROPERTIES PREFIX "")
set_target_properties(d3xp PROPERTIES COMPILE_DEFINITIONS "GAME_DLL;_D3XP;CTF")
2019-01-13 18:03:12 +00:00
target_include_directories(d3xp PRIVATE "${CMAKE_SOURCE_DIR}/d3xp")
2012-07-03 16:26:24 +00:00
set_target_properties(d3xp PROPERTIES LINK_FLAGS "${ldflags}")
set_target_properties(d3xp PROPERTIES INSTALL_NAME_DIR "@executable_path")
2015-06-20 19:30:46 +00:00
if (AROS)
target_link_libraries(d3xp idlib dll)
else()
target_link_libraries(d3xp idlib)
endif()
2012-07-04 00:17:34 +00:00
2012-07-09 21:31:35 +00:00
if(NOT APPLE AND NOT WIN32)
2012-07-04 00:17:34 +00:00
install(TARGETS d3xp
RUNTIME DESTINATION "${bindir}"
LIBRARY DESTINATION "${libdir}"
ARCHIVE DESTINATION "${libdir}"
)
2012-07-09 21:31:35 +00:00
endif()
2011-12-12 18:15:16 +00:00
endif()