From 609c725cedbeca31ae3aba3a9c39c5030ea1d20f Mon Sep 17 00:00:00 2001 From: Trumeet Date: Thu, 21 Jul 2022 21:47:47 -0700 Subject: fix(libacron/acronc): complete cross-platform build This patch made several changes to correctly build libac on Windows: 1. Deprecated PkgConfig on Unix. On both platforms, libac requires the JSON-C CMake module to locate libraries (whether is dynamic or static) and headers. On Windows, the common practice is to statically link the library, so libac now provides setup.bat to automatically clone JSON-C and build it. In CMakeLists.txt, libac will automatically pick up the in-tree JSON-C build if it presents. Otherwise, it will use the system default's. Users can override the CMAKE_PREFIX_PATH to supply a custom JSON-C library if it is not found in-tree. 2. Switched from #include to , as the former (current) approach is non-standard and depends on the system header locations. The later (new) approach relies on CMake to supply header search paths, which works on Windows as well. 3. Deprecated --version-script on Unix linkers. Instead, libac now uses -fvisibility (https://gcc.gnu.org/wiki/Visibility) on GCC or LLVM, as well as __declspec(dllexport) on MSVC to export selected symbols. A new macro, LIBAC_EXPORT, is defined in incl.h (new), and all functions needed to export are marked with that macro. 4. Changed several codes (mostly socket-related) to work on Windows. 5. Massive rewrite of CMake in preparation of further installation and static library support. Signed-off-by: Trumeet --- client/libacron/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'client/libacron/README.md') diff --git a/client/libacron/README.md b/client/libacron/README.md index 11d7663..8305a5d 100644 --- a/client/libacron/README.md +++ b/client/libacron/README.md @@ -23,7 +23,7 @@ cd client/libacron/ mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. -make +cmake --build . ``` The shared library will be at `libac.so`. @@ -32,6 +32,19 @@ The distributable headers are at `client/libacron/include/`. To make debug builds, use the Debug build type. Debug builds will have ASAN enabled. +To build on Windows: + +```batch +git clone https://git.yuuta.moe/Minecraft/acron.git +CD acron +git submodule update --init +CD client/libacron/ +setup.bat +mkdir build +cmake -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +``` + ## Usage All functions begin with `ac_`. Include `libac.h`. -- cgit v1.2.3