Create two executables - one for the game and one for the baking tool
This commit is contained in:
parent
1845de1428
commit
a466fbd35a
7 changed files with 145 additions and 27 deletions
|
|
@ -155,7 +155,8 @@ IF( NOT CMAKE_BUILD_TYPE )
|
|||
ENDIF()
|
||||
|
||||
set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." )
|
||||
set( ZDOOM_EXE_NAME "vkdoom" CACHE FILEPATH "Name of the executable to create" )
|
||||
set( ZDOOM_EXE_NAME "vkdoom" CACHE FILEPATH "Name of the game executable to create" )
|
||||
set( ZTOOL_EXE_NAME "vktool" CACHE FILEPATH "Name of the tool executable to create" )
|
||||
if( MSVC )
|
||||
# Allow the user to use ZDOOM_OUTPUT_DIR as a single release point.
|
||||
# Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names
|
||||
|
|
|
|||
|
|
@ -1209,12 +1209,22 @@ set( GAME_SOURCES
|
|||
|
||||
)
|
||||
|
||||
set( APP_SOURCES
|
||||
gamemain.cpp
|
||||
)
|
||||
|
||||
set( TOOL_SOURCES
|
||||
toolmain.cpp
|
||||
)
|
||||
|
||||
set( GAME_NONPCH_SOURCES ${GAME_SOURCES} )
|
||||
list( REMOVE_ITEM GAME_NONPCH_SOURCES ${PCH_SOURCES} )
|
||||
|
||||
add_executable( zdoom WIN32 MACOSX_BUNDLE ${GAME_SOURCES} )
|
||||
add_library( zengine STATIC ${GAME_SOURCES})
|
||||
add_executable( zdoom WIN32 MACOSX_BUNDLE ${APP_SOURCES} )
|
||||
add_executable( ztool ${TOOL_SOURCES} )
|
||||
|
||||
target_precompile_headers( zdoom PRIVATE g_pch.h )
|
||||
target_precompile_headers( zengine PRIVATE g_pch.h )
|
||||
|
||||
set_source_files_properties( ${FASTMATH_SOURCES} PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} )
|
||||
set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" )
|
||||
|
|
@ -1235,8 +1245,6 @@ if( UNIX )
|
|||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries( zdoom ${PROJECT_LIBRARIES} lzma ${ZMUSIC_LIBRARIES} )
|
||||
|
||||
include_directories(
|
||||
BEFORE
|
||||
.
|
||||
|
|
@ -1300,7 +1308,13 @@ include_directories(
|
|||
${SYSTEM_SOURCES_DIR}
|
||||
)
|
||||
|
||||
add_dependencies( zdoom revision_check )
|
||||
add_dependencies( zengine revision_check )
|
||||
add_dependencies( zdoom zengine )
|
||||
add_dependencies( ztool zengine )
|
||||
|
||||
target_link_libraries( zengine ${PROJECT_LIBRARIES} lzma ${ZMUSIC_LIBRARIES} )
|
||||
target_link_libraries( zdoom zengine )
|
||||
target_link_libraries( ztool zengine )
|
||||
|
||||
# Due to some quirks, we need to do this in this order
|
||||
if( NOT ZDOOM_OUTPUT_OLDSTYLE )
|
||||
|
|
@ -1308,6 +1322,8 @@ if( NOT ZDOOM_OUTPUT_OLDSTYLE )
|
|||
# Linux distributions are slow to adopt 2.6. :(
|
||||
set_target_properties( zdoom PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ZDOOM_OUTPUT_DIR} )
|
||||
set_target_properties( zdoom PROPERTIES OUTPUT_NAME ${ZDOOM_EXE_NAME} )
|
||||
set_target_properties( ztool PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ZDOOM_OUTPUT_DIR} )
|
||||
set_target_properties( ztool PROPERTIES OUTPUT_NAME ${ZTOOL_EXE_NAME} )
|
||||
else()
|
||||
set_target_properties( zdoom PROPERTIES
|
||||
RUNTIME_OUTPUT_NAME ${ZDOOM_EXE_NAME}
|
||||
|
|
@ -1319,45 +1335,74 @@ else()
|
|||
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${ZDOOM_EXE_NAME}rd
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${ZDOOM_OUTPUT_DIR}
|
||||
)
|
||||
set_target_properties( ztool PROPERTIES
|
||||
RUNTIME_OUTPUT_NAME ${ZTOOL_EXE_NAME}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${ZDOOM_OUTPUT_DIR}
|
||||
RUNTIME_OUTPUT_NAME_DEBUG ${ZTOOL_EXE_NAME}d
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${ZDOOM_OUTPUT_DIR}
|
||||
RUNTIME_OUTPUT_NAME_MINSIZEREL ${ZTOOL_EXE_NAME}msr
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${ZDOOM_OUTPUT_DIR}
|
||||
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO ${ZTOOL_EXE_NAME}rd
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${ZDOOM_OUTPUT_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if( MSVC )
|
||||
option ( CONSOLE_MODE "Compile as a console application" OFF )
|
||||
if ( CONSOLE_MODE )
|
||||
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE" )
|
||||
else()
|
||||
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS" )
|
||||
endif()
|
||||
|
||||
option ( CONSOLE_MODE "Compile game executable as a console application" OFF )
|
||||
option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
|
||||
set( LINKERSTUFF "/MANIFEST:NO" )
|
||||
|
||||
if( ZDOOM_GENERATE_MAPFILE )
|
||||
set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
|
||||
set(LINKERSTUFF "/MANIFEST:NO")
|
||||
|
||||
if (ZDOOM_GENERATE_MAPFILE)
|
||||
set(LINKERSTUFF ${LINKERSTUFF} "/MAP")
|
||||
endif()
|
||||
set_target_properties(zdoom PROPERTIES LINK_FLAGS ${LINKERSTUFF})
|
||||
|
||||
set(ZDOOM_LINKERSTUFF ${LINKERSTUFF})
|
||||
set(ZTOOL_LINKERSTUFF ${LINKERSTUFF})
|
||||
|
||||
if (CONSOLE_MODE)
|
||||
set(ZDOOM_LINKERSTUFF ${ZDOOM_LINKERSTUFF} "/SUBSYSTEM:CONSOLE")
|
||||
endif()
|
||||
|
||||
set_target_properties(zdoom PROPERTIES LINK_FLAGS ${ZDOOM_LINKERSTUFF})
|
||||
set_target_properties(ztool PROPERTIES LINK_FLAGS ${ZTOOL_LINKERSTUFF})
|
||||
|
||||
# Create stripped PDBs for nightly builds
|
||||
set_target_properties(zdoom PROPERTIES LINK_FLAGS_RELWITHDEBINFO /PDBSTRIPPED:${ZDOOM_OUTPUT_DIR}/RelWithDebInfo/${ZDOOM_EXE_NAME}-stripped.pdb)
|
||||
set_target_properties(ztool PROPERTIES LINK_FLAGS_RELWITHDEBINFO /PDBSTRIPPED:${ZDOOM_OUTPUT_DIR}/RelWithDebInfo/${ZTOOL_EXE_NAME}-stripped.pdb)
|
||||
|
||||
add_custom_command(TARGET zdoom POST_BUILD
|
||||
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\common\\platform\\win32\\manifest.xml\" -outputresource:\"$<TARGET_FILE:zdoom>\"\;\#1
|
||||
COMMENT "Adding manifest..."
|
||||
)
|
||||
|
||||
add_custom_command(TARGET ztool POST_BUILD
|
||||
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\common\\platform\\win32\\manifest.xml\" -outputresource:\"$<TARGET_FILE:ztool>\"\;\#1
|
||||
COMMENT "Adding manifest..."
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
if( NOT WIN32 AND NOT APPLE )
|
||||
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${ZDOOM_EXE_NAME} ${ZDOOM_OUTPUT_DIR}/${ZDOOM_EXE_NAME}; fi" )
|
||||
FILE( WRITE ${CMAKE_CURRENT_BINARY_DIR}/link-make "if [ ! -e ${ZDOOM_OUTPUT_DIR}/${ZTOOL_EXE_NAME} ]; then ln -sf ${CMAKE_CURRENT_BINARY_DIR}/${ZTOOL_EXE_NAME} ${ZDOOM_OUTPUT_DIR}/${ZTOOL_EXE_NAME}; fi" )
|
||||
add_custom_command( TARGET zdoom POST_BUILD
|
||||
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/link-make )
|
||||
add_custom_command( TARGET ztool POST_BUILD
|
||||
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/link-make )
|
||||
IF ("${INSTALL_RPATH}" STREQUAL "")
|
||||
set_target_properties(zdoom PROPERTIES
|
||||
#allow libzmusic.so.1 library in same folder as executable at runtime
|
||||
INSTALL_RPATH "\$ORIGIN:\$ORIGIN/zmusic/build/source"
|
||||
BUILD_WITH_INSTALL_RPATH ON
|
||||
)
|
||||
set_target_properties(ztool PROPERTIES
|
||||
#allow libzmusic.so.1 library in same folder as executable at runtime
|
||||
INSTALL_RPATH "\$ORIGIN:\$ORIGIN/zmusic/build/source"
|
||||
BUILD_WITH_INSTALL_RPATH ON
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -1372,6 +1417,7 @@ add_custom_command(TARGET zdoom POST_BUILD
|
|||
|
||||
if (VCPKG_TOOLCHAIN)
|
||||
x_vcpkg_install_local_dependencies(TARGETS zdoom DESTINATION ".")
|
||||
x_vcpkg_install_local_dependencies(TARGETS ztool DESTINATION ".")
|
||||
endif()
|
||||
|
||||
if( WIN32 )
|
||||
|
|
@ -1399,6 +1445,7 @@ if( APPLE )
|
|||
set( LINK_FRAMEWORKS "${LINK_FRAMEWORKS} -framework QuartzCore" )
|
||||
endif()
|
||||
|
||||
# Do we also need to do this with ztool? It is not an app bundle
|
||||
set_target_properties(zdoom PROPERTIES
|
||||
LINK_FLAGS "${LINK_FRAMEWORKS}"
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist"
|
||||
|
|
@ -1418,6 +1465,9 @@ endif()
|
|||
install(TARGETS zdoom
|
||||
DESTINATION ${INSTALL_PATH}
|
||||
COMPONENT "Game executable")
|
||||
install(TARGETS ztool
|
||||
DESTINATION ${INSTALL_PATH}
|
||||
COMPONENT "Tool executable")
|
||||
|
||||
source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+")
|
||||
source_group("Game Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/.+")
|
||||
|
|
|
|||
|
|
@ -530,8 +530,7 @@ void ReleaseApplicationController()
|
|||
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int I_GameMain(int argc, char** argv)
|
||||
{
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
|
|
@ -574,3 +573,8 @@ int main(int argc, char** argv)
|
|||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int I_ToolMain(int argc, char** argv)
|
||||
{
|
||||
return I_GameMain(argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ void I_DetectOS()
|
|||
|
||||
void I_StartupJoysticks();
|
||||
|
||||
int main (int argc, char **argv)
|
||||
int I_GameMain(int argc, char** argv)
|
||||
{
|
||||
#if !defined (__APPLE__)
|
||||
{
|
||||
|
|
@ -202,3 +202,8 @@ int main (int argc, char **argv)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
int I_ToolMain(int argc, char** argv)
|
||||
{
|
||||
return I_GameMain(argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,16 +333,15 @@ void I_ShowFatalError(const char *msg)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
int wmain()
|
||||
void I_SetWindowTitle(const char* caption)
|
||||
{
|
||||
return wWinMain(GetModuleHandle(0), 0, GetCommandLineW(), SW_SHOW);
|
||||
mainwindow.SetWindowTitle(caption);
|
||||
}
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
|
||||
{
|
||||
//==========================================================================
|
||||
|
||||
int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
|
||||
{
|
||||
g_hInst = hInstance;
|
||||
|
||||
InitCommonControls();
|
||||
|
|
@ -381,7 +380,20 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int
|
|||
return DoMain(hInstance);
|
||||
}
|
||||
|
||||
void I_SetWindowTitle(const char* caption)
|
||||
int I_ToolMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
|
||||
{
|
||||
mainwindow.SetWindowTitle(caption);
|
||||
g_hInst = hInstance;
|
||||
|
||||
InitCommonControls();
|
||||
if (SUCCEEDED(CoInitialize(nullptr)))
|
||||
atexit([]() { CoUninitialize(); }); // beware of calling convention.
|
||||
|
||||
FString reportsDirectory = GetKnownFolder(CSIDL_LOCAL_APPDATA, FOLDERID_LocalAppData, true);
|
||||
reportsDirectory += "/" GAMENAMELOWERCASE;
|
||||
reportsDirectory += "/crashreports";
|
||||
CreatePath(reportsDirectory.GetChars());
|
||||
|
||||
InitCrashReporter(reportsDirectory.WideString(), {});
|
||||
|
||||
return DoMain(hInstance);
|
||||
}
|
||||
|
|
|
|||
23
src/gamemain.cpp
Normal file
23
src/gamemain.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
#if defined(WIN32)
|
||||
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <Windows.h>
|
||||
|
||||
int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow);
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
|
||||
{
|
||||
return I_GameMain(hInstance, nothing, cmdline, nCmdShow);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int I_GameMain(int argc, char** argv);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return I_GameMain(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
23
src/toolmain.cpp
Normal file
23
src/toolmain.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
#if defined(WIN32)
|
||||
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <Windows.h>
|
||||
|
||||
int I_ToolMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow);
|
||||
|
||||
int wmain()
|
||||
{
|
||||
return I_ToolMain(GetModuleHandle(0), 0, GetCommandLineW(), SW_SHOW);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int I_ToolMain(int argc, char** argv);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return I_ToolMain(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue