2019-10-29 18:53:46 +00:00
cmake_minimum_required( VERSION 3.1.0 )
2019-09-22 21:15:46 +00:00
include(precompiled_headers)
if( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()
include( CheckCXXSourceCompiles )
include( CheckFunctionExists )
include( CheckCXXCompilerFlag )
include( CheckIncludeFile )
include( CheckIncludeFiles )
include( CheckLibraryExists )
include( FindPkgConfig )
2019-09-22 23:28:18 +00:00
if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
option( NO_STRIP "Do not strip Release or MinSizeRel builds" )
# At least some versions of Xcode fail if you strip with the linker
# instead of the separate strip utility.
if( APPLE )
set( NO_STRIP ON )
endif()
endif()
2020-01-06 01:41:47 +00:00
# Build does not work with signed chars!
2019-10-16 21:09:02 +00:00
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
2020-01-06 01:41:47 +00:00
else()
2020-01-07 00:11:19 +00:00
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
2019-10-16 21:09:02 +00:00
endif()
2019-09-22 21:15:46 +00:00
option( DYN_OPENAL "Dynamically load OpenAL" ON )
if( APPLE )
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
endif()
2019-12-27 12:37:39 +00:00
target_architecture(TARGET_ARCHITECTURE)
message(STATUS "Architecture is ${TARGET_ARCHITECTURE}")
2019-11-19 20:35:35 +00:00
2019-10-17 18:29:58 +00:00
# Right now only 64 bit is supported.
2019-12-27 12:37:39 +00:00
if( ${TARGET_ARCHITECTURE} MATCHES "x86_64" )
2019-11-19 20:35:35 +00:00
set( X64 64 )
endif()
2019-09-22 21:15:46 +00:00
2019-12-27 12:37:39 +00:00
if( X64 OR ${TARGET_ARCHITECTURE} MATCHES "i386" )
2019-09-22 21:15:46 +00:00
add_definitions( -DARCH_IA32 )
endif()
2019-12-27 12:37:39 +00:00
if( NOT PROJECT_LIBRARIES )
set( PROJECT_LIBRARIES "" )
2019-09-22 21:15:46 +00:00
endif()
if( WIN32 )
if( X64 )
set( WIN_TYPE Win64 )
set( XBITS x64 )
else()
set( WIN_TYPE Win32 )
set( XBITS x86 )
endif()
add_definitions( -D_WIN32 )
2019-10-17 18:29:58 +00:00
set( DX_dinput8_LIBRARY dinput8 )
2019-09-22 21:15:46 +00:00
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES
2019-09-22 21:15:46 +00:00
opengl32
wsock32
winmm
"${DX_dinput8_LIBRARY}"
ole32
user32
gdi32
comctl32
comdlg32
ws2_32
setupapi
oleaut32
2020-01-06 01:41:47 +00:00
dbghelp
2019-09-22 21:15:46 +00:00
legacy_stdio_definitions
2020-01-06 01:41:47 +00:00
2019-09-22 21:15:46 +00:00
shlwapi
version
imm32
dxguid
dsound
winspool
advapi32
shell32
SetupAPI
uuid
odbc32
odbccp32
2019-12-18 21:50:37 +00:00
# this local library crap needs to go away. Sadly there doesn't seem to be anything to get a working libvpx that doesn't force linking with MinGW dependencies.
2019-09-22 21:15:46 +00:00
libvpx
libcompat-to-msvc
2020-01-06 01:41:47 +00:00
2019-09-22 21:15:46 +00:00
)
2020-01-06 01:41:47 +00:00
2019-09-22 21:15:46 +00:00
2019-09-22 23:28:18 +00:00
if( NOT DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} DelayImp )
2019-09-22 21:15:46 +00:00
endif()
2019-09-22 23:28:18 +00:00
if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
if( DX_dxguid_LIBRARY )
2019-12-27 12:37:39 +00:00
list( APPEND PROJECT_LIBRARIES "${DX_dxguid_LIBRARY}" )
2019-09-22 21:15:46 +00:00
endif()
endif()
else()
if( APPLE )
set( NO_GTK ON )
set( DYN_GTK OFF )
# Prevent inclusion of fp.h and FixMath.h from Carbon framework
# Declarations from these files are not used but cause the following conflicts:
# - redefinition of 'FixedToFloat' and 'FloatToFixed' macros
# - redefinition of 'pi' as different kind of symbol
add_definitions( -D__FP__ -D__FIXMATH__ )
else()
option( NO_GTK "Disable GTK+ dialogs (Not applicable to Windows)" )
option( DYN_GTK "Load GTK+ at runtime instead of compile time" ON )
# Use GTK+ for the IWAD picker, if available.
if( NOT NO_GTK )
pkg_check_modules( GTK3 gtk+-3.0 )
if( GTK3_FOUND )
if( NOT DYN_GTK )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${GTK3_LIBRARIES} )
2019-09-22 21:15:46 +00:00
endif()
include_directories( ${GTK3_INCLUDE_DIRS} )
link_directories( ${GTK3_LIBRARY_DIRS} )
else()
pkg_check_modules( GTK2 gtk+-2.0 )
if( GTK2_FOUND )
if( NOT DYN_GTK )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${GTK2_LIBRARIES} )
2019-09-22 21:15:46 +00:00
endif()
include_directories( ${GTK2_INCLUDE_DIRS} )
link_directories( ${GTK2_LIBRARY_DIRS} )
else()
set( NO_GTK ON )
endif()
endif()
endif()
endif()
if( NO_GTK )
add_definitions( -DNO_GTK )
elseif( DYN_GTK )
add_definitions( -DDYN_GTK=1 )
else()
add_definitions( -DDYN_GTK=0 )
endif()
# Non-Windows version also needs SDL except native OS X backend
if( NOT APPLE OR NOT OSX_COCOA_BACKEND )
find_package( SDL2 REQUIRED )
include_directories( "${SDL2_INCLUDE_DIR}" )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${SDL2_LIBRARY}" )
2019-09-22 21:15:46 +00:00
endif()
find_path( FPU_CONTROL_DIR fpu_control.h )
if( FPU_CONTROL_DIR )
include_directories( ${FPU_CONTROL_DIR} )
add_definitions( -DHAVE_FPU_CONTROL )
endif()
endif()
if( NOT NO_OPENAL )
if ( NOT DYN_OPENAL ) # DYN_OPENAL uses local copies of the headers.
find_package( OpenAL )
mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
if( OPENAL_INCLUDE_DIR )
include_directories( ${OPENAL_INCLUDE_DIR} )
mark_as_advanced(CLEAR OPENAL_LIBRARY)
if( OPENAL_LIBRARY )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${OPENAL_LIBRARY} ${PROJECT_LIBRARIES} )
2019-09-22 21:15:46 +00:00
else()
set( NO_OPENAL ON )
endif()
else()
set( NO_OPENAL ON )
endif()
else()
add_definitions( -DDYN_OPENAL )
endif()
endif()
if( NO_OPENAL )
add_definitions( -DNO_OPENAL=1 )
endif()
# Decide on SSE setup
2019-12-27 12:37:39 +00:00
# SSE only matters on 32-bit targets. We check compiler flags to know if we can do it.
if( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc )
2019-09-22 21:15:46 +00:00
CHECK_CXX_COMPILER_FLAG( "-msse2 -mfpmath=sse" CAN_DO_MFPMATH )
CHECK_CXX_COMPILER_FLAG( -arch:SSE2 CAN_DO_ARCHSSE2 )
if( CAN_DO_MFPMATH )
set( SSE1_ENABLE "-msse -mfpmath=sse" )
set( SSE2_ENABLE "-msse2 -mfpmath=sse" )
elseif( CAN_DO_ARCHSSE2 )
set( SSE1_ENABLE -arch:SSE )
set( SSE2_ENABLE -arch:SSE2 )
endif()
endif()
if( X64 )
set( HAVE_MMX 1 )
else( X64 )
set( SAFE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
2019-09-22 23:28:18 +00:00
if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx")
2019-09-22 23:28:18 +00:00
endif( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
CHECK_CXX_SOURCE_COMPILES("#include <mmintrin.h>
int main(void) { __m64 v = _m_from_int(0); }"
HAVE_MMX)
set( CMAKE_CXX_FLAGS ${SAFE_CMAKE_CXX_FLAGS} )
endif( X64 )
CHECK_CXX_SOURCE_COMPILES("#include <ppl.h>
int main() { concurrency::parallel_for(0, 1, 1, [](int) { } ); }"
HAVE_PARALLEL_FOR)
if( NOT HAVE_PARALLEL_FOR )
CHECK_CXX_SOURCE_COMPILES("#include <dispatch/dispatch.h>
int main() { dispatch_apply(1, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t) { }); }"
HAVE_DISPATCH_APPLY)
endif()
# Set up flags for MSVC
if (MSVC)
set( CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}" )
endif (MSVC)
# Set up flags for GCC
2019-09-22 23:28:18 +00:00
if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
if( PROFILE )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" )
endif()
2020-01-20 09:09:44 +00:00
#set( REL_CXX_FLAGS "-fno-rtti" )
2019-09-22 21:15:46 +00:00
if( NOT PROFILE AND NOT APPLE )
# On OS X frame pointers are required for exception handling, at least with Clang
set( REL_CXX_FLAGS "${REL_CXX_FLAGS} -fomit-frame-pointer" )
endif()
set( CMAKE_CXX_FLAGS_RELEASE "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}" )
set( CMAKE_CXX_FLAGS_MINSIZEREL "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
# Support for the GCC/Clang sanitizers.
set( WITH_ASAN 0 CACHE BOOL "Enable the Address Sanitizer")
if( NOT CMAKE_COMPILER_IS_GNUCXX )
set( WITH_MSAN 0 CACHE BOOL "Enable the Memory Sanitizer")
endif( NOT CMAKE_COMPILER_IS_GNUCXX )
set( WITH_UBSAN 0 CACHE BOOL "Enable the Undefined Behavior Sanitizer")
if( WITH_MSAN )
if ( WITH_ASAN OR WITH_UBSAN )
message( SEND_ERROR "You can't use MSAN with either ASAN or UBSAN." )
endif ( WITH_ASAN OR WITH_UBSAN )
endif( WITH_MSAN )
set( SANITIZER_FLAG "" )
if( WITH_ASAN )
set( SANITIZER_FLAG "-fsanitize=address" )
if ( WITH_UBSAN )
set( SANITIZER_FLAG "${SANITIZER_FLAG},undefined" )
endif( WITH_UBSAN )
elseif( WITH_MSAN )
set( SANITIZER_FLAG "-fsanitize=memory" )
elseif( WITH_UBSAN )
set( SANITIZER_FLAG "-fsanitize=undefined" )
endif( WITH_ASAN )
set( CMAKE_CXX_FLAGS "${SANITIZER_FLAG} ${CMAKE_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "${SANITIZER_FLAG} ${CMAKE_C_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "${SANITIZER_FLAG} ${CMAKE_EXE_LINKER_FLAGS}" )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.5")
set( CMAKE_C_FLAGS "-Wno-unused-result ${CMAKE_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "-Wno-unused-result ${CMAKE_CXX_FLAGS}" )
endif()
if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
if( APPLE OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "3.6" )
set( CMAKE_CXX_FLAGS "-Wno-inconsistent-missing-override ${CMAKE_CXX_FLAGS}" )
endif()
endif()
set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_CXX_FLAGS}" )
# ARM processors (Raspberry Pi, et al) - enable ARM NEON support.
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set (USE_ARMV8 0 CACHE BOOL "Use ARMv8 instructions - Raspberry Pi 3")
if (USE_ARMV8)
set( CMAKE_CXX_FLAGS "-mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mtune=cortex-a53 -mhard-float -DNO_SSE ${CMAKE_CXX_FLAGS}" )
else ()
set( CMAKE_CXX_FLAGS "-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mtune=cortex-a7 -mhard-float -DNO_SSE ${CMAKE_CXX_FLAGS}" )
endif ()
endif ()
if( NOT X64 AND NOT CAN_DO_MFPMATH )
set( CMAKE_C_FLAGS "-DNO_SSE ${CMAKE_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "-DNO_SSE ${CMAKE_CXX_FLAGS}" )
endif()
# Remove extra warnings when using the official DirectX headers.
# Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid,
# which is a royal pain. The previous version I had been using was fine with them.
# MinGW: switch to the Windows Unicode API.
if( WIN32 )
set( CMAKE_CXX_FLAGS "-Wno-unknown-pragmas -Wno-comment -Wno-format ${CMAKE_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "-D_UNICODE -DUNICODE ${CMAKE_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode" )
endif()
# Detect FreeBSD and add flags
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
endif()
if( NOT NO_STRIP )
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" )
set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s" )
endif()
endif()
# Check for thread_local keyword, it's optional at the moment
2020-01-06 01:41:47 +00:00
#CHECK_CXX_SOURCE_COMPILES("thread_local int i; int main() { i = 0; }"
# HAVE_THREAD_LOCAL)
2019-09-22 21:15:46 +00:00
2020-01-06 01:41:47 +00:00
#if( NOT HAVE_THREAD_LOCAL )
# message( SEND_ERROR "C++ compiler doesn't support thread_local storage duration specifier" )
#endif()
2019-09-22 21:15:46 +00:00
# Check for functions that may or may not exist.
CHECK_FUNCTION_EXISTS( filelength FILELENGTH_EXISTS )
if( FILELENGTH_EXISTS )
add_definitions( -DHAVE_FILELENGTH=1 )
endif()
CHECK_FUNCTION_EXISTS( strupr STRUPR_EXISTS )
if( NOT STRUPR_EXISTS )
add_definitions( -DNEED_STRUPR=1 )
endif()
CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
if( NOT STRICMP_EXISTS )
add_definitions( -Dstricmp=strcasecmp )
endif()
CHECK_FUNCTION_EXISTS( strnicmp STRNICMP_EXISTS )
if( NOT STRNICMP_EXISTS )
add_definitions( -Dstrnicmp=strncasecmp )
endif()
if( NOT MSVC )
add_definitions( -D__forceinline=inline )
endif()
if( UNIX )
CHECK_LIBRARY_EXISTS( rt clock_gettime "" CLOCK_GETTIME_IN_RT )
if( NOT CLOCK_GETTIME_IN_RT )
CHECK_FUNCTION_EXISTS( clock_gettime CLOCK_GETTIME_EXISTS )
if( NOT CLOCK_GETTIME_EXISTS )
message( STATUS "Could not find clock_gettime. Timing statistics will not be available." )
add_definitions( -DNO_CLOCK_GETTIME )
endif()
else()
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} rt )
2019-09-22 21:15:46 +00:00
endif()
endif()
# Flags
# Update gitinfo.h
add_custom_target( revision_check ALL
2020-04-11 22:16:14 +00:00
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/tools/updaterevision/UpdateRevision.cmake" source/gitinfo.h
2019-09-22 21:15:46 +00:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
2020-04-11 22:04:02 +00:00
)
2019-09-22 21:15:46 +00:00
2019-12-26 13:16:00 +00:00
# required libraries
2019-09-22 21:15:46 +00:00
2020-02-09 12:26:51 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${CMAKE_DL_LIBS}" )
2019-09-22 21:15:46 +00:00
if (HAVE_VULKAN)
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "glslang" "SPIRV" "OGLCompiler")
2019-09-22 21:15:46 +00:00
endif()
2020-02-09 12:26:51 +00:00
# ZMUSIC
2020-02-09 14:48:07 +00:00
if( MSVC )
find_package( ZMusic )
else()
2020-04-13 08:28:31 +00:00
find_package( ZMusic REQUIRED )
2020-02-09 14:48:07 +00:00
endif()
2020-02-09 12:26:51 +00:00
if( MSVC AND NOT ZMUSIC_FOUND )
# Use prebuilt library
set( ZMUSIC_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../bin/windows/zmusic" )
set( ZMUSIC_INCLUDE_DIR ${ZMUSIC_ROOT_PATH}/include )
set( ZMUSIC_LIBRARIES zmusiclite )
if( X64 )
link_directories( ${ZMUSIC_ROOT_PATH}/64bit )
else()
link_directories( ${ZMUSIC_ROOT_PATH}/32bit )
endif()
set( ZMUSIC_FOUND TRUE )
endif()
2020-01-28 09:04:48 +00:00
# VPX
if( MSVC AND NOT VPX_FOUND )
# Use prebuilt library
set( VPX_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows" )
set( VPX_INCLUDE_DIR ${VPX_ROOT_PATH}/include )
set( VPX_LIBRARIES libvpx libcompat-to-msvc )
if( X64 )
link_directories( ${VPX_ROOT_PATH}/lib/64 )
else()
link_directories( ${VPX_ROOT_PATH}/lib/32 )
# Workaround for "error LNK2026: module unsafe for SAFESEH image."
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO" )
endif()
set( VPX_FOUND TRUE )
endif()
if( VPX_FOUND )
add_definitions( "-DUSE_LIBVPX=1" )
include_directories( "${VPX_INCLUDE_DIR}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${VPX_LIBRARIES} )
endif()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" )
2019-09-22 21:15:46 +00:00
if (WIN32)
2020-01-28 09:04:48 +00:00
include_directories( "platform/win32" )
2019-09-22 21:15:46 +00:00
endif()
if( ${HAVE_VM_JIT} )
add_definitions( -DHAVE_VM_JIT )
include_directories( "${ASMJIT_INCLUDE_DIR}" )
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ASMJIT_LIBRARIES}")
2019-09-22 21:15:46 +00:00
endif()
2020-01-06 01:35:27 +00:00
set( PLAT_POSIX_SOURCES
platform/posix/i_steam.cpp )
set( PLAT_SDL_SOURCES
platform/posix/sdl/crashcatcher.c
platform/posix/sdl/hardware.cpp
platform/posix/sdl/i_gui.cpp
platform/posix/sdl/i_input.cpp
platform/posix/sdl/i_joystick.cpp
platform/posix/sdl/i_main.cpp
platform/posix/sdl/i_system.cpp
platform/posix/sdl/sdlglvideo.cpp
platform/posix/sdl/st_start.cpp )
set( PLAT_UNIX_SOURCES
platform/posix/unix/i_specialpaths.cpp
platform/posix/unix/gtk_dialogs.cpp )
set( PLAT_OSX_SOURCES
platform/posix/osx/iwadpicker_cocoa.mm
platform/posix/osx/i_specialpaths.mm
2020-01-26 14:39:10 +00:00
platform/posix/osx/raze.icns )
2020-01-06 01:35:27 +00:00
set( PLAT_COCOA_SOURCES
platform/posix/cocoa/i_input.mm
platform/posix/cocoa/i_joystick.cpp
platform/posix/cocoa/i_main.mm
platform/posix/cocoa/i_system.mm
platform/posix/cocoa/i_video.mm
platform/posix/cocoa/st_console.mm
platform/posix/cocoa/st_start.mm )
2019-09-22 21:15:46 +00:00
2019-12-26 13:16:00 +00:00
# Start defining source files
2019-09-22 21:15:46 +00:00
set( PLAT_WIN32_SOURCES
2019-12-22 19:55:47 +00:00
platform/win32/base_sysfb.cpp
platform/win32/gl_sysfb.cpp
platform/win32/hardware.cpp
platform/win32/i_crash.cpp
platform/win32/i_dijoy.cpp
platform/win32/i_input.cpp
platform/win32/i_keyboard.cpp
platform/win32/i_main.cpp
platform/win32/i_mouse.cpp
platform/win32/i_rawps2.cpp
2019-10-21 19:36:05 +00:00
platform/win32/i_specialpaths.cpp
2019-12-22 19:55:47 +00:00
platform/win32/i_system.cpp
platform/win32/i_xinput.cpp
platform/win32/st_start.cpp
platform/win32/st_start_util.cpp
platform/win32/win32basevideo.cpp
platform/win32/win32glvideo.cpp
platform/win32/win32vulkanvideo.cpp
2019-09-22 21:15:46 +00:00
)
if( WIN32 )
2020-01-06 01:35:27 +00:00
set( SYSTEM_SOURCES_DIR platform/win32 )
2019-09-22 21:15:46 +00:00
set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
2019-09-22 23:28:18 +00:00
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} platform/win32/gameres.rc )
2019-09-22 21:15:46 +00:00
elseif( APPLE )
if( OSX_COCOA_BACKEND )
2020-01-08 00:00:57 +00:00
set( SYSTEM_SOURCES_DIR platform/posix/cocoa )
2019-09-22 21:15:46 +00:00
set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
else()
2020-01-07 00:11:19 +00:00
set( SYSTEM_SOURCES_DIR platform/posix/sdl )
2019-09-22 21:15:46 +00:00
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} )
2020-01-06 01:35:27 +00:00
set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} platform/posix/sdl/i_system.mm )
2019-09-22 21:15:46 +00:00
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
endif()
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} )
2020-01-06 01:35:27 +00:00
set_source_files_properties( platform/posix/osx/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( platform/posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
2019-09-22 21:15:46 +00:00
else()
2020-01-07 23:34:17 +00:00
set( SYSTEM_SOURCES_DIR platform/posix/sdl )
2019-09-22 21:15:46 +00:00
set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} )
endif()
if( HAVE_PARALLEL_FOR )
add_definitions( -DHAVE_PARALLEL_FOR=1 )
elseif( HAVE_DISPATCH_APPLY )
add_definitions( -DHAVE_DISPATCH_APPLY=1 )
else()
option( NO_OPENMP "Disable usage of OpenMP" OFF )
if( NOT NO_OPENMP )
include( FindOpenMP )
if( OPENMP_FOUND )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
endif( OPENMP_FOUND )
endif( NOT NO_OPENMP )
endif()
2020-04-07 22:19:49 +00:00
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.c ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.h
COMMAND lemon -C${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/frontend/zcc-parse.lemon
DEPENDS lemon ${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/frontend/zcc-parse.lemon )
2019-09-22 21:15:46 +00:00
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h
2020-04-11 22:04:02 +00:00
COMMAND re2c --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/common/engine/sc_man_scanner.re
DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/common/engine/sc_man_scanner.re )
2020-01-06 01:41:47 +00:00
2019-09-22 21:15:46 +00:00
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
#option( SEND_ANON_STATS "Enable sending of anonymous hardware statistics" ON )
#if( NOT SEND_ANON_STATS )
# add_definitions( -DNO_SEND_STATS )
#endif()
# Project files should be aware of the header files. We can GLOB these since
# there's generally a new cpp for every header so this file will get changed
file( GLOB HEADER_FILES
build/include/*.h
glbackend/*.h
libsmackerdec/include/*.h
libxmp-lite/include/libxmp-lite/*.h
libxmp-lite/src/*.h
2020-04-11 21:38:30 +00:00
core/*.h
core/2d/*.h
core/fonts/*.h
core/utility/*.h
core/utility/rapidjson/*.h
core/console/*.h
core/music/*.h
core/menu/*.h
core/input/*.h
core/rendering/*.h
core/rendering/gl/system/*.h
core/rendering/gl/renderer/*.h
core/rendering/gl/shaders/*.h
core/rendering/hwrenderer/data/*.h
core/rendering/hwrenderer/postprocessing/*.h
core/rendering/hwrenderer/utility/*.h
2019-09-22 21:15:46 +00:00
2020-04-12 06:19:19 +00:00
common/audio/sound/thirdparty/*.h
common/audio/sound/*.h
2020-04-12 06:08:31 +00:00
common/audio/music/*.h*
common/console/*.h
2020-04-11 21:50:43 +00:00
common/utility/*.h
2020-04-11 22:04:02 +00:00
common/engine/*.h
2020-04-06 14:10:54 +00:00
common/objects/*.h
2020-04-11 21:54:33 +00:00
common/filesystem/*.h
2020-04-11 22:04:02 +00:00
common/textures/*.h
2020-04-11 21:50:43 +00:00
common/thirdparty/*.h
common/thirdparty/rapidjson/*.h
2020-04-06 19:10:07 +00:00
common/thirdparty/math/*h
2020-04-10 20:17:29 +00:00
common/rendering/gl_load/*.h
2020-04-06 19:10:07 +00:00
common/scripting/core/*h
common/scripting/vm/*h
common/scripting/jit/*h
common/scripting/interface/*.h
2020-04-07 18:14:24 +00:00
common/scripting/backend/*.h
2020-04-07 22:19:49 +00:00
common/scripting/frontend/*.h
2020-04-11 21:50:43 +00:00
2019-09-22 21:15:46 +00:00
build/src/*.h
2019-12-22 19:55:47 +00:00
platform/win32/*.h
2020-01-26 14:40:43 +00:00
platform/posix/*.h
2019-09-22 21:15:46 +00:00
thirdparty/include/*.h
thirdparty/include/*.hpp
2019-11-07 19:31:16 +00:00
thirdparty/imgui/*.h
2020-04-11 21:38:30 +00:00
core/textures/*.h
core/textures/formats/*.h
2019-09-22 21:15:46 +00:00
)
# These files will be flagged as "headers" so that they appear in project files
# without being compiled.
set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
2019-10-23 23:20:58 +00:00
sc_man_scanner.h
2020-04-11 22:04:02 +00:00
common/engine/sc_man_scanner.re
2020-04-07 22:19:49 +00:00
common/scripting/frontend/zcc-parse.lemon
zcc-parse.c
zcc-parse.h
2019-12-27 12:39:30 +00:00
platform/win32/zutil.natvis
2019-09-22 21:15:46 +00:00
)
2020-04-06 21:32:29 +00:00
set( VM_JIT_SOURCES
common/scripting/jit/jit.cpp
common/scripting/jit/jit_runtime.cpp
common/scripting/jit/jit_call.cpp
common/scripting/jit/jit_flow.cpp
common/scripting/jit/jit_load.cpp
common/scripting/jit/jit_math.cpp
common/scripting/jit/jit_move.cpp
common/scripting/jit/jit_store.cpp
)
2019-09-22 21:15:46 +00:00
# Enable fast math for some sources where performance matters (or where the PCH must not be used.) (This would be good for rendering code, but unfortunately that is hopelessly intermingled with the playsim code in engine.cpp.)
set( FASTMATH_SOURCES
2020-04-10 20:17:29 +00:00
common/rendering/gl_load/gl_load.c
2019-09-22 21:15:46 +00:00
# This should better be made a library subproject later, once things are working.
libsmackerdec/src/BitReader.cpp
libsmackerdec/src/FileStream.cpp
libsmackerdec/src/HuffmanVLC.cpp
libsmackerdec/src/LogError.cpp
libsmackerdec/src/SmackerDecoder.cpp
2020-04-11 21:50:43 +00:00
common/utility/matrix.cpp
2019-09-22 21:15:46 +00:00
# The rest is only here because it is C, not C++
2020-01-06 01:41:47 +00:00
2019-11-02 11:59:59 +00:00
gitinfo.cpp
2019-09-22 21:15:46 +00:00
)
set (PCH_SOURCES
2019-11-26 20:25:45 +00:00
2019-09-22 21:15:46 +00:00
glbackend/gl_hwtexture.cpp
glbackend/gl_samplers.cpp
2019-10-05 10:28:08 +00:00
glbackend/gl_shader.cpp
2019-09-22 21:15:46 +00:00
glbackend/glbackend.cpp
2019-10-06 19:15:53 +00:00
glbackend/gl_palmanager.cpp
2019-10-20 06:04:54 +00:00
glbackend/gl_texture.cpp
2019-11-05 22:35:38 +00:00
glbackend/hw_draw2d.cpp
2020-01-06 01:41:47 +00:00
2019-11-01 23:38:30 +00:00
thirdparty/src/base64.cpp
2019-09-22 21:15:46 +00:00
thirdparty/src/fix16.cpp
thirdparty/src/md4.cpp
2019-10-20 07:16:01 +00:00
thirdparty/src/enet.cpp
2020-01-06 01:41:47 +00:00
2019-09-22 21:15:46 +00:00
# Todo: Split out the license-safe code from this.
build/src/animvpx.cpp
build/src/clip.cpp
build/src/common.cpp
build/src/defs.cpp
build/src/engine.cpp
build/src/hash.cpp
build/src/hightile.cpp
build/src/mdsprite.cpp
build/src/mhk.cpp
build/src/palette.cpp
build/src/polymost.cpp
build/src/pragmas.cpp
build/src/scriptfile.cpp
build/src/timer.cpp
build/src/voxmodel.cpp
2020-01-06 01:41:47 +00:00
2020-04-11 21:38:30 +00:00
core/animlib.cpp
core/rts.cpp
core/gameconfigfile.cpp
core/gamecvars.cpp
core/gamecontrol.cpp
core/inputstate.cpp
core/searchpaths.cpp
core/initfs.cpp
core/statistics.cpp
core/secrets.cpp
core/compositesavegame.cpp
core/savegamehelp.cpp
core/quotes.cpp
core/screenshot.cpp
2020-04-12 06:07:48 +00:00
core/raze_music.cpp
2020-04-12 06:09:38 +00:00
core/raze_sound.cpp
2020-04-11 21:38:30 +00:00
core/2d/v_2ddrawer.cpp
core/2d/v_draw.cpp
core/2d/v_drawtext.cpp
core/2d/screentext.cpp
core/fonts/font.cpp
core/fonts/hexfont.cpp
core/fonts/singlelumpfont.cpp
core/fonts/v_font.cpp
core/fonts/v_text.cpp
core/console/c_console.cpp
core/console/d_event.cpp
2020-04-12 06:19:19 +00:00
common/audio/sound/i_sound.cpp
common/audio/sound/oalsound.cpp
common/audio/sound/s_environment.cpp
common/audio/sound/s_sound.cpp
2020-04-12 06:08:31 +00:00
common/audio/music/music_midi_base.cpp
common/audio/music/music.cpp
common/audio/music/i_music.cpp
common/audio/music/i_soundfont.cpp
common/audio/music/music_config.cpp
2020-04-11 21:50:43 +00:00
common/thirdparty/sfmt/SFMT.cpp
2020-04-12 05:46:53 +00:00
common/textures/animtexture.cpp
2020-04-11 22:04:02 +00:00
common/textures/bitmap.cpp
2020-04-11 22:17:01 +00:00
common/textures/m_png.cpp
2020-05-23 21:53:38 +00:00
common/textures/image.cpp
2020-05-24 14:11:10 +00:00
common/textures/texturemanager.cpp
2020-05-24 14:32:52 +00:00
common/textures/formats/fontchars.cpp
2020-05-23 22:15:38 +00:00
common/textures/formats/automaptexture.cpp
common/textures/formats/brightmaptexture.cpp
common/textures/formats/buildtexture.cpp
2020-05-23 21:53:38 +00:00
common/textures/formats/ddstexture.cpp
2020-05-23 22:15:38 +00:00
common/textures/formats/flattexture.cpp
common/textures/formats/imgztexture.cpp
2020-05-23 21:53:38 +00:00
common/textures/formats/jpegtexture.cpp
2020-05-23 22:15:38 +00:00
common/textures/formats/md5check.cpp
common/textures/formats/multipatchtexture.cpp
common/textures/formats/patchtexture.cpp
2020-05-23 21:53:38 +00:00
common/textures/formats/pcxtexture.cpp
common/textures/formats/pngtexture.cpp
2020-05-23 22:15:38 +00:00
common/textures/formats/rawpagetexture.cpp
common/textures/formats/emptytexture.cpp
common/textures/formats/shadertexture.cpp
2020-05-23 21:53:38 +00:00
common/textures/formats/tgatexture.cpp
common/textures/formats/stbtexture.cpp
2020-04-11 22:11:50 +00:00
common/console/c_commandline.cpp
common/console/c_buttons.cpp
common/console/c_bind.cpp
common/console/c_enginecmds.cpp
common/console/c_consolebuffer.cpp
common/console/c_cvars.cpp
common/console/c_dispatch.cpp
common/console/c_expr.cpp
2020-04-11 21:50:43 +00:00
common/utility/engineerrors.cpp
common/utility/i_module.cpp
common/utility/m_alloc.cpp
common/utility/utf8.cpp
common/utility/palette.cpp
common/utility/files.cpp
common/utility/files_decompress.cpp
common/utility/memarena.cpp
common/utility/cmdlib.cpp
common/utility/configfile.cpp
common/utility/i_time.cpp
common/utility/m_argv.cpp
common/utility/s_playlist.cpp
common/utility/zstrformat.cpp
2020-04-11 22:04:02 +00:00
common/utility/name.cpp
2020-04-11 21:50:43 +00:00
common/thirdparty/md5.cpp
common/thirdparty/superfasthash.cpp
2020-04-11 21:54:33 +00:00
common/filesystem/filesystem.cpp
common/filesystem/ancientzip.cpp
common/filesystem/file_7z.cpp
common/filesystem/file_grp.cpp
common/filesystem/file_lump.cpp
common/filesystem/file_rff.cpp
common/filesystem/file_wad.cpp
common/filesystem/file_zip.cpp
common/filesystem/file_pak.cpp
common/filesystem/file_whres.cpp
common/filesystem/file_directory.cpp
common/filesystem/resourcefile.cpp
2020-04-08 16:53:47 +00:00
common/engine/stats.cpp
2020-04-11 22:04:02 +00:00
common/engine/sc_man.cpp
2020-04-11 22:18:12 +00:00
common/engine/palettecontainer.cpp
2020-04-11 22:11:50 +00:00
common/engine/stringtable.cpp
2020-04-12 06:21:50 +00:00
common/engine/i_interface.cpp
common/engine/renderstyle.cpp
common/engine/v_colortables.cpp
2020-04-07 16:04:35 +00:00
common/engine/serializer.cpp
2020-04-07 18:14:24 +00:00
common/engine/m_random.cpp
2020-04-06 14:10:54 +00:00
common/objects/dobject.cpp
common/objects/dobjgc.cpp
common/objects/dobjtype.cpp
2020-04-10 20:17:29 +00:00
common/rendering/gl_load/gl_interface.cpp
2020-04-07 16:04:35 +00:00
common/scripting/core/dictionary.cpp
2020-04-07 18:14:24 +00:00
common/scripting/core/dynarrays.cpp
2020-04-06 19:10:07 +00:00
common/scripting/core/symbols.cpp
common/scripting/core/types.cpp
common/scripting/core/scopebarrier.cpp
common/scripting/core/vmdisasm.cpp
2020-04-07 22:19:49 +00:00
common/scripting/core/imports.cpp
2020-04-06 19:10:07 +00:00
common/scripting/vm/vmexec.cpp
common/scripting/vm/vmframe.cpp
common/scripting/interface/stringformat.cpp
2020-04-07 22:19:49 +00:00
#common/scripting/interface/exports.cpp
common/scripting/frontend/ast.cpp
common/scripting/frontend/zcc_compile.cpp
common/scripting/frontend/zcc_parser.cpp
2020-04-07 18:14:24 +00:00
common/scripting/backend/vmbuilder.cpp
common/scripting/backend/codegen.cpp
2020-04-11 21:50:43 +00:00
2020-04-08 16:53:47 +00:00
2020-04-11 21:38:30 +00:00
core/textures/buildtiles.cpp
core/textures/texture.cpp
core/textures/imagetexture.cpp
core/textures/imagehelpers.cpp
core/music/s_advsound.cpp
core/menu/imagescroller.cpp
core/menu/joystickmenu.cpp
core/menu/listmenu.cpp
core/menu/savegamemanager.cpp
core/menu/loadsavemenu.cpp
core/menu/menu.cpp
core/menu/menudef.cpp
core/menu/menuinput.cpp
core/menu/messagebox.cpp
core/menu/optionmenu.cpp
core/menu/resolutionmenu.cpp
#core/input/i_joystick.cpp
#core/input/i_input.cpp
core/input/m_joy.cpp
core/rendering/r_videoscale.cpp
core/rendering/v_framebuffer.cpp
core/rendering/v_video.cpp
core/rendering/gl/renderer/gl_renderer.cpp
core/rendering/gl/renderer/gl_postprocess.cpp
core/rendering/gl/renderer/gl_postprocessstate.cpp
core/rendering/gl/renderer/gl_renderbuffers.cpp
core/rendering/gl/shaders/gl_shaderprogram.cpp
core/rendering/gl/system/gl_buffers.cpp
core/rendering/gl/system/gl_debug.cpp
core/rendering/gl/system/gl_framebuffer.cpp
core/rendering/hwrenderer/data/flatvertices.cpp
core/rendering/hwrenderer/postprocessing/hw_postprocess.cpp
core/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
core/rendering/hwrenderer/utility/hw_shaderpatcher.cpp
2019-09-22 21:15:46 +00:00
)
2020-04-06 21:32:29 +00:00
if( ${HAVE_VM_JIT} )
set( PCH_SOURCES ${PCH_SOURCES} ${VM_JIT_SOURCES} )
else()
set( NOT_COMPILED_SOURCE_FILES ${NOT_COMPILED_SOURCE_FILES} ${VM_JIT_SOURCES} )
endif()
2020-01-27 11:45:19 +00:00
macro( use_precompiled_header )
if( MSVC )
enable_precompiled_headers( "${ARGV0}/g_pch.h" PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
endmacro()
use_precompiled_header(".")
2019-09-22 21:15:46 +00:00
2019-12-27 12:52:15 +00:00
add_executable( ${PROJECT_NAME} WIN32 MACOSX_BUNDLE
2019-09-22 21:15:46 +00:00
${HEADER_FILES}
${NOT_COMPILED_SOURCE_FILES}
2020-04-06 14:10:54 +00:00
common/objects/__autostart.cpp
2019-09-22 21:15:46 +00:00
${SYSTEM_SOURCES}
${FASTMATH_SOURCES}
${PCH_SOURCES}
2020-04-11 21:50:43 +00:00
common/utility/x86.cpp
common/thirdparty/strnatcmp.c
common/utility/zstring.cpp
common/utility/findfile.cpp
common/thirdparty/math/asin.c
common/thirdparty/math/atan.c
common/thirdparty/math/const.c
common/thirdparty/math/cosh.c
common/thirdparty/math/exp.c
common/thirdparty/math/isnan.c
common/thirdparty/math/log.c
common/thirdparty/math/log10.c
common/thirdparty/math/mtherr.c
common/thirdparty/math/polevl.c
common/thirdparty/math/pow.c
common/thirdparty/math/powi.c
common/thirdparty/math/sin.c
common/thirdparty/math/sinh.c
common/thirdparty/math/sqrt.c
common/thirdparty/math/tan.c
common/thirdparty/math/tanh.c
common/thirdparty/math/fastsin.cpp
2020-04-06 14:10:54 +00:00
common/objects/zzautozend.cpp
2019-09-22 21:15:46 +00:00
)
2019-12-02 01:07:32 +00:00
#set_source_files_properties( ${FASTMATH_SOURCES} PROPERTIES COMPILE_FLAGS ${DEM_FASTMATH_FLAG} )
2019-09-22 21:15:46 +00:00
set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" )
2020-04-11 22:04:02 +00:00
set_source_files_properties( common/engine/sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" )
2019-09-22 21:15:46 +00:00
set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
# [BL] Solaris requires these to be explicitly linked.
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} nsl socket)
2019-09-22 21:15:46 +00:00
endif()
if( UNIX )
find_package( Backtrace )
if(Backtrace_FOUND)
2019-12-27 12:37:39 +00:00
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${Backtrace_LIBRARIES} )
2019-09-22 21:15:46 +00:00
endif()
endif()
2020-02-09 12:26:51 +00:00
target_link_libraries( ${PROJECT_NAME} ${PROJECT_LIBRARIES} ${ZMUSIC_LIBRARIES} gdtoa lzma duke3d blood rr sw exhumed )
2019-09-22 21:15:46 +00:00
include_directories(
2019-11-02 11:59:59 +00:00
${CMAKE_CURRENT_SOURCE_DIR}
2019-09-22 21:15:46 +00:00
build/include
libxmp-lite/include
libxmp-lite/include/libxmp-lite
libsmackerdec/include
thirdparty/include
2019-11-07 19:31:16 +00:00
thirdparty/imgui
2020-04-11 21:38:30 +00:00
core
core/2d
core/fonts
core/utility
core/console
core/textures
core/music
core/dobject
core/menu
core/input
core/rendering/gl/system
core/rendering/gl/renderer
core/rendering/gl/shaders
core/rendering/hwrenderer/data
core/rendering/hwrenderer/postprocessing
core/rendering/hwrenderer/utility
core/rendering
2019-09-25 20:38:47 +00:00
platform
2020-04-12 06:19:19 +00:00
common/audio/sound
2020-04-12 06:08:31 +00:00
common/audio/music
2020-04-11 21:50:43 +00:00
common/thirdparty
2020-04-11 22:04:02 +00:00
common/textures
2020-05-23 22:15:38 +00:00
common/textures/formats
2020-04-11 21:54:33 +00:00
common/filesystem
2020-04-11 21:50:43 +00:00
common/utility
2020-04-11 22:11:50 +00:00
common/console
2020-04-11 22:04:02 +00:00
common/engine
2020-04-06 19:10:07 +00:00
common/objects
2020-04-10 20:17:29 +00:00
common/rendering
common/rendering/gl_load
2020-04-06 19:10:07 +00:00
common/scripting/vm
common/scripting/jit
2020-04-07 16:04:35 +00:00
common/scripting/core
2020-04-07 18:14:24 +00:00
common/scripting/interface
2020-04-07 22:19:49 +00:00
common/scripting/frontend
2020-04-07 18:14:24 +00:00
common/scripting/backend
2019-09-22 21:15:46 +00:00
${CMAKE_BINARY_DIR}/libraries/gdtoa
2019-09-23 06:40:02 +00:00
2020-01-07 00:11:19 +00:00
${SYSTEM_SOURCES_DIR}
2019-09-22 21:15:46 +00:00
)
2020-01-07 00:11:19 +00:00
if (NOT WIN32)
include_directories(platform/posix)
endif()
2019-12-27 12:52:15 +00:00
add_dependencies( ${PROJECT_NAME} revision_check )
2019-09-22 21:15:46 +00:00
# Due to some quirks, we need to do this in this order
2019-12-27 12:37:39 +00:00
if( NOT COMPILE_OUTPUT_OLDSTYLE )
2019-09-22 21:15:46 +00:00
# RUNTIME_OUTPUT_DIRECTORY does not exist in CMake 2.4.
# Linux distributions are slow to adopt 2.6. :(
2019-12-27 12:52:15 +00:00
set_target_properties( ${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${COMPILE_OUTPUT_DIECTRORY} )
set_target_properties( ${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} )
2019-09-22 21:15:46 +00:00
else()
2019-12-27 12:52:15 +00:00
set_target_properties( ${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_NAME ${PROJECT_NAME}
2019-12-27 12:37:39 +00:00
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${COMPILE_OUTPUT_DIECTRORY}
2019-12-27 12:52:15 +00:00
RUNTIME_OUTPUT_NAME_DEBUG ${PROJECT_NAME}d
2019-12-27 12:37:39 +00:00
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${COMPILE_OUTPUT_DIECTRORY}
2019-12-27 12:52:15 +00:00
RUNTIME_OUTPUT_NAME_MINSIZEREL ${PROJECT_NAME}msr
2019-12-27 12:37:39 +00:00
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${COMPILE_OUTPUT_DIECTRORY}
2019-12-27 12:52:15 +00:00
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${PROJECT_NAME}rd
2019-12-27 12:37:39 +00:00
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${COMPILE_OUTPUT_DIECTRORY}
2019-09-22 21:15:46 +00:00
)
endif()
if( MSVC )
2019-12-27 12:37:39 +00:00
option( COMPILE_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
2019-09-22 21:15:46 +00:00
set( LINKERSTUFF "/MANIFEST:NO" )
2019-12-27 12:37:39 +00:00
if( COMPILE_GENERATE_MAPFILE )
2019-09-22 21:15:46 +00:00
set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
endif()
2019-12-27 12:52:15 +00:00
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${LINKERSTUFF})
2019-09-22 21:15:46 +00:00
2019-12-27 12:52:15 +00:00
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\platform\\win32\\manifest.game.xml\" -outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"\;\#1
2019-09-22 21:15:46 +00:00
COMMENT "Adding manifest..."
)
endif()
if( NOT WIN32 AND NOT APPLE )
2019-12-27 12:52:15 +00:00
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${COMPILE_OUTPUT_DIECTRORY}/${PROJECT_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${COMPILE_OUTPUT_DIECTRORY}/${PROJECT_NAME}; fi" )
add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD
2019-09-22 21:15:46 +00:00
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make )
endif()
2020-02-07 20:36:37 +00:00
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/soundfont/${PROJECT_NAME}.sf2 $<TARGET_FILE_DIR:${PROJECT_NAME}>/soundfonts/${PROJECT_NAME}.sf2
)
2019-09-22 21:15:46 +00:00
if( CMAKE_COMPILER_IS_GNUCXX )
# GCC misoptimizes this file
endif()
if( APPLE )
set( LINK_FRAMEWORKS "-framework Cocoa -framework IOKit -framework OpenGL")
if( HAVE_VULKAN )
set( LINK_FRAMEWORKS "${LINK_FRAMEWORKS} -framework QuartzCore" )
endif()
2019-12-27 12:52:15 +00:00
set_target_properties(${PROJECT_NAME} PROPERTIES
2019-09-22 21:15:46 +00:00
LINK_FLAGS "${LINK_FRAMEWORKS}"
2020-01-26 14:38:13 +00:00
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/osx/${PROJECT_NAME}-info.plist"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" )
2019-09-22 21:15:46 +00:00
# Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen()
# if placed in the directory with the main executable
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath @executable_path" )
endif()
if( WIN32 )
2019-12-26 16:42:45 +00:00
set( INSTALL_PATH . CACHE STRING "Directory where the executable will be placed during install." )
2019-09-22 21:15:46 +00:00
else()
2019-12-26 16:42:45 +00:00
set( INSTALL_PATH bin CACHE STRING "Directory where the executable will be placed during install." )
2019-09-22 21:15:46 +00:00
endif()
2019-12-27 12:52:15 +00:00
install(TARGETS ${PROJECT_NAME}
2019-09-22 21:15:46 +00:00
DESTINATION ${INSTALL_PATH}
COMPONENT "Game executable")
2020-04-11 21:38:30 +00:00
source_group("Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/utility/.+")
source_group("Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/.+")
source_group("Core\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/textures/.+")
source_group("Core\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/textures/formats/.+")
source_group("Core\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/utility/.+")
source_group("Core\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/2d/.+")
source_group("Core\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/console/.+")
source_group("Core\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/fonts/.+")
source_group("Core\\DObject" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/dobject/.+")
source_group("Core\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/menu/.+")
source_group("Core\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/.+")
source_group("Core\\Rendering\\GL\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/gl/system.+")
2019-12-26 16:42:45 +00:00
source_group("Platform" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/.+")
source_group("Platform\\Win32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/win32/.+")
2020-01-26 14:40:43 +00:00
source_group("Platform\\POSIX" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/.+")
2020-04-11 21:50:43 +00:00
source_group("Common" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/.+")
2020-04-12 06:08:31 +00:00
source_group("Common\\Audio" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/audio/.+")
2020-04-12 06:19:19 +00:00
source_group("Common\\Audio\\Sound" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/audio/sound/.+")
source_group("Common\\Audio\\Sound\\Third-party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/audio/sound/thirdparty/.+")
2020-04-12 06:08:31 +00:00
source_group("Common\\Audio\\Music" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/audio/music.+")
2020-04-11 22:11:50 +00:00
source_group("Common\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/console/.+")
source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
2020-04-06 14:10:54 +00:00
source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/objects/.+")
source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
2020-04-11 22:11:50 +00:00
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
2020-04-06 19:10:07 +00:00
source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+")
2020-04-07 18:14:24 +00:00
source_group("Common\\Scripting\\Interface" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/interface/.+")
2020-04-07 22:19:49 +00:00
source_group("Common\\Scripting\\Frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/frontend/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.c ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.h)
2020-04-07 18:14:24 +00:00
source_group("Common\\Scripting\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/backend/.+")
2020-04-06 19:10:07 +00:00
source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/core/.+")
source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+")
2020-04-07 16:04:35 +00:00
source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+")
2020-04-10 20:17:29 +00:00
source_group("Common\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/.+")
source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl_load/.+")
2020-04-07 16:04:35 +00:00
source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+")
2020-05-23 21:53:38 +00:00
source_group("Common\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/formats.+")
2020-04-11 21:50:43 +00:00
source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+")
source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+")
source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+")
source_group("Common\\Third Party\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/sfmt/.+")
2019-09-22 21:15:46 +00:00
source_group("Utility\\Smackerdec" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/smackerdec/.+")
source_group("Utility\\Smackerdec\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libsmackerdec/include/.+")
source_group("Utility\\Smackerdec\\Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libsmackerdec/src/.+")
source_group("Utility\\XMP-Lite" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/.+")
source_group("Utility\\XMP-Lite Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/include/libxmp-lite/.+")
source_group("Utility\\XMP-Lite Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/src/.+")
source_group("Utility\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/.+")
source_group("Utility\\Third Party Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/.+")
source_group("Utility\\Third Party Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/src/.+")
2020-02-22 17:41:24 +00:00
source_group("Utility\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/rapidjson/.+")
2019-09-22 21:15:46 +00:00
source_group("OpenGL Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glbackend/.+")
source_group("Build Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/.+")
source_group("Build Engine\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/include/.+")
source_group("Build Engine\\Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/src/.+")
2020-01-27 11:45:19 +00:00
macro( add_game_library )
file( GLOB HEADER_FILES src/*.h )
if( NOT_COMPILED_SOURCE_FILES )
set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
endif()
use_precompiled_header("..")
add_library( ${ARGV0} STATIC
${PCH_SOURCES}
${HEADER_FILES}
${NOT_COMPILED_SOURCE_FILES}
)
endmacro()
require_stricmp()
require_strnicmp()
unset( PCH_SOURCES )
unset( HEADER_FILES )
unset( NOT_COMPILED_SOURCE_FILES )
add_subdirectory( duke3d )
add_subdirectory( blood )
add_subdirectory( rr )
add_subdirectory( sw )
add_subdirectory( exhumed )