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)
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)
xmlstuff.cpp xmlstuff.h
xywindow.cpp xywindow.h
)
+
if (WIN32)
list(APPEND RADIANTLIST multimon.cpp multimon.h)
endif ()
uilib
xmllib
)
+
+window_app(${RADIANT_BASENAME})
+
if (X11_LIBRARIES)
target_link_libraries(${RADIANT_BASENAME} ${X11_LIBRARIES})
endif ()
q2map/writebsp.c
)
+console_app(q2map)
+window_app(q2map)
+
target_compile_definitions(q2map
PRIVATE
)
qdata/video.c
)
+console_app(qdata3)
+
target_compile_definitions(qdata3
PRIVATE
)
video.c
)
+console_app(h2data)
+
target_compile_definitions(h2data
PRIVATE
)
q3map2/writebsp.c
)
+console_app(q3map2)
+
if (BUILD_CRUNCH)
set(OPTIONAL_IMAGE_LIBRARIES crnrgba)
set(OPTIONAL_IMAGE_DEFINES BUILD_CRUNCH=1)
q3data/video.c
)
+console_app(q3data)
+
target_link_libraries(q3data
${GLIB_LIBRARIES}
${LIBXML2_LIBRARIES}