Merge branch 'master' into powerslave

# Conflicts:
#	source/CMakeLists.txt
This commit is contained in:
Christoph Oelckers 2019-12-27 15:34:09 +01:00
commit 8e5b9111bd
5 changed files with 77 additions and 326 deletions

View file

@ -1,5 +1,6 @@
cmake_minimum_required( VERSION 3.1.0 )
project(Demolition)
set ( PROJECT_NAME "demolition")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -76,21 +77,21 @@ function( add_pk3 PK3_NAME PK3_DIR )
# Generate target name. Just use "pk3" for main pk3 target.
string( REPLACE "." "_" PK3_TARGET ${PK3_NAME} )
if( NOT DEMOLITION_OUTPUT_OLDSTYLE )
add_custom_command( OUTPUT ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME}
COMMAND zipdir -udf ${PK3_ZIPDIR_OPTIONS} ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME} $<TARGET_FILE_DIR:demolition>/${PK3_NAME}
if( NOT COMPILE_OUTPUT_OLDSTYLE )
add_custom_command( OUTPUT ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME}
COMMAND zipdir -udf ${PK3_ZIPDIR_OPTIONS} ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME} ${PK3_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME} $<TARGET_FILE_DIR:${PROJECT_NAME}>/${PK3_NAME}
DEPENDS zipdir )
else()
add_custom_command( OUTPUT ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME}
COMMAND zipdir -udf ${PK3_ZIPDIR_OPTIONS} ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR}
add_custom_command( OUTPUT ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME}
COMMAND zipdir -udf ${PK3_ZIPDIR_OPTIONS} ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
endif()
# Create a list of source files for this PK3, for use in the IDE
# Phase 1: Create a list of all source files for this PK3 archive, except
# for a couple of strife image file names that confuse CMake.
file(GLOB_RECURSE PK3_SRCS ${PK3_DIR}/*)
# Exclude from the source list some demolition .png files with brackets in the
# Exclude from the source list some files with brackets in the
# file names here, because they confuse CMake.
# This only affects the list of source files shown in the IDE.
# It does not actually remove the files from the PK3 archive.
@ -109,7 +110,7 @@ function( add_pk3 PK3_NAME PK3_DIR )
# rebuild each time since their dependency has "changed."
add_custom_target( ${PK3_TARGET} ALL
COMMAND ${CMAKE_COMMAND} -E touch $<TARGET_FILE:zipdir>
DEPENDS ${DEMOLITION_OUTPUT_DIR}/${PK3_NAME}
DEPENDS ${COMPILE_OUTPUT_DIECTRORY}/${PK3_NAME}
SOURCES ${PK3_SRCS})
# Phase 3: Assign source files to a nice folder structure in the IDE
assort_pk3_source_folder("Source Files" ${PK3_DIR})
@ -140,14 +141,14 @@ IF( NOT CMAKE_BUILD_TYPE )
FORCE )
ENDIF()
set( DEMOLITION_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where engine data and the executable will be created." )
set( DEMOLITION_EXE_NAME "demolition" CACHE FILEPATH "Name of the executable to create" )
set( COMPILE_OUTPUT_DIECTRORY ${CMAKE_BINARY_DIR} CACHE PATH "Directory where engine data and the executable will be created." )
set( COMPILE_EXE_NAME ${PROJECT_NAME} CACHE FILEPATH "Name of the executable to create" )
if( MSVC )
# Allow the user to use DEMOLITION_OUTPUT_DIR as a single release point.
# Use demolition, demolitiond, demolition64, and demolitiond64 for the binary names
option( DEMOLITION_OUTPUT_OLDSTYLE "Don't use Release/Debug directories." OFF )
# Allow the user to use COMPILE_OUTPUT_DIECTRORY as a single release point.
# Use different names for the various compile targets.
option( COMPILE_OUTPUT_OLDSTYLE "Don't use Release/Debug directories." OFF )
else()
set( DEMOLITION_OUTPUT_OLDSTYLE OFF )
set( COMPILE_OUTPUT_OLDSTYLE OFF )
endif()
# Replacement variables for a possible long list of C/C++ compilers compatible with GCC
@ -176,7 +177,7 @@ find_package( ZLIB )
include( TargetArch )
# Things for later. Currently we have no VM and no Vulkan
#if( ${DEMOLITION_TARGET_ARCH} MATCHES "x86_64" )
#if( ${TARGET_ARCHITECTURE} MATCHES "x86_64" )
# set( HAVE_VM_JIT ON )
# option (HAVE_VULKAN "Enable Vulkan support" ON)
#endif()
@ -208,8 +209,8 @@ if( MSVC )
# Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations.
option( DEMOLITION_GENERATE_ASM "Generate assembly output." OFF )
if( DEMOLITION_GENERATE_ASM )
option( COMPILE_GENERATE_ASM "Generate assembly output." OFF )
if( COMPILE_GENERATE_ASM )
set( REL_C_FLAGS "/MT /Oy /Oi /FAcs /GS-" )
else()
set( REL_C_FLAGS "/MT /Oy /Oi /GS-" )
@ -323,7 +324,7 @@ if( ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB )
message( STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIR}" )
else()
message( STATUS "Using internal zlib" )
set( SKIP_INSTALL_ALL TRUE ) # Avoid installing zlib alongside demolition
set( SKIP_INSTALL_ALL TRUE ) # Avoid installing zlib
add_subdirectory( libraries/zlib )
set( ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib )
set( ZLIB_LIBRARIES z )
@ -348,7 +349,7 @@ endif()
# message( STATUS "Using system asmjit, includes found at ${ASMJIT_INCLUDE_DIR}" )
# else()
# message( STATUS "Using internal asmjit" )
# set( SKIP_INSTALL_ALL TRUE ) # Avoid installing asmjit alongside demolition
# set( SKIP_INSTALL_ALL TRUE ) # Avoid installing asmjit
# add_subdirectory( libraries/asmjit )
# set( ASMJIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit )
# set( ASMJIT_LIBRARIES asmjit )
@ -393,7 +394,7 @@ endif()
#if( WIN32 )
# set( INSTALL_DOCS_PATH docs CACHE STRING "Directory where the documentation will be placed during install." )
#else()
# set( INSTALL_DOCS_PATH share/doc/${DEMOLITION_EXE_NAME} CACHE STRING "Directory where the demolition documentation will be placed during install." )
# set( INSTALL_DOCS_PATH share/doc/${COMPILE_EXE_NAME} CACHE STRING "Directory where the documentation will be placed during install." )
#endif()
#install(DIRECTORY docs/
# DESTINATION ${INSTALL_DOCS_PATH}

View file

@ -36,20 +36,20 @@ if( APPLE )
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
endif()
target_architecture(DEMOLITION_TARGET_ARCH)
message(STATUS "Architecture is ${DEMOLITION_TARGET_ARCH}")
target_architecture(TARGET_ARCHITECTURE)
message(STATUS "Architecture is ${TARGET_ARCHITECTURE}")
# Right now only 64 bit is supported.
if( ${DEMOLITION_TARGET_ARCH} MATCHES "x86_64" )
if( ${TARGET_ARCHITECTURE} MATCHES "x86_64" )
set( X64 64 )
endif()
if( X64 OR ${DEMOLITION_TARGET_ARCH} MATCHES "i386" )
if( X64 OR ${TARGET_ARCHITECTURE} MATCHES "i386" )
add_definitions( -DARCH_IA32 )
endif()
if( NOT DEMOLITION_LIBS )
set( DEMOLITION_LIBS "" )
if( NOT PROJECT_LIBRARIES )
set( PROJECT_LIBRARIES "" )
endif()
if( WIN32 )
@ -72,7 +72,7 @@ if( WIN32 )
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows/lib/32)
endif()
set( DEMOLITION_LIBS
set( PROJECT_LIBRARIES
opengl32
wsock32
winmm
@ -111,12 +111,12 @@ if( WIN32 )
if( NOT DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} DelayImp )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} DelayImp )
endif()
if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
if( DX_dxguid_LIBRARY )
list( APPEND DEMOLITION_LIBS "${DX_dxguid_LIBRARY}" )
list( APPEND PROJECT_LIBRARIES "${DX_dxguid_LIBRARY}" )
endif()
endif()
else()
@ -138,7 +138,7 @@ else()
pkg_check_modules( GTK3 gtk+-3.0 )
if( GTK3_FOUND )
if( NOT DYN_GTK )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${GTK3_LIBRARIES} )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${GTK3_LIBRARIES} )
endif()
include_directories( ${GTK3_INCLUDE_DIRS} )
link_directories( ${GTK3_LIBRARY_DIRS} )
@ -146,7 +146,7 @@ else()
pkg_check_modules( GTK2 gtk+-2.0 )
if( GTK2_FOUND )
if( NOT DYN_GTK )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${GTK2_LIBRARIES} )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${GTK2_LIBRARIES} )
endif()
include_directories( ${GTK2_INCLUDE_DIRS} )
link_directories( ${GTK2_LIBRARY_DIRS} )
@ -169,7 +169,7 @@ else()
if( NOT APPLE OR NOT OSX_COCOA_BACKEND )
find_package( SDL2 REQUIRED )
include_directories( "${SDL2_INCLUDE_DIR}" )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${SDL2_LIBRARY}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${SDL2_LIBRARY}" )
endif()
find_path( FPU_CONTROL_DIR fpu_control.h )
@ -187,7 +187,7 @@ if( NOT NO_OPENAL )
include_directories( ${OPENAL_INCLUDE_DIR} )
mark_as_advanced(CLEAR OPENAL_LIBRARY)
if( OPENAL_LIBRARY )
set( DEMOLITION_LIBS ${OPENAL_LIBRARY} ${DEMOLITION_LIBS} )
set( PROJECT_LIBRARIES ${OPENAL_LIBRARY} ${PROJECT_LIBRARIES} )
else()
set( NO_OPENAL ON )
endif()
@ -224,24 +224,17 @@ find_package( FluidSynth )
# Decide on SSE setup
set( SSE_MATTERS NO )
# with global use of SSE 2 we do not need special handling for selected files
if (NOT DEMOLITION_USE_SSE2)
# 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 )
# 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 )
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" )
set( SSE_MATTERS YES )
elseif( CAN_DO_ARCHSSE2 )
set( SSE1_ENABLE -arch:SSE )
set( SSE2_ENABLE -arch:SSE2 )
set( SSE_MATTERS YES )
endif()
endif()
endif()
if( X64 )
@ -416,7 +409,7 @@ if( UNIX )
add_definitions( -DNO_CLOCK_GETTIME )
endif()
else()
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} rt )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} rt )
endif()
endif()
@ -432,9 +425,9 @@ add_custom_target( revision_check ALL
# required libraries
message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
if (HAVE_VULKAN)
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "glslang" "SPIRV" "OGLCompiler")
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "glslang" "SPIRV" "OGLCompiler")
endif()
# Ugh... These precompiled dependencies need to go.
@ -448,20 +441,20 @@ endif()
if( ${HAVE_VM_JIT} )
add_definitions( -DHAVE_VM_JIT )
include_directories( "${ASMJIT_INCLUDE_DIR}" )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ASMJIT_LIBRARIES}")
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ASMJIT_LIBRARIES}")
endif()
if( SNDFILE_FOUND )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${SNDFILE_LIBRARIES}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${SNDFILE_LIBRARIES}" )
include_directories( "${SNDFILE_INCLUDE_DIRS}" )
endif()
if( MPG123_FOUND )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${MPG123_LIBRARIES}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${MPG123_LIBRARIES}" )
include_directories( "${MPG123_INCLUDE_DIR}" )
endif()
if( NOT DYN_FLUIDSYNTH )
if( FLUIDSYNTH_FOUND )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${FLUIDSYNTH_LIBRARIES}" )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${FLUIDSYNTH_LIBRARIES}" )
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
endif()
endif()
@ -533,7 +526,7 @@ elseif( APPLE )
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} )
##set_source_files_properties( posix/osx/demolition.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
##set_source_files_properties( posix/osx/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
##set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
else()
#set( SYSTEM_SOURCES_DIR posix posix/sdl )
@ -637,7 +630,7 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h
common/utility/sc_man_scanner.re
platform/win32/demolition.natvis
platform/win32/zutil.natvis
)
@ -836,7 +829,7 @@ else()
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
add_executable( demolition WIN32 MACOSX_BUNDLE
add_executable( ${PROJECT_NAME} WIN32 MACOSX_BUNDLE
${HEADER_FILES}
${NOT_COMPILED_SOURCE_FILES}
#__autostart.cpp
@ -856,17 +849,17 @@ set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
# [BL] Solaris requires these to be explicitly linked.
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} nsl socket)
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} nsl socket)
endif()
if( UNIX )
find_package( Backtrace )
if(Backtrace_FOUND)
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${Backtrace_LIBRARIES} )
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${Backtrace_LIBRARIES} )
endif()
endif()
target_link_libraries( demolition ${DEMOLITION_LIBS} gdtoa lzma duke3d blood rr sw exhumed zmusic )
target_link_libraries( ${PROJECT_NAME} ${PROJECT_LIBRARIES} gdtoa lzma duke3d blood rr sw exhumed zmusic )
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
@ -900,71 +893,63 @@ include_directories(
#${SYSTEM_SOURCES_DIR}
)
add_dependencies( demolition revision_check )
add_dependencies( ${PROJECT_NAME} revision_check )
# Due to some quirks, we need to do this in this order
if( NOT DEMOLITION_OUTPUT_OLDSTYLE )
if( NOT COMPILE_OUTPUT_OLDSTYLE )
# RUNTIME_OUTPUT_DIRECTORY does not exist in CMake 2.4.
# Linux distributions are slow to adopt 2.6. :(
set_target_properties( demolition PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${DEMOLITION_OUTPUT_DIR} )
set_target_properties( demolition PROPERTIES OUTPUT_NAME ${DEMOLITION_EXE_NAME} )
set_target_properties( ${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${COMPILE_OUTPUT_DIECTRORY} )
set_target_properties( ${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} )
else()
set_target_properties( demolition PROPERTIES
RUNTIME_OUTPUT_NAME ${DEMOLITION_EXE_NAME}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${DEMOLITION_OUTPUT_DIR}
RUNTIME_OUTPUT_NAME_DEBUG ${DEMOLITION_EXE_NAME}d
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${DEMOLITION_OUTPUT_DIR}
RUNTIME_OUTPUT_NAME_MINSIZEREL ${DEMOLITION_EXE_NAME}msr
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${DEMOLITION_OUTPUT_DIR}
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${DEMOLITION_EXE_NAME}rd
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${DEMOLITION_OUTPUT_DIR}
set_target_properties( ${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_NAME ${PROJECT_NAME}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${COMPILE_OUTPUT_DIECTRORY}
RUNTIME_OUTPUT_NAME_DEBUG ${PROJECT_NAME}d
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${COMPILE_OUTPUT_DIECTRORY}
RUNTIME_OUTPUT_NAME_MINSIZEREL ${PROJECT_NAME}msr
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${COMPILE_OUTPUT_DIECTRORY}
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${PROJECT_NAME}rd
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${COMPILE_OUTPUT_DIECTRORY}
)
endif()
if( MSVC )
option( DEMOLITION_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
option( COMPILE_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
set( LINKERSTUFF "/MANIFEST:NO" )
if( DEMOLITION_GENERATE_MAPFILE )
if( COMPILE_GENERATE_MAPFILE )
set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
endif()
set_target_properties(demolition PROPERTIES LINK_FLAGS ${LINKERSTUFF})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${LINKERSTUFF})
add_custom_command(TARGET demolition POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\platform\\win32\\manifest.game.xml\" -outputresource:\"$<TARGET_FILE:demolition>\"\;\#1
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
COMMENT "Adding manifest..."
)
endif()
if( NOT WIN32 AND NOT APPLE )
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${DEMOLITION_OUTPUT_DIR}/${DEMOLITION_EXE_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${DEMOLITION_EXE_NAME} ${DEMOLITION_OUTPUT_DIR}/${DEMOLITION_EXE_NAME}; fi" )
add_custom_command( TARGET demolition POST_BUILD
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
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make )
endif()
#add_custom_command(TARGET demolition POST_BUILD
#add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_SOURCE_DIR}/soundfont/gdemolition.sf2 $<TARGET_FILE_DIR:demolition>/soundfonts/gdemolition.sf2
# ${CMAKE_SOURCE_DIR}/soundfont/${PROJECT_NAME}.sf2 $<TARGET_FILE_DIR:${PROJECT_NAME}>/soundfonts/${PROJECT_NAME}.sf2
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_SOURCE_DIR}/fm_banks/GENMIDI.GS.wopl $<TARGET_FILE_DIR:demolition>/fm_banks/GENMIDI.GS.wopl
# ${CMAKE_SOURCE_DIR}/fm_banks/GENMIDI.GS.wopl $<TARGET_FILE_DIR:${PROJECT_NAME}>/fm_banks/GENMIDI.GS.wopl
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_SOURCE_DIR}/fm_banks/gs-by-papiezak-and-sneakernets.wopn $<TARGET_FILE_DIR:demolition>/fm_banks/gs-by-papiezak-and-sneakernets.wopn
# ${CMAKE_SOURCE_DIR}/fm_banks/gs-by-papiezak-and-sneakernets.wopn $<TARGET_FILE_DIR:${PROJECT_NAME}>/fm_banks/gs-by-papiezak-and-sneakernets.wopn
#)
if( CMAKE_COMPILER_IS_GNUCXX )
# GCC misoptimizes this file
#set_source_files_properties( oplsynth/fmopl.cpp PROPERTIES COMPILE_FLAGS "-fno-tree-dominator-opts -fno-tree-fre" )
endif()
#if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
# Need to enable intrinsics for these files.
# if( SSE_MATTERS )
# set_source_files_properties(
# utility/x86.cpp
# PROPERTIES COMPILE_FLAGS "-msse2 -mmmx" )
# endif()
#endif()
if( APPLE )
set( LINK_FRAMEWORKS "-framework Cocoa -framework IOKit -framework OpenGL")
@ -973,9 +958,9 @@ if( APPLE )
set( LINK_FRAMEWORKS "${LINK_FRAMEWORKS} -framework QuartzCore" )
endif()
set_target_properties(demolition PROPERTIES
set_target_properties(${PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FRAMEWORKS}"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/demolition-info.plist" )
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/${PROJECT_NAME}-info.plist" )
# Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen()
# if placed in the directory with the main executable
@ -987,7 +972,7 @@ if( WIN32 )
else()
set( INSTALL_PATH bin CACHE STRING "Directory where the executable will be placed during install." )
endif()
install(TARGETS demolition
install(TARGETS ${PROJECT_NAME}
DESTINATION ${INSTALL_PATH}
COMPONENT "Game executable")

View file

@ -1,235 +0,0 @@
#include "zstring.h"
#include "gameconfigfile.h"
#include "gamecontrol.h"
#include "resourcefile.h"
#include "sc_man.h"
#include "i_specialpaths.h"
#include "inputstate.h"
#include "c_cvars.h"
#include "../../glbackend/glbackend.h"
// Currently there is no global state for the current game. This is a temporary workaround because the video init code needs to do a few things based on the active game.
FString currentGame;
namespace Duke
{
extern GameInterface Interface;
}
namespace Redneck
{
extern GameInterface Interface;
}
namespace Blood
{
extern GameInterface Interface;
}
namespace ShadowWarrior
{
extern GameInterface Interface;
}
GameInterface *CheckFrontend()
{
FILE* f = fopen("blood.rff", "rb");
if (f)
{
currentGame = "Blood";
fclose(f);
return &Blood::Interface;
}
else
{
f = fopen("redneck.grp", "rb");
if (f)
{
currentGame = "Redneck";
fseek(f, 0, SEEK_END);
auto pos = ftell(f);
// Quick hack to distinguish these two. This won't survive until production but for testing it's sufficient.
if (pos > 190'000'000) currentGame = "RedneckRides";
fclose(f);
return &Redneck::Interface;
}
else
{
f = fopen("sw.grp", "rb");
if (f)
{
currentGame = "ShadowWarrior";
fclose(f);
return &ShadowWarrior::Interface;
}
f = fopen("fury.grp", "rb");
if (f)
{
currentGame = "IonFury";
fclose(f);
return &Duke::Interface;
}
f = fopen("nam.grp", "rb");
if (f)
{
currentGame = "Nam";
fclose(f);
return &Duke::Interface;
}
f = fopen("ww2gi.grp", "rb");
if (f)
{
currentGame = "WW2GI";
fclose(f);
return &Duke::Interface;
}
else
{
currentGame = "Duke";
}
return &Duke::Interface;
}
}
}
void ChooseGame()
{
auto dir = Args->CheckValue("-game");
if (dir && !chdir(dir))
{
gi = CheckFrontend();
return;
}
TArray<FString> paths;
std::vector<std::wstring> wgames;
TArray<TASKDIALOG_BUTTON> buttons;
char* token;
FileReader fr;
if (fr.OpenFile("./games.list"))
{
auto filedata = fr.ReadPadded(1);
auto script = scriptfile_fromstring((char*)filedata.Data());
int id = 1000;
while (!scriptfile_eof(script))
{
scriptfile_getstring(script, &token);
if (scriptfile_eof(script))
{
break;
}
FString game = token;
scriptfile_getstring(script, &token);
paths.Push(token);
FStringf display("%s\n%s", game.GetChars(), token);
wgames.push_back(display.WideString());
buttons.Push({ id++, wgames.back().c_str() });
}
}
if (paths.Size() == 0)
{
exit(1);
}
int nResult = 0;
TASKDIALOGCONFIG stTaskConfig;
ZeroMemory(&stTaskConfig, sizeof(stTaskConfig));
stTaskConfig.cbSize = sizeof(TASKDIALOGCONFIG);
stTaskConfig.hwndParent = NULL;
stTaskConfig.hInstance = NULL;
stTaskConfig.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION| TDF_USE_COMMAND_LINKS;
if (!gi)
{
// Open a popup to select the game.
// The entire startup code just doesn't work right if this isn't checked as the very first thing.
stTaskConfig.pszWindowTitle = L"Demolition";
stTaskConfig.pszMainInstruction = L"Choose your game";
stTaskConfig.pszContent = L"";
stTaskConfig.cButtons = buttons.Size();
stTaskConfig.pButtons = buttons.Data();
stTaskConfig.nDefaultButton = 1000;
if (SUCCEEDED(TaskDialogIndirect(&stTaskConfig, &nResult, NULL, NULL)))
{
if (nResult >= 1000 && nResult < 1000 +(int)buttons.Size())
{
nResult -= 1000;
chdir(paths[nResult]);
gi = CheckFrontend();
}
}
if (gi == nullptr) exit(1);
}
}
std::unique_ptr<FResourceFile> engine_res;
// The resourge manager in cache1d is far too broken to add some arbitrary file without some adjustment.
// For now, keep this file here, until the resource management can be redone in a more workable fashion.
extern FString progdir;
void InitBaseRes()
{
if (!engine_res)
{
// If we get here for the first time, load the engine-internal data.
FString baseres = progdir + "demolition.pk3";
engine_res.reset(FResourceFile::OpenResourceFile(baseres, true, true));
if (!engine_res)
{
I_Error("Engine resources (%s) not found", baseres.GetChars());
}
}
}
FileReader openFromBaseResource(const char* fn)
{
InitBaseRes();
auto lump = engine_res->FindLump(fn);
if (lump) return lump->NewReader();
// Also look in game filtered directories.
FStringf filtername("filter/game-%s/%s", currentGame.GetChars(), fn);
lump = engine_res->FindLump(filtername);
if (lump) return lump->NewReader();
return FileReader(nullptr);
}
int GameMain()
{
try
{
// Write to the DOCUMENTS directory, not the game directory
FString logpath = M_GetDocumentsPath() + "demolition.log";
OSD_SetLogFile(logpath);
CONFIG_ReadCombatMacros();
// Startup dialog must be presented here so that everything can be set up before reading the keybinds.
G_LoadConfig(currentGame);
CONFIG_Init();
r = gi->app_main(buildargc, (const char**)buildargv);
}
catch (const std::runtime_error & err)
{
wm_msgbox("Error", "%s", err.what());
return 3;
}
catch (const ExitEvent & exit)
{
// Just let the rest of the function execute.
r = exit.Reason();
}
}

View file

@ -24,7 +24,7 @@ BEGIN
//CONTROL "Load lights",IDC_WELCOME_LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,180,51,10
//CONTROL "Load brightmaps",IDC_WELCOME_BRIGHTMAPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,190,65,10
CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,73,211,87,10
DEFPUSHBUTTON "Play Demolition",IDOK,8,228,90,14
DEFPUSHBUTTON "Play!",IDOK,8,228,90,14
PUSHBUTTON "Exit",IDCANCEL,166,228,50,14
CONTROL "OpenGL",IDC_WELCOME_VULKAN1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,167,41,10
CONTROL "Vulkan",IDC_WELCOME_VULKAN2,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,13,177,37,10