no message

master
zcy 2022-03-25 00:07:03 +08:00
parent 223c303e1e
commit fa6e8763bb
6 changed files with 29 additions and 9 deletions

View File

@ -4,8 +4,14 @@ project(generallib)
add_subdirectory(general) add_subdirectory(general)
SET(SRC_SDK sdk_main.c )# SET(SRC_SDK sdk_main.c )#
add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK}) add_library(generallib STATIC $<TARGET_OBJECTS:General> ${SRC_SDK})
set_property(TARGET generallib PROPERTY
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
message("current path is" ${CMAKE_CURRENT_SOURCE_DIR}) message("current path is" ${CMAKE_CURRENT_SOURCE_DIR})
IF (WIN32) IF (WIN32)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

View File

@ -38,4 +38,8 @@ aux_source_directory(src/encrypt EncryptSrc)
message("source file is " ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc}) message("source file is " ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc})
add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} ) add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} )
set_property(TARGET General PROPERTY
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)

View File

@ -1,5 +1,5 @@
#include "cpu_usage.h" #include "cpu_usage.h"
#include <iostream>
float CPUusage::get_cpu_usage() float CPUusage::get_cpu_usage()
{ {
@ -30,6 +30,7 @@ float CPUusage::get_cpu_usage()
clear(); clear();
return -1; return -1;
} }
std::cout<<"systime "<<FileTime2UTC(&kernel_time)<<"usertime " <<FileTime2UTC(&user_time)<<std::endl;
system_time = (FileTime2UTC(&kernel_time) + FileTime2UTC(&user_time)) system_time = (FileTime2UTC(&kernel_time) + FileTime2UTC(&user_time))
/ _processor; / _processor;
time = FileTime2UTC(&now); time = FileTime2UTC(&now);

View File

@ -12,20 +12,19 @@ message("incldue " ${PARENTPATH}/obj/inc/third/include)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang # using Clang
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC # using GCC
link_directories(${PARENTPATH}/cmake-build-debug/libgenerallib.a) link_directories(${PARENTPATH}/obj/Debug/)
link_libraries(libGeneral.a) link_libraries(generallib.lib)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++ # using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
# using Visual Studio C++ link_directories(${PARENTPATH}/obj/Debug/)
link_libraries(generallib.lib)
link_libraries(ws2_32) link_libraries(ws2_32)
link_libraries(${PARENTPATH}/general/third/lib/libevent.a)
link_libraries(${PARENTPATH}/general/third/lib/libevent_core.a)
endif() endif()

View File

@ -9,6 +9,7 @@ set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_CXX_FLAGS "/OPT:NOREF /std:c++14 /EHsc /MTd") set(CMAKE_CXX_FLAGS "/OPT:NOREF /std:c++14 /EHsc /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "") set(CMAKE_CXX_FLAGS_RELEASE "")
string(REGEX REPLACE "(.*)/(.*)/(.*)" "\\1" PARENTPATH ${PROJECT_SOURCE_DIR}) string(REGEX REPLACE "(.*)/(.*)/(.*)" "\\1" PARENTPATH ${PROJECT_SOURCE_DIR})
message("last=" ${PARENTPATH}) message("last=" ${PARENTPATH})
@ -23,6 +24,6 @@ link_libraries(gtestd.lib gtest_maind.lib gmockd.lib gmock_maind.lib)
add_executable(gtest_demo gtest_demo.cpp) add_executable(gtest_demo gtest_demo.cpp)
set_property(TARGET gtest_demo PROPERTY set_property(TARGET gtest_demo PROPERTY
MSVC_RUNTIME_LIBRARY MultiThreadedDebug) MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
target_include_directories(gtest_demo SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include) target_include_directories(gtest_demo SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include)

View File

@ -8,6 +8,7 @@
*/ */
#include<gtest/gtest.h> #include<gtest/gtest.h>
#include "function/cpu_usage.h" #include "function/cpu_usage.h"
#include <Windows.h>
int add(int a,int b){ int add(int a,int b){
return a+b; return a+b;
@ -17,6 +18,14 @@ TEST(testCase,test0){
EXPECT_EQ(add(2,3),5); EXPECT_EQ(add(2,3),5);
} }
TEST(testCase,test1){
CPUusage ussage1(21132);
while (1)
{
std::cout<<ussage1.get_cpu_usage()<<std::endl;
Sleep(1000);
}
}
int main(int argc,char **argv){ int main(int argc,char **argv){
testing::InitGoogleTest(&argc,argv); testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();