From fa34fb62e6fb688fbe54db8d2cc112a1384adb00 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Wed, 5 May 2021 19:55:47 -0700 Subject: [PATCH] Minor Windows build fixes --- CMakeLists.txt | 14 ++++++++++---- README | 2 +- README.md | 4 ++-- build.ps1 | 4 +--- src/bindings/csharp/CSharpSockets.cxx | 4 ++++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f334cb5..a3a51d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,7 @@ set(ALLOW_INSTALL_TARGET TRUE) set(BUILD_STATIC_LIB TRUE) set(BUILD_SHARED_LIB TRUE) set(BUILD_HOST_SELFTEST TRUE) +set(ZTS_DISABLE_CENTRAL_API TRUE) # C# language bindings (libzt.dll/dylib/so) if (ZTS_ENABLE_PINVOKE) @@ -275,10 +276,12 @@ if(BUILD_HOST_EXAMPLES) ${PROJ_DIR}/examples/c/adhoc.c) target_link_libraries(adhoc ${STATIC_LIB_NAME}) +if(NOT ZTS_DISABLE_CENTRAL_API) add_executable(centralapi ${PROJ_DIR}/examples/c/centralapi.cpp) - target_compile_options(centralapi PRIVATE "-Wno-tautological-overlap-compare") + #target_compile_options(centralapi PRIVATE "-Wno-tautological-overlap-compare") target_link_libraries(centralapi ${STATIC_LIB_NAME}) +endif() add_executable(callbackapi ${PROJ_DIR}/examples/c/callbackapi.c) @@ -313,11 +316,14 @@ endif() # | FLAGS | # ------------------------------------------------------------------------------ -#set(ZT_FLAGS "${ZT_FLAGS} -DNO_GETADDRINFO=1") +set(ZT_FLAGS "${ZT_FLAGS} -DZT_SDK=1") set(ZT_FLAGS "${ZT_FLAGS} -DZT_USE_MINIUPNPC=1") set(ZT_FLAGS "${ZT_FLAGS} -D_USING_LWIP_DEFINITIONS_=0") -set(ZT_FLAGS "${ZT_FLAGS} -DOMIT_JSON_SUPPORT=1 -Wno-unused-parameter") -set(LWIP_FLAGS "${LWIP_FLAGS} -Wno-tautological-constant-out-of-range-compare -Wno-parentheses-equality") + +if (NOT BUILD_WIN) + set(ZT_FLAGS "${ZT_FLAGS} -DOMIT_JSON_SUPPORT=1 -Wno-unused-parameter") + set(LWIP_FLAGS "${LWIP_FLAGS} -Wno-tautological-constant-out-of-range-compare -Wno-parentheses-equality") +endif() if(BUILD_DEBUG) set(LWIP_FLAGS "${LWIP_FLAGS} -DLWIP_DBG_TYPES_ON=128") diff --git a/README b/README index 8a9bca1..76ff885 100644 --- a/README +++ b/README @@ -13,7 +13,7 @@ build.ps1 are used to simplify building and packaging for various targets. 1. git submodule update --init 2. (*)nix : ./build.sh host "release" -2. Windows : . .\build.ps1; Build-Host -BuildType "Release" +2. Windows : . .\build.ps1; Build-Host -BuildType "Release" -Arch "x64" To see additional build targets: diff --git a/README.md b/README.md index d5d6bd6..61bb444 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,9 @@ This project uses [CMake](https://cmake.org/download/) as a build system generat |:---|:---|:---| |Linux | `./build.sh host "release"`| [build.sh](./build.sh) | |macOS | `./build.sh host "release"`| [build.sh](./build.sh) | -|Windows | `. .\build.ps1; Build-Host -BuildType "Release"`| [build.ps1](./build.ps1), *Requires [PowerShell](https://github.com/powershell/powershell)*| +|Windows | `. .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"` | [build.ps1](./build.ps1), *Requires [PowerShell](https://github.com/powershell/powershell)*| - Using the `host` keyword will automatically detect the current machine type and build standard libzt for use in C/C++ (no additional language bindings.) See `./build.sh list` for additional target options. `libzt` depends on [cURL](https://github.com/curl/curl) for the optional portion of the API that interfaces with our hosted web offering ([my.zerotier.com](my.zerotier.com)). If you do not need this functionality you can omit it by passing `-DZTS_ENABLE_CENTRAL_API=0` to CMake. + Using the `host` keyword will automatically detect the current machine type and build standard libzt for use in C/C++ (no additional language bindings.) See `./build.sh list` for additional target options. `libzt` depends on [cURL](https://github.com/curl/curl) for the optional portion of the API that interfaces with our hosted web offering ([my.zerotier.com](my.zerotier.com)). If you do not need this functionality you can omit it by passing `-DZTS_DISABLE_CENTRAL_API=1` to CMake. Example output: diff --git a/build.ps1 b/build.ps1 index 770a301..4da047e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,8 +1,6 @@ -function Build-Host +function Build-Host([string]$BuildType, [string]$Arch) { - $Arch="x64" $Artifact="host" - $BuildType="Debug" $Variant="-DBUILD_HOST=1" # Directory for CMake to build and store intermediate files diff --git a/src/bindings/csharp/CSharpSockets.cxx b/src/bindings/csharp/CSharpSockets.cxx index 2aa2921..198daaa 100644 --- a/src/bindings/csharp/CSharpSockets.cxx +++ b/src/bindings/csharp/CSharpSockets.cxx @@ -398,6 +398,8 @@ SWIGINTERN void SWIG_CSharpException(int code, const char* msg) extern "C" { #endif +#ifndef ZTS_DISABLE_CENTRAL_API + SWIGEXPORT int SWIGSTDCALL CSharp_zts_central_set_access_mode(char jarg1) { int jresult; @@ -597,6 +599,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_central_net_get_members(void* jarg1, unsig return jresult; } +#endif // ZTS_DISABLE_CENTRAL_API + SWIGEXPORT int SWIGSTDCALL CSharp_zts_id_new(char* jarg1, void* jarg2) { int jresult;