(Windows) Set the subsystem to WINDOWS when building with MSVC to avoid displaying a console window on application startup

This commit is contained in:
Leon Styhre 2023-08-11 18:30:03 +02:00
parent 330f2a44de
commit 73522bcb6c
3 changed files with 8 additions and 7 deletions

View file

@ -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})

View file

@ -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)

View file

@ -25,15 +25,11 @@
#include <io.h>
#include <windows.h>
#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) {