From f6333e0daee002d3d759e25a2ef2c7bda4054627 Mon Sep 17 00:00:00 2001 From: Roman Shapiro Date: Thu, 16 Nov 2023 04:35:44 +0700 Subject: [PATCH] Added new experimental MSVC build way through CMake --- .gitignore | 3 +++ build/README.md | 13 +++++++++++++ build/create_solution.bat | 1 + src/CMakeLists.txt | 26 ++++++++++++++++++++++++++ src/protocol.c | 5 +++++ 5 files changed, 48 insertions(+) create mode 100644 build/README.md create mode 100644 build/create_solution.bat create mode 100644 src/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 35c0bed..e8e8f46 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ src/util/Makefile src/.accepted src/depend src/util/depend +build/* +!build/create_solution.bat +!build/README.md \ No newline at end of file diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..c737b22 --- /dev/null +++ b/build/README.md @@ -0,0 +1,13 @@ +### Overview +This guide describes how to build TbaMUD in the Visual Studio through the new experimental CMake environment. + +### Prerequisites +* [Visual Studio 2022+](https://visualstudio.microsoft.com/ru/vs/) +* [CMake 3.27+](https://cmake.org/) + +### Build Steps +1. Goto the folder `build` and execute `create_solution.bat`. + +2. Open `build/circle.sln` in Visual Studio. + +3. Compile and run. \ No newline at end of file diff --git a/build/create_solution.bat b/build/create_solution.bat new file mode 100644 index 0000000..ab60043 --- /dev/null +++ b/build/create_solution.bat @@ -0,0 +1 @@ +cmake -B . -S ..\src -G "Visual Studio 17 2022" \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..51832b4 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.27) + +# Set the project name +project(circle) + +# Global definitions +if(MSVC) + # using Visual Studio C++ + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) +endif() + +# circle itself +file(GLOB CIRCLE_SOURCES + "*.h" + "*.c" +) + +add_executable(circle ${CIRCLE_SOURCES}) + +if(MSVC) + target_link_libraries(circle wsock32.lib) + + set_target_properties(circle PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/.." + ) +endif() \ No newline at end of file diff --git a/src/protocol.c b/src/protocol.c index e2beac3..587e6ac 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -13,6 +13,11 @@ #include #include "protocol.h" +#ifdef _MSC_VER +#include "telnet.h" +#define alloca _alloca +#endif + /****************************************************************************** The following section is for Diku/Merc derivatives. Replace as needed. ******************************************************************************/