From: Thomas Debesse Date: Thu, 4 Jul 2019 23:57:34 +0000 (+0200) Subject: cmake: make tools target the console subsystem on Windows X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f2f321e97f89c45980cd63d70f98331b484fec1c;p=xonotic%2Fnetradiant.git cmake: make tools target the console subsystem on Windows previously on Windows the stdout stuff was only printed on MinTTY console or SSH shell, this change makes the tools to target the console subsystem so they also print stdout on cmd console. this also makes the tool spawning a cmd console windows when not started from a console, allowing people to monitor what is printed. this is done by adding a console_app() cmake macro that enables the -mconsole linker flag. For exhaustivity an extraneous window_app() macro is done too that enables the -mwindows flag. The -mwindows looks to be implicit, but making this macro explicit and using it keeps the CMakeLists.txt file self documenting which exe has to be compiled with -mconsole, which one has to be compiled with -mwindows, and which one has to be compiled with both. this is a way to check if an exe targets only the windows subsystem: $ objdump -p netradiant.exe | egrep '^Subsystem' Subsystem 00000002 (Windows GUI) this is a way to check if an exe targets the console subsystem: $ objdump -p q3map2.exe | egrep '^Subsystem' Subsystem 00000003 (Windows CUI) note that this one targets both console and windows subsystem, only console is reported: $ objdump -p q2map.exe | egrep '^Subsystem' Subsystem 00000003 (Windows CUI) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a414aa1..6afa468a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,18 @@ if (BUILD_BINARIES) string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX}) endif () + macro (console_app name) + if (WIN32) + target_link_libraries(${name} -mconsole) + endif () + endmacro () + + macro (window_app name) + if (WIN32) + target_link_libraries(${name} -mwindows) + endif () + endmacro () + macro (radiant_tool name) if (BUNDLE_LIBRARIES AND WIN32) add_executable(${name} ${ARGN} ${PROJECT_SOURCE_DIR}/include/lib.rc) diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 6fcb3680..144bf320 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -90,6 +90,7 @@ set(RADIANTLIST xmlstuff.cpp xmlstuff.h xywindow.cpp xywindow.h ) + if (WIN32) list(APPEND RADIANTLIST multimon.cpp multimon.h) endif () @@ -126,6 +127,9 @@ target_link_libraries(${RADIANT_BASENAME} uilib xmllib ) + +window_app(${RADIANT_BASENAME}) + if (X11_LIBRARIES) target_link_libraries(${RADIANT_BASENAME} ${X11_LIBRARIES}) endif () diff --git a/tools/quake2/CMakeLists.txt b/tools/quake2/CMakeLists.txt index 6945ee67..20d7ff82 100644 --- a/tools/quake2/CMakeLists.txt +++ b/tools/quake2/CMakeLists.txt @@ -46,6 +46,9 @@ radiant_tool(q2map q2map/writebsp.c ) +console_app(q2map) +window_app(q2map) + target_compile_definitions(q2map PRIVATE ) @@ -81,6 +84,8 @@ radiant_tool(qdata3 qdata/video.c ) +console_app(qdata3) + target_compile_definitions(qdata3 PRIVATE ) diff --git a/tools/quake2/qdata_heretic2/CMakeLists.txt b/tools/quake2/qdata_heretic2/CMakeLists.txt index aae46591..d9c5b436 100644 --- a/tools/quake2/qdata_heretic2/CMakeLists.txt +++ b/tools/quake2/qdata_heretic2/CMakeLists.txt @@ -56,6 +56,8 @@ radiant_tool(h2data video.c ) +console_app(h2data) + target_compile_definitions(h2data PRIVATE ) diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt index 7ba643bf..d2d3ae2b 100644 --- a/tools/quake3/CMakeLists.txt +++ b/tools/quake3/CMakeLists.txt @@ -127,6 +127,8 @@ radiant_tool(q3map2 q3map2/writebsp.c ) +console_app(q3map2) + if (BUILD_CRUNCH) set(OPTIONAL_IMAGE_LIBRARIES crnrgba) set(OPTIONAL_IMAGE_DEFINES BUILD_CRUNCH=1) @@ -179,6 +181,8 @@ radiant_tool(q3data q3data/video.c ) +console_app(q3data) + target_link_libraries(q3data ${GLIB_LIBRARIES} ${LIBXML2_LIBRARIES}