From 201733d1b52a98f58ff4bd81a932c69d5b833a29 Mon Sep 17 00:00:00 2001 From: Chris Oboe Date: Sat, 24 Dec 2022 03:39:59 +0100 Subject: Disable automatically opening the console on windows yuzu-cmd builds (#9485) * don't automatically open the console on windows build of yuzu-cmd * fix formatting --- src/yuzu_cmd/CMakeLists.txt | 9 +++++++++ src/yuzu_cmd/yuzu.cpp | 7 +++++++ 2 files changed, 16 insertions(+) (limited to 'src/yuzu_cmd') diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index f6eeb9d8d..61b6cc4e0 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -49,6 +49,15 @@ if(UNIX AND NOT APPLE) install(TARGETS yuzu-cmd) endif() +if(WIN32) + # compile as a win32 gui application instead of a console application + if(MSVC) + set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") + elseif(MINGW) + set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "-Wl,--subsystem,windows") + endif() +endif() + if (MSVC) include(CopyYuzuSDLDeps) copy_yuzu_SDL_deps(yuzu-cmd) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index a80649703..91133569d 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -174,6 +174,13 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) { /// Application entry point int main(int argc, char** argv) { +#ifdef _WIN32 + if (AttachConsole(ATTACH_PARENT_PROCESS)) { + freopen("CONOUT$", "wb", stdout); + freopen("CONOUT$", "wb", stderr); + } +#endif + Common::Log::Initialize(); Common::Log::SetColorConsoleBackendEnabled(true); Common::Log::Start(); -- cgit v1.2.3