From a4e3a000fb3e5a78ab28a25b6a77352bddcfd5e0 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Wed, 27 Sep 2023 20:05:30 +0200 Subject: [PATCH] Fix Dynamic Library builds on Windows --- Engine/source/CMakeLists.txt | 7 +++++++ Engine/source/app/mainLoop.cpp | 3 ++- Engine/source/platformWin32/winWindow.cpp | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index d54cfdaa0..8bd7a70df 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -371,6 +371,9 @@ elseif (WIN32) # NOTE: On Windows, /Zc:wchar_t- is necessary otherwise you get unicode errors set_target_properties(${TORQUE_APP_NAME} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS}") + if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING) + set_target_properties(TorqueEngine PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_COMMON_DEFAULT}") + endif (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING) else() add_executable(${TORQUE_APP_NAME} ${TORQUE_SOURCE_FILES}) @@ -387,6 +390,10 @@ if(MSVC) list(GET OUTPUT_CONFIG ${INDEX} CONF) list(GET OUTPUT_SUFFIX ${INDEX} SUFFIX) set_property(TARGET ${TORQUE_APP_NAME} PROPERTY OUTPUT_NAME_${CONF} ${TORQUE_APP_NAME}_${SUFFIX}) + if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING) + set_property(TARGET TorqueEngine PROPERTY ${CONF}_POSTFIX "_${SUFFIX}") + set_property(TARGET TorqueEngine PROPERTY ${CONF}_OUTPUT_NAME ${TORQUE_APP_NAME}) + endif (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING) endforeach() # Set Visual Studio startup project set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TORQUE_APP_NAME}) diff --git a/Engine/source/app/mainLoop.cpp b/Engine/source/app/mainLoop.cpp index 5d1e9fcf4..a60af964e 100644 --- a/Engine/source/app/mainLoop.cpp +++ b/Engine/source/app/mainLoop.cpp @@ -292,6 +292,8 @@ void StandardMainLoop::init() Con::setVariable( "defaultGame", StringTable->insert("scripts") ); + Con::setVariable("TorqueScriptFileExtension", TORQUE_SCRIPT_EXTENSION); + Con::addVariable( "_forceAllMainThread", TypeBool, &ThreadPool::getForceAllMainThread(), "Force all work items to execute on main thread. turns this into a single-threaded system. Primarily useful to find whether malfunctions are caused by parallel execution or not.\n" "@ingroup platform" ); @@ -567,7 +569,6 @@ bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv ) Platform::setMainDotCsDir(buffer); Platform::setCurrentDirectory(buffer); - Con::setVariable("TorqueScriptFileExtension", TORQUE_SCRIPT_EXTENSION); Con::evaluate(script, false, useDefaultScript ? defaultScriptName : argv[1]); delete[] script; diff --git a/Engine/source/platformWin32/winWindow.cpp b/Engine/source/platformWin32/winWindow.cpp index 16feaf418..011884ce4 100644 --- a/Engine/source/platformWin32/winWindow.cpp +++ b/Engine/source/platformWin32/winWindow.cpp @@ -429,7 +429,7 @@ S32 TorqueMain(int argc, const char **argv) extern "C" { -S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32) +TORQUE_API S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32) { Vector argv( __FILE__, __LINE__ );