cmake 添加测试模板
parent
b452eae0c7
commit
aa743a87b4
|
@ -10,4 +10,5 @@ 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)
|
||||
add_executable(tcptest src/tcpclient_test.cpp src/patterntest/pattern_test.cpp)
|
||||
add_executable(tcptest src/tcpclient_test.cpp src/patterntest/pattern_test.cpp)
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
|
||||
string(REGEX REPLACE "(.*)/(.*)/(.*)" "\\1" PARENTPATH ${CMAKE_CURRENT_LIST_FILE})
|
||||
message("parent path is " ${PARENTPATH})
|
||||
|
||||
include_directories(${PARENTPATH}/obj/inc)
|
||||
include_directories(${PARENTPATH}/obj/inc/third/include)
|
||||
|
||||
message("incldue " ${PARENTPATH}/obj/inc/third/include)
|
||||
|
||||
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# using Clang
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# using GCC
|
||||
link_directories(${PARENTPATH}/cmake-build-debug/libgenerallib.a)
|
||||
link_libraries(libGeneral.a)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
|
||||
# using Intel C++
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
|
||||
# using Visual Studio C++
|
||||
link_libraries(ws2_32)
|
||||
link_libraries(${PARENTPATH}/general/third/lib/libevent.a)
|
||||
link_libraries(${PARENTPATH}/general/third/lib/libevent_core.a)
|
||||
|
||||
endif()
|
||||
|
||||
|
|
@ -6,14 +6,20 @@ message("project dir " ${PROJECT_SOURCE_DIR})
|
|||
|
||||
set(CMAKE_BUILD_TYPE DEBUG)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "/OPT:NOREF /MTd /std:c++14 /EHsc /MTd")
|
||||
set(CMAKE_CXX_FLAGS "/OPT:NOREF /std:c++14 /EHsc /MTd")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
|
||||
string(REGEX REPLACE "(.*)/(.*)/(.*)" "\\1" PARENTPATH ${PROJECT_SOURCE_DIR})
|
||||
message("last=" ${PARENTPATH})
|
||||
|
||||
include_directories(E:\\conan_data\\gtest\\1.0\\_\\_\\package\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\include)
|
||||
link_directories(E:\\conan_data\\gtest\\1.0\\_\\_\\package\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\lib)
|
||||
include(${PARENTPATH}/CmakeTemplate.txt)
|
||||
include_directories(./third/gtest/include)
|
||||
link_directories(./third/gtest/lib)
|
||||
|
||||
link_libraries(gtestd.lib gtest_maind.lib gmockd.lib gmock_maind.lib)
|
||||
|
||||
# include(${CMAKE_CURRENT_SOURCE_DIR}/../CmakeTemplate.txt)
|
||||
|
||||
add_executable(gtest_demo gtest_demo.cpp)
|
||||
|
||||
set_property(TARGET gtest_demo PROPERTY
|
||||
|
|
|
@ -1,13 +1,26 @@
|
|||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2022-03-23 20:41:42
|
||||
* @LastEditTime: 2022-03-23 21:00:44
|
||||
* @LastEditors: your name
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \gtest_demo\gtest_demo.cpp
|
||||
*/
|
||||
#include<gtest/gtest.h>
|
||||
|
||||
#include "function/cpu_usage.h"
|
||||
|
||||
int add(int a,int b){
|
||||
return a+b;
|
||||
}
|
||||
|
||||
TEST(testCase,test0){
|
||||
EXPECT_EQ(add(2,3),5);
|
||||
}
|
||||
|
||||
int main(int argc,char **argv){
|
||||
testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue