| 1 | # Optional unit test |
| 2 | |
| 3 | if(BUILD_TESTS) |
| 4 | |
| 5 | find_package(Boost COMPONENTS unit_test_framework) |
| 6 | |
| 7 | if(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
| 8 | |
| 9 | message(STATUS "Building unit test") |
| 10 | |
| 11 | enable_testing() |
| 12 | |
| 13 | INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS}) |
| 14 | |
| 15 | set(cpp_tests |
| 16 | basic.cpp |
| 17 | baudrate.cpp |
| 18 | ) |
| 19 | |
| 20 | add_executable(test_libftdi1 ${cpp_tests}) |
| 21 | target_link_libraries(test_libftdi1 ftdi1 ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
| 22 | |
| 23 | add_test(test_libftdi1 test_libftdi1) |
| 24 | |
| 25 | # Add custom target so we run easily run "make check" |
| 26 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_libftdi1) |
| 27 | |
| 28 | else(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
| 29 | |
| 30 | message(STATUS "NOT building unit test (requires boost unit test framework)") |
| 31 | |
| 32 | endif(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
| 33 | |
| 34 | else(BUILD_TESTS) |
| 35 | |
| 36 | message(STATUS "NOT building unit test") |
| 37 | |
| 38 | endif(BUILD_TESTS) |