Minor Windows build fixes

This commit is contained in:
Joseph Henry
2021-05-05 19:55:47 -07:00
parent 5a668ceeba
commit fa34fb62e6
5 changed files with 18 additions and 10 deletions

View File

@@ -91,6 +91,7 @@ set(ALLOW_INSTALL_TARGET TRUE)
set(BUILD_STATIC_LIB TRUE) set(BUILD_STATIC_LIB TRUE)
set(BUILD_SHARED_LIB TRUE) set(BUILD_SHARED_LIB TRUE)
set(BUILD_HOST_SELFTEST TRUE) set(BUILD_HOST_SELFTEST TRUE)
set(ZTS_DISABLE_CENTRAL_API TRUE)
# C# language bindings (libzt.dll/dylib/so) # C# language bindings (libzt.dll/dylib/so)
if (ZTS_ENABLE_PINVOKE) if (ZTS_ENABLE_PINVOKE)
@@ -275,10 +276,12 @@ if(BUILD_HOST_EXAMPLES)
${PROJ_DIR}/examples/c/adhoc.c) ${PROJ_DIR}/examples/c/adhoc.c)
target_link_libraries(adhoc ${STATIC_LIB_NAME}) target_link_libraries(adhoc ${STATIC_LIB_NAME})
if(NOT ZTS_DISABLE_CENTRAL_API)
add_executable(centralapi add_executable(centralapi
${PROJ_DIR}/examples/c/centralapi.cpp) ${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}) target_link_libraries(centralapi ${STATIC_LIB_NAME})
endif()
add_executable(callbackapi add_executable(callbackapi
${PROJ_DIR}/examples/c/callbackapi.c) ${PROJ_DIR}/examples/c/callbackapi.c)
@@ -313,11 +316,14 @@ endif()
# | FLAGS | # | 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} -DZT_USE_MINIUPNPC=1")
set(ZT_FLAGS "${ZT_FLAGS} -D_USING_LWIP_DEFINITIONS_=0") set(ZT_FLAGS "${ZT_FLAGS} -D_USING_LWIP_DEFINITIONS_=0")
if (NOT BUILD_WIN)
set(ZT_FLAGS "${ZT_FLAGS} -DOMIT_JSON_SUPPORT=1 -Wno-unused-parameter") 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") set(LWIP_FLAGS "${LWIP_FLAGS} -Wno-tautological-constant-out-of-range-compare -Wno-parentheses-equality")
endif()
if(BUILD_DEBUG) if(BUILD_DEBUG)
set(LWIP_FLAGS "${LWIP_FLAGS} -DLWIP_DBG_TYPES_ON=128") set(LWIP_FLAGS "${LWIP_FLAGS} -DLWIP_DBG_TYPES_ON=128")

2
README
View File

@@ -13,7 +13,7 @@ build.ps1 are used to simplify building and packaging for various targets.
1. git submodule update --init 1. git submodule update --init
2. (*)nix : ./build.sh host "release" 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: To see additional build targets:

View File

@@ -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) | |Linux | `./build.sh host "release"`| [build.sh](./build.sh) |
|macOS | `./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: Example output:

View File

@@ -1,8 +1,6 @@
function Build-Host function Build-Host([string]$BuildType, [string]$Arch)
{ {
$Arch="x64"
$Artifact="host" $Artifact="host"
$BuildType="Debug"
$Variant="-DBUILD_HOST=1" $Variant="-DBUILD_HOST=1"
# Directory for CMake to build and store intermediate files # Directory for CMake to build and store intermediate files

View File

@@ -398,6 +398,8 @@ SWIGINTERN void SWIG_CSharpException(int code, const char* msg)
extern "C" { extern "C" {
#endif #endif
#ifndef ZTS_DISABLE_CENTRAL_API
SWIGEXPORT int SWIGSTDCALL CSharp_zts_central_set_access_mode(char jarg1) SWIGEXPORT int SWIGSTDCALL CSharp_zts_central_set_access_mode(char jarg1)
{ {
int jresult; int jresult;
@@ -597,6 +599,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_central_net_get_members(void* jarg1, unsig
return jresult; return jresult;
} }
#endif // ZTS_DISABLE_CENTRAL_API
SWIGEXPORT int SWIGSTDCALL CSharp_zts_id_new(char* jarg1, void* jarg2) SWIGEXPORT int SWIGSTDCALL CSharp_zts_id_new(char* jarg1, void* jarg2)
{ {
int jresult; int jresult;