diff --git a/CMakeLists.txt b/CMakeLists.txt index 10b5f10..f0af8d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,28 +3,9 @@ enable_language(CXX) project(generallib) add_subdirectory(general) -find_package(libevent REQUIRED) -set(EVENT__HAVE_LIBEVENT 1) -message(STATUS "PATH: " $ENV{CMAKE_MODULE_PATH}) - -message(STATUS "libevent include: " ${libevent_INCLUDE_DIRS}) -message(STATUS "libevent lib: " ${libevent_INCLUDE_DIR}) -message(STATUS "libevent lib Dirs: " ${libevent_LIB_DIRS}) - SET(SRC_SDK sdk_main.c )#生成动态库需要至少包含一个源文件 add_library(generallib STATIC $ ${SRC_SDK}) -message("CMAKE_BINARY_DIR is " ${CMAKE_BINARY_DIR}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libd) -link_directories(${libevent_LIB_DIRS}) -set_target_properties(generallib PROPERTIES LINKER_LANGUAGE CXX) -target_link_libraries(generallib public - -Wl,--whole-archive - libevent.a - -Wl,--no-whole-archive -) - - message("current path is" ${CMAKE_CURRENT_SOURCE_DIR}) IF (WIN32) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") diff --git a/general/CMakeLists.txt b/general/CMakeLists.txt index 74f5958..db56e2b 100644 --- a/general/CMakeLists.txt +++ b/general/CMakeLists.txt @@ -3,7 +3,6 @@ enable_language(CXX) project(General) message( "current compiler " ${CMAKE_CXX_COMPILER_ID}) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # using Clang elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") @@ -32,7 +31,11 @@ INCLUDE_DIRECTORIES (pattern) include_directories(third/include) aux_source_directory(src DIRSRCS) aux_source_directory(src/pattern PaternSrc) +aux_source_directory(src/function FunctionSrc) +aux_source_directory(src/algorithm AlgorithmSrc) +aux_source_directory(src/net NetSrc) +aux_source_directory(src/encrypt EncryptSrc) +message("source file is " ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${NetSrc} ${FunctionSrc} ${AlgorithmSrc}) -add_library(General OBJECT ${DIRSRCS} ${PaternSrc} src/pattern/signleton.hpp src/pattern/cmd.hpp src/pattern/Observer.hpp src/pattern/stratergy.hpp "src/pattern/adapter.hpp" 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 src/function/Timer.cpp src/function/btree.cpp src/function/btree.h src/algorithm/sorter.hpp) +add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${NetSrc} ${FunctionSrc} ${AlgorithmSrc} ) diff --git a/test/src/cpp11/CMakeLists.txt b/test/src/cpp11/CMakeLists.txt index fd73dcb..03dc733 100644 --- a/test/src/cpp11/CMakeLists.txt +++ b/test/src/cpp11/CMakeLists.txt @@ -1,13 +1,14 @@ cmake_minimum_required(VERSION 3.12) project(cpp11) +add_definitions(-std=c++11) message("current dir" ${CMAKE_CURRENT_SOURCE_DIR}) # set(CMAKE_CXX_FLAGS "-fno-elide-constructors") aux_source_directory(. SOURCE) message(info ${SOURCE}) +link_directories("./third/jsoncpp/lib/") +link_libraries(jsoncpp) add_executable(cpp11 ${SOURCE} ) include_directories("./third/jsoncpp/include/pkgsrc/include/json") -link_libraries("./third/jsoncpp/lib/") -add_library(jsoncpp STATIC IMPORTED) # target_link_libraries(cpp11 "jsoncpp") diff --git a/test/src/cpp11/conanfile.txt b/test/src/cpp11/conanfile.txt new file mode 100644 index 0000000..852c13c --- /dev/null +++ b/test/src/cpp11/conanfile.txt @@ -0,0 +1,4 @@ +[requires] +jsoncpp/1.1.1 +[imports] +.,* -> ./third @ folder=True, ignore_case=True, excludes=*.html *.jpeg \ No newline at end of file diff --git a/test/src/cpp11/thread_usage.cpp b/test/src/cpp11/thread_usage.cpp index 1be543a..bdf9c5b 100644 --- a/test/src/cpp11/thread_usage.cpp +++ b/test/src/cpp11/thread_usage.cpp @@ -148,10 +148,22 @@ class TestTask : public general::Task public: void Run() { - for(int i = 0;i < 50000; i++){ - + for (int i = 0;i < 100; i ++){ + std::string strValue = "{\"key\":\"value1\",\ + \"array\":[{\"arraykey\":1},{\"arraykey\":2}]}"; + + Json::Reader reader; + Json::Reader reader1; + Json::Reader reader2; + + Json::Value root; + Json::Value root1; + Json::Value root2; + + reader.parse(strValue, root); + reader1.parse(strValue, root1); + reader2.parse(strValue, root2); } - std::cout<<"end"<(t2-t1).count(); + double dr_ms = std::chrono::duration(t2-t1).count(); std::cout<<"count is "<mThreadCnt = num; mStarted = false; - if (num < 2){ - mThreadCnt = 2; - } - mStoping = false; + } int CThreadPool::AddTask(Task *t){ diff --git a/test/src/tcptest/CMakeLists.txt b/test/src/tcptest/CMakeLists.txt index 267f8f9..4d772cf 100644 --- a/test/src/tcptest/CMakeLists.txt +++ b/test/src/tcptest/CMakeLists.txt @@ -2,17 +2,21 @@ cmake_minimum_required(VERSION 3.11) project(tcptest) message("cmake module " $ENV{CMAKE_MODULE_PATH}) message("project dir " ${PROJECT_SOURCE_DIR}) -message("current dir " ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../build) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../obj) +link_directories(${CMAKE_CURRENT_SOURCE_DIR}/third/lib) link_libraries(libgenerallib.a) +link_libraries(libevent.a) +link_libraries(libevent_core.a) link_libraries(ws2_32) -link_libraries(libevent.la) -link_libraries(libevent_core.la) +link_libraries(bcrypt) +link_libraries(Iphlpapi.lib) add_executable(tcptest tcpclient_test.cpp) -target_include_directories(tcptest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include()) +target_include_directories(tcptest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include) diff --git a/test/src/tcptest/conanfile.txt b/test/src/tcptest/conanfile.txt new file mode 100644 index 0000000..583eb6a --- /dev/null +++ b/test/src/tcptest/conanfile.txt @@ -0,0 +1,8 @@ +[requires] +libevent/2.1.2 +[imports] +lib, *.a -> ./third/lib # Copies all dll files from packages bin folder to my "bin" folder +include, *.h -> ./third/include # Copies all dll files from packages bin folder to my "bin" folder +include, *.hpp -> ./third/include # Copies all dll files from packages bin folder to my "bin" folder + + diff --git a/test/src/tcptest/tcpclient_test.cpp b/test/src/tcptest/tcpclient_test.cpp index b25723b..cc29f22 100644 --- a/test/src/tcptest/tcpclient_test.cpp +++ b/test/src/tcptest/tcpclient_test.cpp @@ -5,4 +5,5 @@ using namespace std; int main(){ TcpClientLibevent mTcp("127.0.0.1",8443, nullptr); + } \ No newline at end of file