summaryrefslogtreecommitdiff
path: root/cmake/ApplyEditbin.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/ApplyEditbin.cmake')
-rw-r--r--cmake/ApplyEditbin.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/ApplyEditbin.cmake b/cmake/ApplyEditbin.cmake
new file mode 100644
index 0000000..3b1aa9d
--- /dev/null
+++ b/cmake/ApplyEditbin.cmake
@@ -0,0 +1,19 @@
+# helper script for Windows to run editbin.exe on a generated executable
+function(apply_editbin target_name target_type)
+if (WIN32)
+ find_program(EDITBIN editbin)
+ if(EDITBIN)
+ set(EDITBIN_FLAGS /nologo /OSVERSION:5.1)
+ if (${target_type} STREQUAL "console")
+ set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:CONSOLE,6.00)
+ elseif (${target_type} STREQUAL "windows")
+ set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:WINDOWS,6.00)
+ endif()
+ add_custom_command(
+ TARGET ${target_name}
+ POST_BUILD
+ COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:${target_name}>"
+ VERBATIM)
+ endif()
+ endif()
+endfunction()