Skip to content

Commit

Permalink
Minor Windows build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-henry committed May 6, 2021
1 parent 5a668ce commit fa34fb6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 1 addition & 3 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/bindings/csharp/CSharpSockets.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fa34fb6

Please sign in to comment.