From 73522bcb6c281604183a3319bf9c448e5e176a42 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 11 Aug 2023 18:30:03 +0200 Subject: [PATCH] (Windows) Set the subsystem to WINDOWS when building with MSVC to avoid displaying a console window on application startup --- es-app/CMakeLists.txt | 7 ++++++- es-pdf-converter/CMakeLists.txt | 2 +- es-pdf-converter/src/main.cpp | 6 +----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index f0429ed9a..069a96a6c 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -119,11 +119,16 @@ endif() # OS-specific installation and package generation setup. # Define target. -if(APPLE OR WIN32) +if(APPLE) include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src) add_executable(EmulationStation ${ES_SOURCES} ${ES_HEADERS}) target_link_libraries(EmulationStation ${COMMON_LIBRARIES} es-core) set_target_properties(EmulationStation PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +elseif(WIN32) + include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src) + add_executable(EmulationStation WIN32 ${ES_SOURCES} ${ES_HEADERS}) + target_link_libraries(EmulationStation ${COMMON_LIBRARIES} es-core) + set_target_properties(EmulationStation PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) else() include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src) add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS}) diff --git a/es-pdf-converter/CMakeLists.txt b/es-pdf-converter/CMakeLists.txt index 38291d1e1..242efa8ad 100644 --- a/es-pdf-converter/CMakeLists.txt +++ b/es-pdf-converter/CMakeLists.txt @@ -26,7 +26,7 @@ else() endif() include_directories(${POPPLER_CPP_INCLUDE_DIR}) -add_executable(es-pdf-convert ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) +add_executable(es-pdf-convert WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) target_link_libraries(es-pdf-convert ${POPPLER_CPP_LIBRARY}) if(WIN32) diff --git a/es-pdf-converter/src/main.cpp b/es-pdf-converter/src/main.cpp index 404a6d787..8418fb5d9 100644 --- a/es-pdf-converter/src/main.cpp +++ b/es-pdf-converter/src/main.cpp @@ -25,15 +25,11 @@ #include #include -#if defined(_MSC_VER) // MSVC compiler. -int wmain(int argc, wchar_t* argv[]) -{ -#else int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { wchar_t** argv {__wargv}; int argc {__argc}; -#endif + HANDLE stdoutHandle {GetStdHandle(STD_OUTPUT_HANDLE)}; if (stdoutHandle == INVALID_HANDLE_VALUE) {