添加Android配置
This commit is contained in:
@@ -11,6 +11,19 @@ if (${TARGET_SYSTEM_NAME} STREQUAL "Linux")
|
||||
elseif (${TARGET_SYSTEM_NAME} STREQUAL "Windows")
|
||||
add_definitions(-DBUILD_WINDOWS=1)
|
||||
message("以Windows为构建目标")
|
||||
elseif(${TARGET_SYSTEM_NAME} STREQUAL "Android")
|
||||
if (NOT DEFINED NDK_PATH)
|
||||
message(FATAL_ERROR "没有设置NDK_PATH路径!")
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED ANDROID_ABI)
|
||||
message(FATAL_ERROR "没有设置ANDROID_ABI!")
|
||||
endif ()
|
||||
set(ANDROID_NDK ${NDK_PATH}) # 设置ndk路径
|
||||
set(CMAKE_TOOLCHAIN_FILE ${NDK_PATH}/build/cmake/android.toolchain.cmake)
|
||||
set(ANDROID_SDK_ROOT ${NDK_PATH})
|
||||
add_definitions(-DBUILD_ANDROID=1)
|
||||
message("以Android为构建目标")
|
||||
else ()
|
||||
message(FATAL_ERROR "未知的目标操作系统")
|
||||
endif ()
|
||||
|
||||
@@ -26,4 +26,13 @@ if(NOT DEFINED PROTOBUF_LIB_PATH)
|
||||
else ()
|
||||
message("手动指定protobuf库为${PROTOBUF_LIB_PATH}")
|
||||
endif ()
|
||||
target_link_libraries(Transmission ${PROTOBUF_LIB_PATH} proto lzma)
|
||||
if(DEFINED PROTOBUF_INCLUDE_PATH)
|
||||
message("手动指定protobuf头文件路径为${PROTOBUF_INCLUDE_PATH}")
|
||||
target_include_directories(proto PUBLIC ${PROTOBUF_INCLUDE_PATH})
|
||||
endif ()
|
||||
if(NOT DEFINED LZMA_LIB_PATH)
|
||||
set(LZMA_LIB_PATH "lzma")
|
||||
else ()
|
||||
message("手动指定LZMA库为${LZMA_LIB_PATH}")
|
||||
endif ()
|
||||
target_link_libraries(Transmission ${PROTOBUF_LIB_PATH} proto ${LZMA_LIB_PATH})
|
||||
@@ -19,6 +19,10 @@
|
||||
#include <io.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#ifdef BUILD_ANDROID
|
||||
#include <sys/socket.h>
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include "CharBuff.h"
|
||||
|
||||
Reference in New Issue
Block a user