From f9cbf17a07f9503aecdac3fe0b9496ad3f8f0036 Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Sat, 25 Feb 2023 19:20:51 +1100 Subject: [PATCH 1/2] Issue #643 - Rewrite CLI vs GUI strategy (this matches DefleMask) --- CMakeLists.txt | 4 +++- src/main.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f994cfd5..5eddbf1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -780,13 +780,15 @@ endif() if(ANDROID AND NOT TERMUX) add_library(furnace SHARED ${USED_SOURCES}) +elseif(WIN32) + add_executable(furnace WIN32 ${USED_SOURCES}) else() add_executable(furnace ${USED_SOURCES}) endif() target_include_directories(furnace SYSTEM PRIVATE ${DEPENDENCIES_INCLUDE_DIRS}) target_compile_definitions(furnace PRIVATE ${DEPENDENCIES_DEFINES} IMGUI_USER_CONFIG="imconfig_fur.h") -target_compile_options(furnace PRIVATE ${DEPENDENCIES_COMPILE_OPTIONS}) +target_compile_options(furnace PRIVATE ${DEPENDENCIES_COMPILE_OPfTIONS}) target_link_libraries(furnace PRIVATE ${DEPENDENCIES_LIBRARIES}) if (PKG_CONFIG_FOUND AND (SYSTEM_FMT OR SYSTEM_LIBSNDFILE OR SYSTEM_ZLIB OR SYSTEM_SDL2 OR SYSTEM_RTMIDI OR WITH_JACK)) if ("${CMAKE_VERSION}" VERSION_LESS "3.13") diff --git a/src/main.cpp b/src/main.cpp index d8cc440b..6ebedae3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -342,12 +342,14 @@ void reportError(String what) { // TODO: CoInitializeEx on Windows? // TODO: add crash log int main(int argc, char** argv) { - // Windows console thing - thanks MarioKart7z! + // Windows console thing - thanks dj.tuBIG/MaliceX #ifdef _WIN32 - DWORD winPID; - HWND winConsole=GetConsoleWindow(); - GetWindowThreadProcessId(winConsole,&winPID); - if (GetCurrentProcessId()==winPID) FreeConsole(); + + if (AttachConsole(ATTACH_PARENT_PROCESS)) { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + freopen("CONIN$", "r", stdin); + } #endif initLog(); From 16ccd4f8fe685f4e0b5bb5a67ec2bd3e7d5bc919 Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Sat, 25 Feb 2023 19:26:27 +1100 Subject: [PATCH 2/2] typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eddbf1b..bd93c919 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -788,7 +788,7 @@ endif() target_include_directories(furnace SYSTEM PRIVATE ${DEPENDENCIES_INCLUDE_DIRS}) target_compile_definitions(furnace PRIVATE ${DEPENDENCIES_DEFINES} IMGUI_USER_CONFIG="imconfig_fur.h") -target_compile_options(furnace PRIVATE ${DEPENDENCIES_COMPILE_OPfTIONS}) +target_compile_options(furnace PRIVATE ${DEPENDENCIES_COMPILE_OPTIONS}) target_link_libraries(furnace PRIVATE ${DEPENDENCIES_LIBRARIES}) if (PKG_CONFIG_FOUND AND (SYSTEM_FMT OR SYSTEM_LIBSNDFILE OR SYSTEM_ZLIB OR SYSTEM_SDL2 OR SYSTEM_RTMIDI OR WITH_JACK)) if ("${CMAKE_VERSION}" VERSION_LESS "3.13")