|
1 | 1 | cmake_minimum_required(VERSION 3.13)
|
2 | 2 |
|
3 |
| -message(STATUS "cmake in tests, project name ${PROJECT_NAME}" ) |
4 |
| - |
5 | 3 | set(CMAKE_CXX_STANDARD 11)
|
6 | 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
7 | 5 |
|
8 |
| -add_executable(test_circularbuffer_int test_circularbuffer_int.cpp) |
9 |
| -target_link_libraries(test_circularbuffer_int |
10 |
| - PRIVATE |
| 6 | +message(STATUS "cmake in tests, project name ${PROJECT_NAME}" ) |
| 7 | + |
| 8 | +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) |
| 9 | +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . |
| 10 | + RESULT_VARIABLE result |
| 11 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download |
| 12 | + ) |
| 13 | +if(result) |
| 14 | + message(FATAL_ERROR "CMake step for googletest failed: ${result}") |
| 15 | +endif() |
| 16 | + |
| 17 | +execute_process(COMMAND ${CMAKE_COMMAND} --build . |
| 18 | + RESULT_VARIABLE result |
| 19 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download |
| 20 | + ) |
| 21 | + |
| 22 | +if(result) |
| 23 | + message(FATAL_ERROR "Build step for googletest failed: ${result}") |
| 24 | +endif() |
| 25 | + |
| 26 | +# Prevent overriding the parent project's compiler/linker |
| 27 | +# settings on Windows |
| 28 | +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 29 | + |
| 30 | +# Add googletest directly to our build. This defines |
| 31 | +# the gtest and gtest_main targets. |
| 32 | +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src |
| 33 | + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build |
| 34 | + EXCLUDE_FROM_ALL) |
| 35 | + |
| 36 | +add_executable(circularbuffer_int circularbuffer_int.cpp) |
| 37 | +target_link_libraries(circularbuffer_int |
11 | 38 | circularbuffer
|
12 |
| - /usr/local/lib/libgtest.a |
13 |
| - pthread |
| 39 | + gtest_main |
14 | 40 | )
|
| 41 | +add_test(NAME test_circularbuffer_int COMMAND circularbuffer_int) |
0 commit comments