Commit 6cbeb0a3 authored by Alastair Robertson's avatar Alastair Robertson

Include GTest in builds

parent 9eb6e51a
cmake_minimum_required(VERSION 2.8.12)
project(bpftrace)
add_compile_options("-std=c++14")
add_compile_options("-Wall")
add_compile_options("-Wextra")
add_compile_options("-Wundef")
add_compile_options("-Wpointer-arith")
add_compile_options("-Wcast-align")
add_compile_options("-Wwrite-strings")
add_compile_options("-Wcast-qual")
add_compile_options("-Wswitch-default")
add_compile_options("-Wswitch-enum")
add_compile_options("-Wconversion")
add_compile_options("-Wunreachable-code")
add_compile_options("-Wformat=2")
add_compile_options("-Wstrict-overflow=5")
add_compile_options("-Wdisabled-optimization")
add_compile_options("-pedantic")
enable_testing()
add_subdirectory(src)
add_subdirectory(tests)
......@@ -50,6 +50,8 @@ git clone https://github.com/ajor/bpftrace
cd bpftrace
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ../src
cmake -DCMAKE_BUILD_TYPE=Debug ../
make
```
The latest versions of BCC and Google Test will be downloaded on the first build. To update them later, the commands `make bcc-update` and `make gtest-update` can be run.
cmake_minimum_required(VERSION 2.8.12)
project(bpftrace)
add_compile_options("-std=c++14")
add_compile_options("-Wall")
add_compile_options("-Wextra")
add_compile_options("-Wundef")
add_compile_options("-Wpointer-arith")
add_compile_options("-Wcast-align")
add_compile_options("-Wwrite-strings")
add_compile_options("-Wcast-qual")
add_compile_options("-Wswitch-default")
add_compile_options("-Wswitch-enum")
add_compile_options("-Wconversion")
add_compile_options("-Wunreachable-code")
add_compile_options("-Wformat=2")
add_compile_options("-Wstrict-overflow=5")
add_compile_options("-Wdisabled-optimization")
add_compile_options("-pedantic")
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
find_package(LLVM REQUIRED CONFIG)
......
add_compile_options("-Wno-undef")
add_compile_options("-Wno-switch-default")
add_compile_options("-Wno-switch-enum")
add_executable(bpftrace_test parser.cpp)
find_package(Threads REQUIRED)
include(ExternalProject)
ExternalProject_Add(gtest
GIT_REPOSITORY https://github.com/google/googletest.git
STEP_TARGETS build update
EXCLUDE_FROM_ALL 1
UPDATE_DISCONNECTED 1
)
add_dependencies(bpftrace_test gtest-build)
ExternalProject_Get_Property(gtest source_dir binary_dir)
include_directories(${source_dir}/googletest/include)
target_link_libraries(bpftrace_test ${binary_dir}/googlemock/gtest/libgtest.a)
target_link_libraries(bpftrace_test ${binary_dir}/googlemock/gtest/libgtest_main.a)
target_link_libraries(bpftrace_test ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME bpftrace_test COMMAND bpftrace_test)
#include "gtest/gtest.h"
TEST(test1, aaa)
{
}
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment