2017-12-07 15:39:45 -08:00
|
|
|
#
|
|
|
|
|
# ZeroTier SDK - Network Virtualization Everywhere
|
2019-01-14 12:01:29 -08:00
|
|
|
# Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
|
2017-12-07 15:39:45 -08:00
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2019-01-14 12:01:29 -08:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-12-07 15:39:45 -08:00
|
|
|
#
|
|
|
|
|
# --
|
|
|
|
|
#
|
|
|
|
|
# You can be released from the requirements of the license by purchasing
|
|
|
|
|
# a commercial license. Buying such a license is mandatory as soon as you
|
|
|
|
|
# develop commercial closed-source software that incorporates or links
|
|
|
|
|
# directly against ZeroTier software without disclosing the source code
|
|
|
|
|
# of your own application.
|
|
|
|
|
#
|
|
|
|
|
|
2018-07-19 17:19:06 -07:00
|
|
|
cmake_minimum_required (VERSION 3.0)
|
2018-08-21 13:43:03 -07:00
|
|
|
project (zt)
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-07-27 15:49:58 -07:00
|
|
|
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
|
set (CMAKE_SUPPRESS_REGENERATION true)
|
|
|
|
|
set (PROJ_DIR ${PROJECT_SOURCE_DIR})
|
|
|
|
|
set (CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/bin)
|
|
|
|
|
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
|
|
|
|
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
2018-08-21 13:43:03 -07:00
|
|
|
set (INCLUDE_PATH ${PROJ_DIR}/include)
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | BUILD CONFIG |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2018-07-26 12:02:08 -07:00
|
|
|
|
|
|
|
|
# Default build type: Release
|
2018-08-21 13:43:03 -07:00
|
|
|
|
|
|
|
|
# Release - Optimization and no debug info
|
|
|
|
|
# Debug - No optimization, debug info
|
|
|
|
|
# RelWithDebInfo - Release optimizations and debug info
|
|
|
|
|
# MinSizeRel - Similar to Release but with optimizations to minimize size
|
|
|
|
|
|
2018-07-27 15:49:58 -07:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set (CMAKE_BUILD_TYPE Release)
|
|
|
|
|
endif ()
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-07-27 15:49:58 -07:00
|
|
|
set (SILENCE "-Wno-unused-parameter -Wno-unused-variable -Wno-missing-field-initializers")
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | PLATFORM/FEATURE AND IDE DETECTION |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|
|
|
|
set (BUILDING_ANDROID TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (WIN32)
|
|
|
|
|
set (BUILDING_WIN32 TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if ("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
|
|
|
|
|
set (BUILDING_WIN64 TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
set (BUILDING_DARWIN TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
|
set (BUILDING_LINUX TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (${CMAKE_GENERATOR} STREQUAL "Xcode")
|
|
|
|
|
set (IN_XCODE TRUE)
|
|
|
|
|
set(XCODE_EMIT_EFFECTIVE_PLATFORM_NAME ON)
|
|
|
|
|
#set_target_properties (${STATIC_LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_MY_BUILD_ONLY_ACTIVE_ARCH YES)
|
|
|
|
|
#set_target_properties (${STATIC_LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "${MY_BUILD_ONLY_ACTIVE_ARCH})
|
|
|
|
|
endif ()
|
|
|
|
|
if (NOT BUILDING_ANDROID AND NOT IN_XCODE AND NOT BUILD_TESTS EQUAL 0)
|
|
|
|
|
set(SHOULD_BUILD_TESTS TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (BUILDING_WIN32 OR BUILDING_WIN64 OR MSVC)
|
|
|
|
|
set (BUILDING_WIN TRUE)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2018-08-23 10:22:55 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | JNI |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
MESSAGE (STATUS "Looking for JNI")
|
2018-08-24 15:45:05 -07:00
|
|
|
|
|
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
# We are only interested in finding jni.h: we do not care about extended JVM
|
|
|
|
|
# functionality or the AWT library.
|
2018-10-18 14:05:52 -07:00
|
|
|
#set(JAVA_AWT_LIBRARY NotNeeded)
|
|
|
|
|
#set(JAVA_JVM_LIBRARY NotNeeded)
|
|
|
|
|
#set(JAVA_INCLUDE_PATH2 NotNeeded)
|
|
|
|
|
#set(JAVA_AWT_INCLUDE_PATH NotNeeded)
|
2018-08-24 15:45:05 -07:00
|
|
|
set(JAVA_INCLUDE_PATH "C:\\Program Files\\Java\\jdk-10.0.2\\include")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-01-14 12:01:29 -08:00
|
|
|
set(JAVA_AWT_LIBRARY NotNeeded)
|
|
|
|
|
set(JAVA_JVM_LIBRARY NotNeeded)
|
|
|
|
|
set(JAVA_INCLUDE_PATH2 NotNeeded)
|
|
|
|
|
set(JAVA_AWT_INCLUDE_PATH NotNeeded)
|
|
|
|
|
find_package(JNI REQUIRED)
|
|
|
|
|
|
2018-08-23 10:22:55 -07:00
|
|
|
if (JNI_FOUND)
|
2019-01-14 12:01:29 -08:00
|
|
|
message (STATUS "JNI_INCLUDE_DIR=${JNI_INCLUDE_DIRS}")
|
2018-08-23 10:22:55 -07:00
|
|
|
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
|
|
|
|
|
list (GET JNI_INCLUDE_DIRS 0 JNI_INCLUDE_DIR)
|
|
|
|
|
message (STATUS "jni path=${JNI_INCLUDE_DIR}")
|
|
|
|
|
include_directories ("${JNI_INCLUDE_DIR}")
|
2019-01-14 12:01:29 -08:00
|
|
|
#include_directories ("${JNI_INCLUDE_DIRS}")
|
2018-08-23 10:22:55 -07:00
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
include_directories ("${JNI_INCLUDE_DIR}\\win32")
|
|
|
|
|
endif ()
|
2019-01-14 12:01:29 -08:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # on macOS
|
|
|
|
|
include_directories ("${JNI_INCLUDE_DIR}/darwin")
|
|
|
|
|
endif ()
|
2018-08-23 10:22:55 -07:00
|
|
|
else ()
|
|
|
|
|
message (STATUS "JNI not found")
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if ((BUILDING_ANDROID OR JNI) AND JNI_FOUND)
|
|
|
|
|
add_definitions (-DSDK_JNI=1)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | LWIP PORT |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
|
set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/port)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/win32)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | LIBRARY NAMES |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
2018-08-23 10:22:55 -07:00
|
|
|
if (IN_XCODE)
|
2018-08-21 13:43:03 -07:00
|
|
|
set (XCODE_FRAMEWORK_NAME ${PROJECT_NAME})
|
|
|
|
|
endif ()
|
|
|
|
|
|
2018-08-23 10:22:55 -07:00
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
# Possibly a CMake limitation? -- Can't share target output names
|
2018-08-21 13:43:03 -07:00
|
|
|
set (STATIC_LIB_NAME ${PROJECT_NAME}-static)
|
2018-08-23 10:22:55 -07:00
|
|
|
set (STATIC_LIB_OUTPUT_NAME ${PROJECT_NAME}-static)
|
2018-08-21 13:43:03 -07:00
|
|
|
set (DYNAMIC_LIB_NAME ${PROJECT_NAME}-shared)
|
2018-08-23 10:22:55 -07:00
|
|
|
set (DYNAMIC_LIB_OUTPUT_NAME ${PROJECT_NAME}-shared)
|
|
|
|
|
else ()
|
2018-08-21 13:43:03 -07:00
|
|
|
set (STATIC_LIB_NAME ${PROJECT_NAME}-static)
|
|
|
|
|
set (STATIC_LIB_OUTPUT_NAME ${PROJECT_NAME})
|
|
|
|
|
set (DYNAMIC_LIB_NAME ${PROJECT_NAME}-shared)
|
|
|
|
|
set (DYNAMIC_LIB_OUTPUT_NAME ${PROJECT_NAME})
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | FLAGS |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2017-12-15 16:26:27 -08:00
|
|
|
|
2019-01-14 12:01:29 -08:00
|
|
|
set (LIBZT_FLAGS "-DZT_SDK=1 -D_USING_LWIP_DEFINITIONS_=1")
|
2018-07-27 15:49:58 -07:00
|
|
|
set (LIBZT_FLAGS_DEBUG "-DZT_SDK=1 -DLIBZT_TRACE=1 -DLWIP_DEBUG=1 -DLIBZT_DEBUG=1 -DNS_TRACE=1 -DNS_DEBUG=1")
|
|
|
|
|
|
2018-10-17 18:08:26 -07:00
|
|
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBZT_FLAGS_DEBUG}")
|
|
|
|
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${LIBZT_FLAGS_DEBUG}")
|
|
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_WIN)
|
2018-07-27 15:49:58 -07:00
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNOMINMAX")
|
|
|
|
|
else ()
|
|
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
|
|
|
|
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fstack-protector")
|
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBZT_FLAGS} ${SILENCE} -O3 -Wall -Wextra -std=c++11")
|
2018-10-17 18:08:26 -07:00
|
|
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SILENCE} -std=c++11")
|
2018-07-27 15:49:58 -07:00
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBZT_FLAGS} ${SILENCE} -O3 -std=c++11")
|
|
|
|
|
endif ()
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-10-17 18:08:26 -07:00
|
|
|
#set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
|
|
|
|
#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
|
|
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | SOURCE FILE GLOBS |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
2018-08-22 10:49:21 -07:00
|
|
|
set (LWIP_SRC_DIR "${PROJ_DIR}/ext/lwip/src")
|
|
|
|
|
set (ZTO_SRC_DIR "${PROJ_DIR}/ext/ZeroTierOne")
|
|
|
|
|
set (LIBZT_SRC_DIR "${PROJ_DIR}/src")
|
|
|
|
|
|
|
|
|
|
include_directories ("${LIBZT_SRC_DIR}")
|
2019-01-25 12:42:53 -08:00
|
|
|
include_directories ("${ZTO_SRC_DIR}/include")
|
2019-01-14 12:01:29 -08:00
|
|
|
include_directories ("${PROJ_DIR}")
|
2018-08-22 10:49:21 -07:00
|
|
|
include_directories ("${ZTO_SRC_DIR}/osdep")
|
|
|
|
|
include_directories ("${ZTO_SRC_DIR}/node")
|
|
|
|
|
include_directories ("${ZTO_SRC_DIR}/service")
|
|
|
|
|
include_directories ("${PROJ_DIR}/include")
|
|
|
|
|
include_directories ("${LWIP_SRC_DIR}/include")
|
|
|
|
|
include_directories ("${LWIP_PORT_DIR}/include")
|
2018-08-21 13:43:03 -07:00
|
|
|
|
|
|
|
|
file (GLOB lwipSrcGlob
|
|
|
|
|
${LWIP_SRC_DIR}/netif/*.c
|
|
|
|
|
${LWIP_SRC_DIR}/api/*.c
|
|
|
|
|
${LWIP_PORT_DIR}/sys_arch.c
|
|
|
|
|
${LWIP_SRC_DIR}/core/*.c
|
|
|
|
|
${LWIP_SRC_DIR}/core/ipv4/*.c
|
|
|
|
|
${LWIP_SRC_DIR}/core/ipv6/*.c)
|
|
|
|
|
list(REMOVE_ITEM lwipSrcGlob ${LWIP_SRC_DIR}/netif/slipif.c)
|
|
|
|
|
|
|
|
|
|
file (GLOB ztoSrcGlob
|
|
|
|
|
${ZTO_SRC_DIR}/node/*.cpp
|
|
|
|
|
${ZTO_SRC_DIR}/service/*.cpp
|
|
|
|
|
${ZTO_SRC_DIR}/osdep/OSUtils.cpp
|
|
|
|
|
${ZTO_SRC_DIR}/controller/*.cpp
|
|
|
|
|
${ZTO_SRC_DIR}/osdep/ManagedRoute.cpp)
|
|
|
|
|
|
|
|
|
|
file (GLOB libztSrcGlob ${LIBZT_SRC_DIR}/*.cpp)
|
|
|
|
|
|
|
|
|
|
file (GLOB ExampleAppSrcGlob
|
|
|
|
|
${PROJ_DIR}/examples/cpp/*.cpp
|
|
|
|
|
${PROJ_DIR}/examples/cpp/ipv4simple/*.cpp
|
|
|
|
|
${PROJ_DIR}/examples/cpp/ipv6simple/*.cpp
|
|
|
|
|
${PROJ_DIR}/examples/cpp/ipv6adhoc/*.cpp
|
|
|
|
|
${PROJ_DIR}/examples/cpp/sharedlib/*.cpp
|
|
|
|
|
${PROJ_DIR}/examples/ztproxy/*.cpp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# header globs for xcode frameworks
|
|
|
|
|
file (GLOB frameworkPrivateHeaderGlob
|
|
|
|
|
${INCLUDE_PATH}/libzt.h
|
|
|
|
|
${INCLUDE_PATH}/libztDebug.h)
|
|
|
|
|
file (GLOB frameworkPublicHeaderGlob ${INCLUDE_PATH}/Xcode-Bridging-Header.h)
|
|
|
|
|
file (GLOB frameworkHeaderGlob ${frameworkPublicHeaderGlob} ${frameworkPrivateHeaderGlob})
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | PLATFORM-SPECIFIC CONFIG |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2018-07-26 12:02:08 -07:00
|
|
|
|
2018-07-27 09:53:08 -07:00
|
|
|
# ANDROID-specific
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_ANDROID)
|
2018-07-27 15:49:58 -07:00
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DSOCKLEN_T_DEFINED=1")
|
2018-08-09 16:27:53 -07:00
|
|
|
set (ANDROID_NDK /Users/$ENV{USER}/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi)
|
|
|
|
|
include_directories (${ANDROID_NDK})
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
2017-12-07 15:39:45 -08:00
|
|
|
|
2018-07-26 12:02:08 -07:00
|
|
|
# WINDOWS-specific MSVC flags and libraries
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_WIN)
|
2018-07-31 21:10:06 -07:00
|
|
|
# 32-bit
|
2018-08-21 13:43:03 -07:00
|
|
|
if(NOT BUILDING_WIN64)
|
2018-07-31 21:10:06 -07:00
|
|
|
set (WINLIBDIR, "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x86")
|
|
|
|
|
endif ()
|
|
|
|
|
# 64-bit
|
2018-08-21 13:43:03 -07:00
|
|
|
if(BUILDING_WIN64)
|
2018-07-31 21:10:06 -07:00
|
|
|
set (WINLIBDIR, "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64")
|
|
|
|
|
endif ()
|
2018-08-23 10:22:55 -07:00
|
|
|
#find_library (ws2_32_LIBRARY_PATH NAMES WS2_32 HINTS ${WINLIBDIR})
|
|
|
|
|
#find_library (shlwapi_LIBRARY_PATH NAMES ShLwApi HINTS ${WINLIBDIR})
|
|
|
|
|
set (ws2_32_LIBRARY_PATH "${WINLIBDIR}/WS2_32.Lib")
|
|
|
|
|
set (shlwapi_LIBRARY_PATH "${WINLIBDIR}/ShLwApi.Lib")
|
2018-07-31 17:18:32 -07:00
|
|
|
set (iphlpapi_LIBRARY_PATH "${WINLIBDIR}/iphlpapi.Lib")
|
2018-07-31 21:10:06 -07:00
|
|
|
message (STATUS ${WINLIBDIR})
|
2018-07-31 17:18:32 -07:00
|
|
|
message (STATUS "WS2_32=${ws2_32_LIBRARY_PATH}")
|
|
|
|
|
message (STATUS "ShLwApi=${shlwapi_LIBRARY_PATH}")
|
|
|
|
|
message (STATUS "liphlpapi=${iphlpapi_LIBRARY_PATH}")
|
2018-07-27 15:49:58 -07:00
|
|
|
add_definitions (-DZT_SDK=1)
|
2018-07-31 21:10:06 -07:00
|
|
|
add_definitions (-DADD_EXPORTS=1)
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
2018-07-19 17:19:06 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | OBJECTS-PIC (INTERMEDIATE) |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2017-12-15 16:26:27 -08:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
add_library (lwip_pic ${lwipSrcGlob})
|
|
|
|
|
set_target_properties (lwip_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
add_library (zto_pic ${ztoSrcGlob})
|
|
|
|
|
set_target_properties (zto_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
add_library (http_pic "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
|
|
|
|
set_target_properties (http_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | OBJECT LIBRARIES (INTERMEDIATE) |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2018-07-31 21:10:06 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# lwip_obj
|
|
|
|
|
add_library (lwip_obj OBJECT ${lwipSrcGlob})
|
|
|
|
|
# zto_obj
|
|
|
|
|
add_library (zto_obj OBJECT ${ztoSrcGlob})
|
|
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
target_link_libraries (zto_obj ws2_32)
|
|
|
|
|
target_link_libraries (zto_obj ${shlwapi_LIBRARY_PATH})
|
|
|
|
|
target_link_libraries (zto_obj ${iphlpapi_LIBRARY_PATH})
|
|
|
|
|
endif ()
|
|
|
|
|
# http_obj
|
|
|
|
|
add_library (http_obj OBJECT "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | LIBZT BUILD TARGETS (FINAL PRODUCT) |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# static
|
|
|
|
|
add_library (${STATIC_LIB_NAME} STATIC
|
2018-07-27 09:53:08 -07:00
|
|
|
$<TARGET_OBJECTS:lwip_obj>
|
|
|
|
|
$<TARGET_OBJECTS:zto_obj>
|
2018-08-21 13:43:03 -07:00
|
|
|
$<TARGET_OBJECTS:http_obj> ${libztSrcGlob})
|
2018-08-23 10:22:55 -07:00
|
|
|
set_target_properties (${STATIC_LIB_NAME} PROPERTIES OUTPUT_NAME ${STATIC_LIB_OUTPUT_NAME})
|
2018-07-27 09:53:08 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# dynamic
|
|
|
|
|
add_library (${DYNAMIC_LIB_NAME} SHARED ${libztSrcGlob})
|
|
|
|
|
message (STATUS ${libztSrcGlob})
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} lwip_pic zto_pic http_pic)
|
2018-08-23 10:22:55 -07:00
|
|
|
set_target_properties (${DYNAMIC_LIB_NAME} PROPERTIES OUTPUT_NAME ${DYNAMIC_LIB_OUTPUT_NAME})
|
2018-08-21 13:43:03 -07:00
|
|
|
set_target_properties (${DYNAMIC_LIB_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true)
|
2018-08-22 10:49:21 -07:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2018-07-27 15:49:58 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_ANDROID)
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} android log)
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
|
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_WIN)
|
|
|
|
|
target_link_libraries (${STATIC_LIB_NAME} ws2_32)
|
|
|
|
|
target_link_libraries (${STATIC_LIB_NAME} ${shlwapi_LIBRARY_PATH})
|
|
|
|
|
target_link_libraries (${STATIC_LIB_NAME} ${iphlpapi_LIBRARY_PATH})
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} ws2_32)
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} ${shlwapi_LIBRARY_PATH})
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} ${iphlpapi_LIBRARY_PATH})
|
2018-07-31 12:43:53 -07:00
|
|
|
endif ()
|
|
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (BUILDING_LINUX OR BUILDING_DARWIN)
|
|
|
|
|
target_link_libraries (${STATIC_LIB_NAME} pthread)
|
|
|
|
|
target_link_libraries (${DYNAMIC_LIB_NAME} pthread)
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
2018-07-27 09:53:08 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# xcode framework
|
|
|
|
|
if (IN_XCODE)
|
|
|
|
|
add_library(${XCODE_FRAMEWORK_NAME} STATIC
|
|
|
|
|
$<TARGET_OBJECTS:lwip_obj>
|
|
|
|
|
$<TARGET_OBJECTS:zto_obj>
|
|
|
|
|
$<TARGET_OBJECTS:http_obj>
|
|
|
|
|
${libztSrcGlob}
|
|
|
|
|
${frameworkHeaderGlob})
|
2018-07-27 09:53:08 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
set_target_properties(${XCODE_FRAMEWORK_NAME} PROPERTIES
|
|
|
|
|
FRAMEWORK TRUE
|
|
|
|
|
FRAMEWORK_VERSION A
|
|
|
|
|
DEFINES_MODULE TRUE
|
|
|
|
|
MACOSX_FRAMEWORK_IDENTIFIER com.cmake.${XCODE_FRAMEWORK_NAME}
|
2018-08-24 15:45:05 -07:00
|
|
|
MODULE_MAP "~/op/zt/libzt/packages/module.modulemap"
|
2018-08-21 13:43:03 -07:00
|
|
|
PUBLIC_HEADER "${frameworkHeaderGlob}"
|
|
|
|
|
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
|
|
|
|
)
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
2017-12-14 11:17:13 -08:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
# | TEST APPLICATIONS AND EXAMPLES |
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2017-12-14 16:29:44 -08:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (SHOULD_BUILD_TESTS)
|
2019-01-14 12:01:29 -08:00
|
|
|
# foreach (testsourcefile ${ExampleAppSrcGlob})
|
|
|
|
|
# string (REPLACE ".cpp" "" testname ${testsourcefile})
|
|
|
|
|
# get_filename_component (testname ${testname} NAME)
|
|
|
|
|
# add_executable (${testname} ${testsourcefile})
|
|
|
|
|
# if (BUILDING_WIN)
|
|
|
|
|
# target_link_libraries (${testname} ${STATIC_LIB_NAME})
|
|
|
|
|
# else ()
|
|
|
|
|
# target_link_libraries (${testname} ${STATIC_LIB_NAME} pthread dl)
|
|
|
|
|
# endif ()
|
|
|
|
|
# endforeach (testsourcefile ${ExampleAppSrcGlob})
|
2018-07-19 17:19:06 -07:00
|
|
|
|
2018-08-21 13:43:03 -07:00
|
|
|
if (NOT BUILDING_WIN) # only necessary for raw driver development
|
2018-07-19 17:19:06 -07:00
|
|
|
# selftest
|
2019-01-14 12:01:29 -08:00
|
|
|
#add_executable (selftest ${PROJ_DIR}/test/selftest.cpp)
|
|
|
|
|
#target_compile_options (selftest PRIVATE -D__SELFTEST__)
|
|
|
|
|
#if (BUILDING_WIN)
|
|
|
|
|
# target_link_libraries (selftest ${STATIC_LIB_NAME} ${ws2_32_LIBRARY_PATH} ${shlwapi_LIBRARY_PATH} ${iphlpapi_LIBRARY_PATH})
|
|
|
|
|
#else ()
|
|
|
|
|
# target_link_libraries (selftest ${STATIC_LIB_NAME} pthread)
|
|
|
|
|
#endif ()
|
2018-07-19 17:19:06 -07:00
|
|
|
# nativetest
|
2019-01-14 12:01:29 -08:00
|
|
|
#add_executable (nativetest ${PROJ_DIR}/test/selftest.cpp)
|
|
|
|
|
#target_compile_options (nativetest PRIVATE -D__NATIVETEST__)
|
2018-07-27 15:49:58 -07:00
|
|
|
endif ()
|
2018-08-21 13:43:03 -07:00
|
|
|
endif ()
|