|
1 | 1 | cmake_minimum_required(VERSION 3.12)
|
2 | 2 | project(bourne)
|
3 | 3 |
|
4 |
| -if(NOT DEFINED STEINWURF_TOP_NAME) |
| 4 | +find_package(Python COMPONENTS Interpreter) |
| 5 | + |
| 6 | +# Use waf to resolve dependencies |
| 7 | +if(NOT DEFINED STEINWURF_RESOLVE) |
| 8 | + message(STATUS "Resolving dependencies...") |
| 9 | + execute_process( |
| 10 | + COMMAND ${Python_EXECUTABLE} waf resolve ${STEINWURF_RESOLVE_OPTIONS} |
| 11 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 12 | + RESULT_VARIABLE STATUS) |
| 13 | + |
| 14 | + if(STATUS AND NOT STATUS EQUAL 0) |
| 15 | + message(FATAL_ERROR "Failed: ${STATUS}") |
| 16 | + endif() |
| 17 | + |
| 18 | + set(STEINWURF_RESOLVE "${CMAKE_CURRENT_SOURCE_DIR}/resolve_symlinks") |
5 | 19 | set(STEINWURF_TOP_NAME bourne)
|
6 | 20 | endif()
|
7 | 21 |
|
@@ -41,4 +55,28 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
41 | 55 | # Build executables
|
42 | 56 | add_executable(example examples/example.cpp)
|
43 | 57 | target_link_libraries(example bourne)
|
| 58 | + |
| 59 | + enable_testing() |
| 60 | + |
| 61 | + if(CMAKE_C_COMPILER_ID MATCHES "MSVC") |
| 62 | + # For Windows: Prevent overriding the parent project's compiler/linker |
| 63 | + # settings |
| 64 | + set(gtest_force_shared_crt |
| 65 | + ON |
| 66 | + CACHE BOOL "" FORCE) |
| 67 | + endif() |
| 68 | + |
| 69 | + # Google Test dependency |
| 70 | + add_subdirectory("${STEINWURF_RESOLVE}/gtest-source") |
| 71 | + |
| 72 | + # Build test executable |
| 73 | + file(GLOB_RECURSE bourne_test_sources ./test/*.cpp) |
| 74 | + add_executable(bourne_test ${bourne_test_sources}) |
| 75 | + target_link_libraries(bourne_test gtest_main) |
| 76 | + target_link_libraries(bourne_test steinwurf::bourne) |
| 77 | + |
| 78 | + # Copy test/test.json to build directory |
| 79 | + file(COPY test/test.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
| 80 | + |
| 81 | + add_test(bourne_test bourne_test) |
44 | 82 | endif()
|
0 commit comments