diff --git a/CMakeLists.txt b/CMakeLists.txt index e1d7dfcd7..11f6821e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ option(ENABLE_LAUNCHER "Enable compilation of launcher" ON) option(ENABLE_TEST "Enable compilation of unit tests" ON) option(ENABLE_PCH "Enable compilation using precompiled headers" ON) option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON) +option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON) # Useful for debugging option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) @@ -134,7 +135,10 @@ if(WIN32) set(Boost_USE_STATIC_LIBS OFF) # Don't link with SDLMain - #set(SDL2_BUILDING_LIBRARY ON) + if(ENABLE_DEBUG_CONSOLE) + set(SDL2_BUILDING_LIBRARY ON) + add_definitions(-DVCMI_WITH_DEBUG_CONSOLE) + endif() # Suppress warnings add_definitions(-D_CRT_SECURE_NO_WARNINGS) diff --git a/client/CMT.cpp b/client/CMT.cpp index 9a0ead469..debae5f2e 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -219,10 +219,9 @@ static void SDLLogCallback(void* userdata, logGlobal->debug("SDL(category %d; priority %d) %s", category, priority, message); } -//#if defined(VCMI_WINDOWS) && !defined (__GNUC__) -//int wmain(int argc, wchar_t* argv[]) -//#el -#if defined(VCMI_APPLE) || defined(VCMI_ANDROID) +#if defined(VCMI_WINDOWS) && !defined(__GNUC__) && defined(VCMI_WITH_DEBUG_CONSOLE) +int wmain(int argc, wchar_t* argv[]) +#elif defined(VCMI_APPLE) || defined(VCMI_ANDROID) int SDL_main(int argc, char *argv[]) #else int main(int argc, char * argv[]) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9359b66e8..692924f9e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -125,7 +125,11 @@ elseif(WIN32) set(client_ICON "VCMI_client.rc") endif() -add_executable(vcmiclient WIN32 ${client_SRCS} ${client_HEADERS} ${client_ICON}) +if(ENABLE_DEBUG_CONSOLE) + add_executable(vcmiclient ${client_SRCS} ${client_HEADERS} ${client_ICON}) +else() + add_executable(vcmiclient WIN32 ${client_SRCS} ${client_HEADERS} ${client_ICON}) +endif(ENABLE_DEBUG_CONSOLE) if(WIN32) set_target_properties(vcmiclient @@ -133,7 +137,9 @@ if(WIN32) OUTPUT_NAME "VCMI_client" PROJECT_LABEL "VCMI_client" ) - target_link_libraries(vcmiclient ${SDLMAIN_LIBRARY}) + if(NOT ENABLE_DEBUG_CONSOLE) + target_link_libraries(vcmiclient ${SDLMAIN_LIBRARY}) + endif() endif() target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES}