Browse Source

CMake: add ENABLE_DEBUG_CONSOLE option for Windows enabled by default

For now we'll keep console, but in future we need a way to toggle it at runtime.
Arseniy Shestakov 8 năm trước cách đây
mục cha
commit
5fce56d23e
3 tập tin đã thay đổi với 16 bổ sung7 xóa
  1. 5 1
      CMakeLists.txt
  2. 3 4
      client/CMT.cpp
  3. 8 2
      client/CMakeLists.txt

+ 5 - 1
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)

+ 3 - 4
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[])

+ 8 - 2
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}