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()
2019-10-16 21:09:02 +00:00
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
endif()
2019-09-22 21:15:46 +00:00
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
option( DYN_OPENAL "Dynamically load OpenAL" ON )
option( DYN_SNDFILE "Dynamically load libsndfile" ON )
option( DYN_MPG123 "Dynamically load libmpg123" ON )
if( APPLE )
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
endif()
2019-11-19 20:35:35 +00:00
target_architecture(DEMOLITION_TARGET_ARCH)
message(STATUS "Architecture is ${DEMOLITION_TARGET_ARCH}")
2019-10-17 18:29:58 +00:00
# Right now only 64 bit is supported.
2019-11-19 20:35:35 +00:00
if( ${DEMOLITION_TARGET_ARCH} MATCHES "x86_64" )
set( X64 64 )
endif()
2019-09-22 21:15:46 +00:00
2019-09-22 23:28:18 +00:00
if( X64 OR ${DEMOLITION_TARGET_ARCH} MATCHES "i386" )
2019-09-22 21:15:46 +00:00
add_definitions( -DARCH_IA32 )
endif()
2019-09-22 23:28:18 +00:00
if( NOT DEMOLITION_LIBS )
set( DEMOLITION_LIBS "" )
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
if( X64 )
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows/lib/64)
else()
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows/lib/32)
endif()
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS
2019-09-22 21:15:46 +00:00
opengl32
wsock32
winmm
"${DX_dinput8_LIBRARY}"
ole32
user32
gdi32
comctl32
comdlg32
ws2_32
setupapi
oleaut32
dbghelp
legacy_stdio_definitions
shlwapi
version
imm32
dxguid
dsound
winspool
advapi32
shell32
SetupAPI
uuid
odbc32
odbccp32
libSDL2main
libSDL2
# this local library crap needs to go away. The Ogg/Vorbis libraries are easy to replace with libsndfile but there doesn't seem to be anything to get a working libvpx that doesn't force linking with MinGW dependencies.
libogg
libvorbis
libvorbisfile
libvpx
libcompat-to-msvc
)
2019-09-22 23:28:18 +00:00
if( NOT DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} 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-09-22 23:28:18 +00:00
list( APPEND DEMOLITION_LIBS "${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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${OPENAL_LIBRARY} ${DEMOLITION_LIBS} )
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 )
set(MPG123_FOUND NO)
set(SNDFILE_FOUND NO)
else()
# Search for libSndFile
if ( NOT DYN_SNDFILE )
find_package( SndFile )
endif()
# Search for libmpg123
if ( NOT DYN_MPG123 )
find_package( MPG123 )
endif()
endif()
# Search for FluidSynth
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
2019-09-22 23:28:18 +00:00
if (NOT DEMOLITION_USE_SSE2)
2019-09-22 21:15:46 +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 )
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 )
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()
set( REL_CXX_FLAGS "-fno-rtti" )
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
CHECK_CXX_SOURCE_COMPILES("thread_local int i; int main() { i = 0; }"
HAVE_THREAD_LOCAL)
if( NOT HAVE_THREAD_LOCAL )
message( SEND_ERROR "C++ compiler doesn't support thread_local storage duration specifier" )
endif()
# 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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} rt )
2019-09-22 21:15:46 +00:00
endif()
endif()
# Flags
# Update gitinfo.h
add_custom_target( revision_check ALL
2019-09-22 21:55:45 +00:00
COMMAND updaterevision source/gitinfo.h
2019-09-22 21:15:46 +00:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS updaterevision )
2019-09-22 23:28:18 +00:00
# Libraries Demolition needs
2019-09-22 21:15:46 +00:00
message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
2019-09-22 21:15:46 +00:00
if (HAVE_VULKAN)
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "glslang" "SPIRV" "OGLCompiler")
2019-09-22 21:15:46 +00:00
endif()
# Ugh... These precompiled dependencies need to go.
if (WIN32)
2019-11-10 22:58:51 +00:00
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/sdl2")
2019-09-22 21:15:46 +00:00
else ()
2019-11-10 22:58:51 +00:00
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
endif()
if( ${HAVE_VM_JIT} )
add_definitions( -DHAVE_VM_JIT )
include_directories( "${ASMJIT_INCLUDE_DIR}" )
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${ASMJIT_LIBRARIES}")
2019-09-22 21:15:46 +00:00
endif()
if( SNDFILE_FOUND )
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${SNDFILE_LIBRARIES}" )
2019-09-22 21:15:46 +00:00
include_directories( "${SNDFILE_INCLUDE_DIRS}" )
endif()
if( MPG123_FOUND )
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${MPG123_LIBRARIES}" )
2019-09-22 21:15:46 +00:00
include_directories( "${MPG123_INCLUDE_DIR}" )
endif()
if( NOT DYN_FLUIDSYNTH )
if( FLUIDSYNTH_FOUND )
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} "${FLUIDSYNTH_LIBRARIES}" )
2019-09-22 21:15:46 +00:00
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
endif()
endif()
2019-09-22 23:28:18 +00:00
# Start defining source files for Demolition
2019-09-22 21:15:46 +00:00
set( PLAT_WIN32_SOURCES
audiolib/src/driver_directsound.cpp
glad/src/glad_wgl.c
2019-09-25 20:38:47 +00:00
platform/win32/winbits.cpp
2019-10-21 19:36:05 +00:00
platform/win32/i_specialpaths.cpp
2019-10-31 22:25:21 +00:00
platform/win32/startwin.game.cpp
2019-09-22 21:15:46 +00:00
# This needs a rework anyway in order to consolidate the startup dialogs so don't bother to sort in properly.
#startosx.game.mm
2019-10-09 17:58:09 +00:00
#sw/src/startgtk.game.cpp
2019-09-22 21:15:46 +00:00
)
set( PLAT_POSIX_SOURCES
2019-10-24 18:28:46 +00:00
#audiolib/src/driver_sdl.cpp
#audiolib/src/sdlmusic.cpp
2019-10-31 22:25:21 +00:00
#platform/gtk/startgtk.game.cpp
2019-09-22 21:15:46 +00:00
)
set( PLAT_SDL_SOURCES
)
set( PLAT_UNIX_SOURCES
2019-09-25 20:43:06 +00:00
platform/gtk/dynamicgtk.cpp
platform/gtk/gtkbits.cpp
2019-10-21 19:36:05 +00:00
platform/unix/i_specialpaths.cpp
2019-09-22 21:15:46 +00:00
)
set( PLAT_OSX_SOURCES
2019-09-25 20:43:06 +00:00
platform/macos/SDLMain.mm
platform/macos/osxbits.mm
2019-10-21 19:36:05 +00:00
platform/macos/i_specialpaths.mm
2019-09-22 21:15:46 +00:00
)
set( PLAT_COCOA_SOURCES
2019-10-31 22:25:21 +00:00
#platform/macos/startosx.game.mm
#platform/macos/GrpFile.game.mm
#platform/macos/GameListSource.game.mm
2019-09-22 21:15:46 +00:00
)
if( WIN32 )
#set( SYSTEM_SOURCES_DIR win32 )
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 )
#set( SYSTEM_SOURCES_DIR posix posix/cocoa )
set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
else()
#set( SYSTEM_SOURCES_DIR posix posix/sdl )
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} )
##set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} posix/sdl/i_system.mm )
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} )
2019-09-22 23:28:18 +00:00
##set_source_files_properties( posix/osx/demolition.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
2019-09-22 21:15:46 +00:00
##set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
else()
#set( SYSTEM_SOURCES_DIR posix posix/sdl )
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()
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h
2019-10-23 23:20:58 +00:00
COMMAND re2c --no-generation-date -s -o ${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h ${CMAKE_CURRENT_SOURCE_DIR}/common/utility/sc_man_scanner.re
DEPENDS re2c ${CMAKE_CURRENT_SOURCE_DIR}/common/utility/sc_man_scanner.re )
2019-09-22 21:15:46 +00:00
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
if( DYN_SNDFILE)
add_definitions( -DHAVE_SNDFILE -DDYN_SNDFILE )
elseif( SNDFILE_FOUND )
add_definitions( -DHAVE_SNDFILE )
endif()
if( DYN_MPG123)
add_definitions( -DHAVE_MPG123 -DDYN_MPG123 )
elseif( MPG123_FOUND )
add_definitions( -DHAVE_MPG123 )
endif()
if( DYN_FLUIDSYNTH )
add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH )
elseif( FLUIDSYNTH_FOUND )
add_definitions( -DHAVE_FLUIDSYNTH )
endif()
#option( SEND_ANON_STATS "Enable sending of anonymous hardware statistics" ON )
#if( NOT SEND_ANON_STATS )
# add_definitions( -DNO_SEND_STATS )
#endif()
# Disable ADLMIDI's and OPNMIDI's MIDI Sequencer
add_definitions(-DADLMIDI_DISABLE_MIDI_SEQUENCER)
add_definitions(-DOPNMIDI_DISABLE_MIDI_SEQUENCER)
# Disable OPNMIDI's experimental yet emulator (using of it has some issues and missing notes in playback)
add_definitions(-DOPNMIDI_DISABLE_GX_EMULATOR)
# 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
audiolib/include/*.h
audiolib/src/*.h
build/include/*.h
glad/include/glad/*.h
glad/include/Khr/*.h
glbackend/*.h
libsmackerdec/include/*.h
libxmp-lite/include/libxmp-lite/*.h
libxmp-lite/src/*.h
mact/include/*.h
mact/src/*.h
2019-10-05 11:38:02 +00:00
common/*.h
2019-10-23 20:51:11 +00:00
common/2d/*.h
2019-10-23 23:20:58 +00:00
common/fonts/*.h
2019-10-05 11:38:02 +00:00
common/utility/*.h
2019-10-21 20:39:26 +00:00
common/console/*.h
2019-10-28 22:46:15 +00:00
common/filesystem/*.h
2019-11-10 22:58:51 +00:00
common/music/*.h
2019-11-08 22:02:52 +00:00
common/menu/*.h
2019-09-22 21:15:46 +00:00
build/src/*.h
thirdparty/include/*.h
thirdparty/include/*.hpp
2019-11-07 19:31:16 +00:00
thirdparty/imgui/*.h
2019-10-05 17:28:05 +00:00
common/textures/*.h
common/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}
build/src/sdlkeytrans.cpp
2019-10-23 23:20:58 +00:00
sc_man_scanner.h
common/utility/sc_man_scanner.re
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
# 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
# The rest is only here because it is C, not C++
glad/src/glad.c
2019-11-12 21:00:33 +00:00
common/utility/strnatcmp.c
2019-09-22 21:15:46 +00:00
# Another bit of cruft just to make S(hit)DL happy...
sdlappicon.cpp
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
audiolib/src/drivers.cpp
2019-10-24 18:28:46 +00:00
audiolib/src/driver_adlib.cpp
2019-09-22 21:15:46 +00:00
audiolib/src/driver_nosound.cpp
2019-10-24 18:28:46 +00:00
audiolib/src/driver_sdl.cpp
2019-10-24 19:02:07 +00:00
audiolib/src/driver_winmm.cpp
2019-09-22 21:15:46 +00:00
audiolib/src/formats.cpp
audiolib/src/fx_man.cpp
audiolib/src/gmtimbre.cpp
audiolib/src/midi.cpp
audiolib/src/mix.cpp
audiolib/src/mixst.cpp
audiolib/src/multivoc.cpp
audiolib/src/music.cpp
2019-10-24 18:28:46 +00:00
audiolib/src/opl3.cpp
2019-09-22 21:15:46 +00:00
audiolib/src/pitch.cpp
audiolib/src/vorbis.cpp
2019-10-24 18:28:46 +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/gl_buffers.cpp
glbackend/hw_draw2d.cpp
2019-09-22 21:15:46 +00:00
mact/src/animlib.cpp
mact/src/control.cpp
mact/src/joystick.cpp
2019-10-28 17:32:05 +00:00
mact/src/input.cpp
2019-09-22 21:15:46 +00:00
2019-11-01 23:38:30 +00:00
thirdparty/src/base64.cpp
2019-09-22 21:15:46 +00:00
thirdparty/src/sjson.cpp
thirdparty/src/fix16.cpp
thirdparty/src/fix16_str.cpp
thirdparty/src/md4.cpp
2019-10-20 07:16:01 +00:00
thirdparty/src/enet.cpp
2019-11-07 19:31:16 +00:00
thirdparty/imgui/imgui.cpp
thirdparty/imgui/imgui_demo.cpp
thirdparty/imgui/imgui_draw.cpp
thirdparty/imgui/imgui_impl_opengl3.cpp
thirdparty/imgui/imgui_impl_sdl.cpp
thirdparty/imgui/imgui_widgets.cpp
2019-09-22 21:15:46 +00:00
# Todo: Split out the license-safe code from this.
build/src/2d.cpp
build/src/a-c.cpp
build/src/animvpx.cpp
build/src/baselayer.cpp
build/src/cache1d.cpp
build/src/clip.cpp
build/src/colmatch.cpp
build/src/common.cpp
build/src/compat.cpp
build/src/defs.cpp
build/src/engine.cpp
build/src/glsurface.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/screenshot.cpp
build/src/scriptfile.cpp
build/src/sdlayer.cpp
build/src/smalltextfont.cpp
build/src/softsurface.cpp
build/src/textfont.cpp
build/src/tiles.cpp
build/src/timer.cpp
build/src/voxmodel.cpp
2019-10-20 17:13:44 +00:00
common/rts.cpp
2019-10-21 19:36:05 +00:00
common/gameconfigfile.cpp
2019-10-21 21:29:48 +00:00
common/gamecvars.cpp
2019-10-25 22:32:49 +00:00
common/gamecontrol.cpp
2019-10-28 05:47:49 +00:00
common/inputstate.cpp
2019-10-29 18:53:46 +00:00
common/searchpaths.cpp
2019-11-01 18:25:42 +00:00
common/initfs.cpp
2019-11-01 21:17:15 +00:00
common/openaudio.cpp
2019-11-09 18:15:03 +00:00
common/optionmenu/optionmenu.cpp
2019-11-12 21:00:33 +00:00
common/statistics.cpp
2019-11-12 22:23:22 +00:00
common/secrets.cpp
2019-11-14 20:07:43 +00:00
common/compositesavegame.cpp
common/savegamehelp.cpp
2019-10-23 20:51:11 +00:00
common/2d/v_2ddrawer.cpp
common/2d/v_draw.cpp
common/2d/v_drawtext.cpp
common/2d/renderstyle.cpp
2019-10-20 17:13:44 +00:00
2019-10-23 23:20:58 +00:00
common/fonts/font.cpp
common/fonts/hexfont.cpp
common/fonts/singlelumpfont.cpp
common/fonts/v_font.cpp
common/fonts/v_text.cpp
common/fonts/fontchars.cpp
2019-10-21 20:39:26 +00:00
common/console/c_cvars.cpp
2019-11-05 18:57:48 +00:00
common/console/c_console.cpp
common/console/c_consolebuffer.cpp
2019-11-03 17:19:29 +00:00
common/console/c_bind.cpp
2019-11-04 22:01:50 +00:00
common/console/c_buttons.cpp
2019-11-03 17:19:29 +00:00
common/console/c_commandline.cpp
2019-11-04 22:01:50 +00:00
common/console/c_dispatch.cpp
2019-11-03 17:19:29 +00:00
common/console/d_event.cpp
2019-10-21 20:39:26 +00:00
2019-11-03 17:19:29 +00:00
common/utility/i_time.cpp
2019-10-23 23:20:58 +00:00
common/utility/name.cpp
2019-10-21 19:36:05 +00:00
common/utility/cmdlib.cpp
2019-09-23 17:29:25 +00:00
common/utility/m_argv.cpp
2019-09-23 17:52:25 +00:00
common/utility/files.cpp
common/utility/files_decompress.cpp
2019-09-23 18:56:05 +00:00
common/utility/zstring.cpp
common/utility/zstrformat.cpp
common/utility/utf8.cpp
common/utility/superfasthash.cpp
2019-09-23 19:06:52 +00:00
common/utility/configfile.cpp
2019-10-03 23:41:57 +00:00
common/utility/matrix.cpp
2019-10-05 17:28:05 +00:00
common/utility/m_png.cpp
common/utility/memarena.cpp
2019-10-23 23:20:58 +00:00
common/utility/sc_man.cpp
2019-11-08 22:02:52 +00:00
common/utility/stringtable.cpp
2019-11-10 09:01:31 +00:00
common/utility/stats.cpp
2019-10-05 17:28:05 +00:00
2019-10-28 23:15:36 +00:00
common/filesystem/filesystem.cpp
2019-10-28 22:46:15 +00:00
common/filesystem/ancientzip.cpp
common/filesystem/file_zip.cpp
common/filesystem/file_7z.cpp
common/filesystem/file_grp.cpp
common/filesystem/file_rff.cpp
common/filesystem/file_pak.cpp
common/filesystem/file_lump.cpp
common/filesystem/file_directory.cpp
common/filesystem/resourcefile.cpp
2019-10-05 17:28:05 +00:00
common/textures/bitmap.cpp
2019-10-12 06:54:06 +00:00
common/textures/buildtiles.cpp
2019-10-05 17:28:05 +00:00
common/textures/texture.cpp
common/textures/image.cpp
common/textures/imagetexture.cpp
2019-10-11 17:21:36 +00:00
common/textures/imagehelpers.cpp
2019-10-05 17:28:05 +00:00
common/textures/formats/ddstexture.cpp
common/textures/formats/jpegtexture.cpp
common/textures/formats/pcxtexture.cpp
common/textures/formats/pngtexture.cpp
common/textures/formats/tgatexture.cpp
2019-10-06 06:48:07 +00:00
common/textures/formats/stbtexture.cpp
2019-10-05 21:44:28 +00:00
common/textures/formats/arttexture.cpp
2019-11-10 23:31:36 +00:00
2019-11-10 22:58:51 +00:00
common/music/music.cpp
2019-11-10 23:31:36 +00:00
common/music/i_music.cpp
common/music/i_soundfont.cpp
common/music/music_config.cpp
common/music/music_midi_base.cpp
2019-11-11 21:52:07 +00:00
common/music/s_advsound.cpp
2019-11-11 20:50:20 +00:00
common/music/backend/oalsound.cpp
common/music/backend/i_sound.cpp
2019-11-10 23:31:36 +00:00
2019-11-28 22:27:10 +00:00
common/menu/imagescroller.cpp
2019-11-08 22:02:52 +00:00
common/menu/joystickmenu.cpp
common/menu/listmenu.cpp
common/menu/loadsavemenu.cpp
common/menu/menu.cpp
common/menu/menudef.cpp
common/menu/menuinput.cpp
common/menu/messagebox.cpp
common/menu/optionmenu.cpp
common/menu/readthis.cpp
2019-09-22 21:15:46 +00:00
)
if( MSVC )
enable_precompiled_headers( 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()
2019-09-22 23:28:18 +00:00
add_executable( demolition WIN32 MACOSX_BUNDLE
2019-09-22 21:15:46 +00:00
${HEADER_FILES}
${NOT_COMPILED_SOURCE_FILES}
#__autostart.cpp
${SYSTEM_SOURCES}
${FASTMATH_SOURCES}
${PCH_SOURCES}
#utility/strnatcmp.c
#utility/zstring.cpp
#zzautozend.cpp
)
2019-09-22 23:28:18 +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" )
set_source_files_properties( utility/sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" )
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-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} nsl socket)
2019-09-22 21:15:46 +00:00
endif()
if( UNIX )
find_package( Backtrace )
if(Backtrace_FOUND)
2019-09-22 23:28:18 +00:00
set( DEMOLITION_LIBS ${DEMOLITION_LIBS} ${Backtrace_LIBRARIES} )
2019-09-22 21:15:46 +00:00
endif()
endif()
2019-11-10 22:58:51 +00:00
target_link_libraries( demolition ${DEMOLITION_LIBS} gdtoa lzma duke3d blood rr sw zmusic )
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
mact/include
audiolib/include
glad/include
libxmp-lite/include
libxmp-lite/include/libxmp-lite
libsmackerdec/include
thirdparty/include
2019-11-07 19:31:16 +00:00
thirdparty/imgui
2019-10-05 11:38:02 +00:00
common
2019-10-25 00:07:46 +00:00
common/2d
common/fonts
2019-09-23 17:29:25 +00:00
common/utility
2019-09-25 22:20:16 +00:00
common/console
2019-10-05 17:28:05 +00:00
common/textures
2019-10-28 22:46:15 +00:00
common/filesystem
2019-11-10 22:58:51 +00:00
common/music
2019-11-08 17:55:52 +00:00
common/dobject
2019-11-08 22:02:52 +00:00
common/menu
2019-09-25 20:38:47 +00:00
platform
2019-09-22 21:15:46 +00:00
${CMAKE_BINARY_DIR}/libraries/gdtoa
2019-09-23 06:40:02 +00:00
2019-09-22 21:15:46 +00:00
#${SYSTEM_SOURCES_DIR}
)
2019-09-22 23:28:18 +00:00
add_dependencies( demolition revision_check )
2019-09-22 21:15:46 +00:00
# Due to some quirks, we need to do this in this order
2019-09-22 23:28:18 +00:00
if( NOT DEMOLITION_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-09-22 23:28:18 +00:00
set_target_properties( demolition PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${DEMOLITION_OUTPUT_DIR} )
set_target_properties( demolition PROPERTIES OUTPUT_NAME ${DEMOLITION_EXE_NAME} )
2019-09-22 21:15:46 +00:00
else()
2019-09-22 23:28:18 +00:00
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}
2019-09-22 21:15:46 +00:00
)
endif()
if( MSVC )
2019-09-22 23:28:18 +00:00
option( DEMOLITION_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
2019-09-22 21:15:46 +00:00
set( LINKERSTUFF "/MANIFEST:NO" )
2019-09-22 23:28:18 +00:00
if( DEMOLITION_GENERATE_MAPFILE )
2019-09-22 21:15:46 +00:00
set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
endif()
2019-09-22 23:28:18 +00:00
set_target_properties(demolition PROPERTIES LINK_FLAGS ${LINKERSTUFF})
2019-09-22 21:15:46 +00:00
2019-09-22 23:28:18 +00:00
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
2019-09-22 21:15:46 +00:00
COMMENT "Adding manifest..."
)
endif()
if( NOT WIN32 AND NOT APPLE )
2019-09-22 23:28:18 +00:00
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
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()
2019-09-22 23:28:18 +00:00
#add_custom_command(TARGET demolition POST_BUILD
2019-09-22 21:15:46 +00:00
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
2019-09-22 23:28:18 +00:00
# ${CMAKE_SOURCE_DIR}/soundfont/gdemolition.sf2 $<TARGET_FILE_DIR:demolition>/soundfonts/gdemolition.sf2
2019-09-22 21:15:46 +00:00
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
2019-09-22 23:28:18 +00:00
# ${CMAKE_SOURCE_DIR}/fm_banks/GENMIDI.GS.wopl $<TARGET_FILE_DIR:demolition>/fm_banks/GENMIDI.GS.wopl
2019-09-22 21:15:46 +00:00
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
2019-09-22 23:28:18 +00:00
# ${CMAKE_SOURCE_DIR}/fm_banks/gs-by-papiezak-and-sneakernets.wopn $<TARGET_FILE_DIR:demolition>/fm_banks/gs-by-papiezak-and-sneakernets.wopn
2019-09-22 21:15:46 +00:00
#)
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()
2019-09-22 23:28:18 +00:00
#if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
2019-09-22 21:15:46 +00:00
# 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")
if( HAVE_VULKAN )
set( LINK_FRAMEWORKS "${LINK_FRAMEWORKS} -framework QuartzCore" )
endif()
2019-09-22 23:28:18 +00:00
set_target_properties(demolition PROPERTIES
2019-09-22 21:15:46 +00:00
LINK_FLAGS "${LINK_FRAMEWORKS}"
2019-09-22 23:28:18 +00:00
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/demolition-info.plist" )
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-09-22 23:28:18 +00:00
set( INSTALL_PATH . CACHE STRING "Directory where the demolition executable will be placed during install." )
2019-09-22 21:15:46 +00:00
else()
2019-09-22 23:28:18 +00:00
set( INSTALL_PATH bin CACHE STRING "Directory where the demolition executable will be placed during install." )
2019-09-22 21:15:46 +00:00
endif()
2019-09-22 23:28:18 +00:00
install(TARGETS demolition
2019-09-22 21:15:46 +00:00
DESTINATION ${INSTALL_PATH}
COMPONENT "Game executable")
2019-09-23 17:29:25 +00:00
source_group("Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
2019-10-22 21:31:46 +00:00
source_group("Code" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/.+")
2019-10-05 17:28:05 +00:00
source_group("Code\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+")
source_group("Code\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/formats/.+")
2019-10-11 17:21:36 +00:00
source_group("Code\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
2019-10-25 17:07:14 +00:00
source_group("Code\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/2d/.+")
source_group("Code\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/console/.+")
2019-10-30 17:09:00 +00:00
source_group("Code\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
source_group("Code\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
2019-11-10 22:58:51 +00:00
source_group("Code\\Music" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/music/.+")
2019-11-08 17:55:52 +00:00
source_group("Code\\DObject" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/dobject/.+")
2019-11-08 22:02:52 +00:00
source_group("Code\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/menu/.+")
2019-09-22 21:15:46 +00:00
source_group("Utility\\Audiolib" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/audiolib/.+")
source_group("Utility\\Audiolib Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/audiolib/include/.+")
source_group("Utility\\Audiolib Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/audiolib/src/.+")
source_group("Utility\\Glad" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glad/.+")
source_group("Utility\\Glad Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glad/include/glad/.+")
source_group("Utility\\Glad Khr Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glad/include/Khr/.+")
source_group("Utility\\Glad Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glad/src/.+")
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\\Mact" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/.+")
source_group("Utility\\Mact Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/include/.+")
source_group("Utility\\Mact Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/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/.+")
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/.+")