From f645cff22c1d8910b29522415de649981e660cb0 Mon Sep 17 00:00:00 2001
From: a7458969 <290198252@qq.com>
Date: Wed, 22 Apr 2020 00:45:50 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=8C=85=E7=BB=84=E5=90=88?=
=?UTF-8?q?=E6=88=90=E4=B8=80=E4=B8=AA=E5=8C=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 4 +++-
CMakeLists.txt | 10 ++++++----
cmake-build-debug/CMakeCache.txt | 3 +++
src/net/TcpClient.cpp | 4 ++++
src/net/TcpClient.h | 1 +
test/CMakeLists.txt | 3 +++
6 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5d223c9..5d9871f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -14,10 +14,10 @@
+
-
@@ -118,6 +118,8 @@
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 801814f..f8881ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.11)
project(General)
-
+set(MINGW_PATH $ENV{MINGW_TOOLCHAIN})
+message("path is " ${MINGW_PATH})
message( "libevent path " ${CONAN_LIBEVENT_ROOT})
message( "current compiler " ${CMAKE_CXX_COMPILER_ID})
@@ -24,8 +25,12 @@ include_directories(third/include)
aux_source_directory(src DIRSRCS)
aux_source_directory(src/pattern PaternSrc)
+
add_library(General ${DIRSRCS} ${PaternSrc} src/pattern/signleton.h src/pattern/Observer.h src/pattern/stratergy.h src/pattern/adapter.h src/encrypt/base64.cpp src/encrypt/base64.h src/encrypt/aes.cpp src/encrypt/aes.h src/encrypt/rsa.cpp
src/math/BigInt.hpp src/net/TcpClient.cpp src/net/TcpClient.h src/net/PackageReceiver.cpp src/net/PackageReceiver.h)
+set_target_properties(General PROPERTIES LINKER_LANGUAGE CXX)
+target_link_libraries(General -Wl,--whole-archive third/lib/libevent.a third/lib/libevent_core.a)
+
set(COPYITEM inc)
file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*)
file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
@@ -54,9 +59,6 @@ message( "copy net ")
file(GLOB NET ${PROJECT_SOURCE_DIR}/src/net/*.h)
file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
-link_libraries(third/lib/libevent.a)
-link_libraries(third/lib/libevent_core.a)
-
IF (WIN32)
ELSEIF (UNIX)
diff --git a/cmake-build-debug/CMakeCache.txt b/cmake-build-debug/CMakeCache.txt
index d321622..9a963b6 100644
--- a/cmake-build-debug/CMakeCache.txt
+++ b/cmake-build-debug/CMakeCache.txt
@@ -238,6 +238,9 @@ CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
//Value Computed by CMake
General_BINARY_DIR:STATIC=D:/project/c++/generallib/cmake-build-debug
+//Dependencies for the target
+General_LIB_DEPENDS:STATIC=general;-Wl,--whole-archive;general;third/lib/libevent.a;general;third/lib/libevent_core.a;
+
//Value Computed by CMake
General_SOURCE_DIR:STATIC=D:/project/c++/generallib
diff --git a/src/net/TcpClient.cpp b/src/net/TcpClient.cpp
index 6d4243a..13277ff 100644
--- a/src/net/TcpClient.cpp
+++ b/src/net/TcpClient.cpp
@@ -179,3 +179,7 @@ int TcpClientLibevent::SetObserver(TcpClientLibevent::TcpClientObserver *ob) {
int TcpClientLibevent::Dispatch() {
return event_base_dispatch(mBase);;
}
+
+TcpClientLibevent::~TcpClientLibevent() {
+
+}
diff --git a/src/net/TcpClient.h b/src/net/TcpClient.h
index 771384b..7e71946 100644
--- a/src/net/TcpClient.h
+++ b/src/net/TcpClient.h
@@ -33,6 +33,7 @@ public:
};
TcpClientLibevent(std::string addrinfo,int port, TcpClientObserver *p);
+ ~TcpClientLibevent();
int ConnectServer();
bool Connected();
int Dispatch();
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6680280..820f2da 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,4 +8,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../obj/inc/third/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../obj/)
link_libraries(libGeneral.a)
link_libraries(ws2_32)
+link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent.a)
+link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent_core.a)
+link_libraries(ws2_32)
add_executable(tcptest src/tcpclient_test.cpp)
\ No newline at end of file