2018-12-15 04:30:33 +00:00
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2018-08-25 23:43:10 +00:00
project(dhewm3sdk)
2011-12-12 18:15:16 +00:00
2018-08-26 02:47:00 +00:00
option(BASE "Build the base (game/) game code" ON)
2018-08-26 03:41:08 +00:00
set(BASE_NAME "dentonmod" CACHE STRING "Name of the mod built from game/ (will result in \${BASE_NAME}.dll)")
set(BASE_DEFS "GAME_DLL;_PORTALSKY;_DENTONMOD" CACHE STRING "Compiler definitions for the mod built from game/")
2018-08-26 02:47:00 +00:00
2018-08-26 03:41:08 +00:00
option(D3XP "Build the d3xp/ game code" OFF)
2018-08-26 02:47:00 +00:00
set(D3XP_NAME "d3xp" CACHE STRING "Name of the mod built from d3xp/ (will result in \${D3XP_NAME}.dll)")
set(D3XP_DEFS "GAME_DLL;_D3XP;CTF" CACHE STRING "Compiler definitions for the mod built from d3xp/")
option(ONATIVE "Optimize for the host CPU" OFF)
set(src_game_mod
# add additional .cpp files of your mod in game/
# (that you added to the ones already existant in the SDK/in dhewm3)
# like "game/MyFile.cpp" (without quotes, one file per line)
2018-08-26 03:41:08 +00:00
game/tracer.cpp
2018-08-26 02:47:00 +00:00
)
set(src_d3xp_mod
# add additional .cpp files of your mod in d3xp/
# (that you added to the ones already existant in the SDK/in dhewm3)
# like "d3xp/MyFile.cpp" (without quotes, one file per line)
)
2011-12-12 18:15:16 +00:00
2018-08-26 02:47:00 +00:00
########################################################################
# You /probably/ don't need to change anything below here for your Mod #
########################################################################
# 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()
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})
2012-07-09 21:31:35 +00:00
if(cpu STREQUAL "powerpc")
2011-12-12 18:15:16 +00:00
set(cpu "ppc")
2012-07-09 21:31:35 +00:00
elseif(cpu MATCHES "i.86")
2011-12-12 18:15:16 +00:00
set(cpu "x86")
endif()
2012-07-09 21:31:35 +00:00
if(MSVC AND CMAKE_CL_64)
2012-07-05 22:28:26 +00:00
set(cpu "amd64")
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()
# 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()
2011-12-20 15:12:17 +00:00
2018-08-25 23:43:10 +00:00
include(CheckCXXCompilerFlag)
include(TestBigEndian)
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()
2020-09-06 02:09:12 +00:00
set(CMAKE_C_FLAGS_DEBUG "-g -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")
2018-11-11 22:57:05 +00:00
set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fomit-frame-pointer")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-unsafe-math-optimizations -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)
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)
2018-08-25 23:43:10 +00:00
add_compile_options(-Wno-strict-overflow)
2015-10-03 07:17:30 +00:00
add_compile_options(-Wno-format-security)
2020-09-14 22:53:07 +00:00
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
# ‘ void* memset(void*, int, size_t)’ clearing an object of type ‘ struct refSound_t’ with no trivial copy-assignment; use assignment or value-initialization instead
# ‘ void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘ class idDrawVert’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead
# etc - I don't care, all the cases I've checked were safe and I'm not gonna add (void*) casts in 1000 places
# (that would make merging new mods painful)
add_compile_options(-Wno-class-memaccess)
endif()
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()
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")
2015-10-03 07:17:30 +00:00
add_compile_options(-arch x86_64 -mmacosx-version-min=10.6)
2011-12-23 16:29:05 +00:00
set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.6")
2021-01-17 23:51:48 +00:00
elseif(cpu STREQUAL "arm64")
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)
2015-10-03 07:17:30 +00:00
add_compile_options(-arch ppc)
2011-12-23 16:29:05 +00:00
set(ldflags "${ldflags} -arch ppc")
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-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")
2018-08-25 23:43:10 +00:00
# set(sys_libs ${sys_libs} dl) FIXME: -ldl needed anyway?
2011-12-12 18:15:16 +00:00
endif()
2012-07-09 21:31:35 +00:00
elseif(MSVC)
2020-09-06 02:09:12 +00:00
add_definitions(/MP) # parallel build (use all cores, or as many as configured in VS)
2015-10-03 07:17:30 +00:00
add_compile_options(/W4)
2020-09-06 02:09:12 +00:00
add_compile_options(/we4840) # treat as error when passing a class to a vararg-function (probably printf-like)
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-09-01 22:55:08 +00:00
add_compile_options(/wd4458) # declaration of 'bla' 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_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
set(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
2011-12-13 22:35:10 +00:00
# mingw and msvc
2012-07-09 21:31:35 +00:00
if(WIN32)
2011-12-13 22:35:10 +00:00
add_definitions(-DWINVER=0x0501)
add_definitions(-D_WIN32_WINNT=0x0501)
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")
2018-08-25 23:43:10 +00:00
TEST_BIG_ENDIAN(is_big_endian)
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
)
2012-01-14 13:51:37 +00:00
message(STATUS "Building ${CMAKE_BUILD_TYPE} for ${os}-${cpu}")
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()
2020-09-06 02:09:12 +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()
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
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
2018-08-26 02:47:00 +00:00
${src_game_mod}
2011-12-12 18:15:16 +00:00
)
2020-09-06 02:09:12 +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
2018-08-26 02:47:00 +00:00
${src_d3xp_mod}
2011-12-12 18:15:16 +00:00
)
2020-09-06 02:09:12 +00:00
add_globbed_headers(src_d3xp "d3xp")
2018-08-25 23:43:10 +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
2011-12-12 18:15:16 +00:00
)
2020-09-06 02:09:12 +00:00
add_globbed_headers(src_idlib "idlib")
# just add all the remaining headers (that have no corresponding .cpp in the SDK)
# to idlib so they can be navigated there
add_globbed_headers(src_idlib "cm")
add_globbed_headers(src_idlib "framework")
add_globbed_headers(src_idlib "renderer")
add_globbed_headers(src_idlib "sound")
add_globbed_headers(src_idlib "sys")
add_globbed_headers(src_idlib "tools")
add_globbed_headers(src_idlib "ui")
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()
2020-09-06 02:09:12 +00:00
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_idlib})
2012-07-09 21:31:35 +00:00
if(BASE)
2015-06-20 19:30:46 +00:00
if (AROS)
add_executable(base sys/aros/dll/dllglue.c ${src_game})
2018-08-26 02:47:00 +00:00
set_target_properties(base PROPERTIES OUTPUT_NAME "${BASE_NAME}.aros-${AROS_ARCH}")
2015-06-20 19:30:46 +00:00
else()
add_library(base SHARED ${src_game})
2018-08-26 02:47:00 +00:00
# so mods can create cdoom.dll instead of base.dll from the code in game/
set_target_properties(base PROPERTIES OUTPUT_NAME "${BASE_NAME}")
2015-06-20 19:30:46 +00:00
endif()
2020-09-06 02:09:12 +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 "")
2018-08-26 02:47:00 +00:00
set_target_properties(base PROPERTIES COMPILE_DEFINITIONS "${BASE_DEFS}")
2020-09-06 02:09: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()
2012-07-09 21:31:35 +00:00
if(D3XP)
2015-06-20 19:30:46 +00:00
if (AROS)
add_executable(d3xp sys/aros/dll/dllglue.c ${src_d3xp})
2018-08-26 02:47:00 +00:00
set_target_properties(d3xp PROPERTIES OUTPUT_NAME "${D3XP_NAME}.aros-${AROS_ARCH}")
2015-06-20 19:30:46 +00:00
else()
add_library(d3xp SHARED ${src_d3xp})
2018-08-26 02:47:00 +00:00
# so mods can create whatever.dll instead of d3xp.dll from the code in d3xp/
set_target_properties(d3xp PROPERTIES OUTPUT_NAME "${D3XP_NAME}")
2015-06-20 19:30:46 +00:00
endif()
2020-09-06 02:09:12 +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 "")
2018-08-26 02:47:00 +00:00
set_target_properties(d3xp PROPERTIES COMPILE_DEFINITIONS "${D3XP_DEFS}")
2020-09-06 02:09: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()