summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Drahos <drahosp@gmail.com>2013-03-03 14:43:32 +0100
committerPeter Drahos <drahosp@gmail.com>2013-03-03 14:43:32 +0100
commit4f5eb166560d62043e7a1c17cebf738008a64478 (patch)
treeed13029700387c762c1466c73deeac691926d9c0
parent705b7f0a0367b26b1e375026132d6220d5303246 (diff)
downloadlua-4f5eb166560d62043e7a1c17cebf738008a64478.tar.gz
Added WinMain entry for wlua target. Fixed Visual Studio builds.
-rw-r--r--CMakeLists.txt8
-rw-r--r--src/wmain.c16
2 files changed, 24 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a44c8f..e54bb7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ set ( LUA_CPATH_DEFAULT "./?${LUA_MODULE_SUFFIX};${LUA_DIR}${LUA_CDIR}/?${LUA_MO
if ( WIN32 AND NOT CYGWIN )
# Windows systems
option ( LUA_WIN "Windows specific build." ON )
+ option ( LUA_BUILD_WLUA "Build wLua interpretter without console output." ON )
option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ${BUILD_SHARED_LIBS} )
# Paths (Double escapes ne option needed)
@@ -132,6 +133,13 @@ target_link_libraries ( lua liblua )
add_executable ( luac ${SRC_CORE} ${SRC_LIB} ${SRC_LUAC} src/luac.rc )
target_link_libraries ( luac ${LIBS} )
+# On windows a variant of the lua interpreter without console output needs to be built
+if ( LUA_BUILD_WLUA )
+ add_executable ( wlua WIN32 src/wmain.c ${SRC_LUA} ${LUA_RC} )
+ target_link_libraries ( wlua liblua )
+ install_executable ( wlua )
+endif ( )
+
install_executable ( lua luac )
install_library ( liblua )
install_data ( README.md )
diff --git a/src/wmain.c b/src/wmain.c
new file mode 100644
index 0000000..6cf3e57
--- /dev/null
+++ b/src/wmain.c
@@ -0,0 +1,16 @@
+#include <windows.h>
+#include <stdlib.h> /* declaration of __argc and __argv */
+
+extern int main(int, char **);
+
+int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int ncmdshow)
+{
+ int rc;
+
+ extern int __argc; /* this seems to work for all the compilers we tested, except Watcom compilers */
+ extern char** __argv;
+
+ rc = main(__argc, __argv);
+
+ return rc;
+}