Commit | Line | Data |
---|---|---|
a87a0712 TJ |
1 | # Optional unit test |
2 | ||
2ecba570 | 3 | if(BUILD_TESTS) |
a87a0712 | 4 | |
2ecba570 | 5 | find_package(Boost COMPONENTS unit_test_framework) |
a87a0712 | 6 | |
2ecba570 | 7 | if(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
a87a0712 | 8 | |
2ecba570 | 9 | message(STATUS "Building unit test") |
a87a0712 | 10 | |
2ecba570 | 11 | enable_testing() |
a87a0712 | 12 | |
2ecba570 | 13 | INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS}) |
a87a0712 | 14 | |
2ecba570 SB |
15 | set(cpp_tests |
16 | basic.cpp | |
17 | baudrate.cpp | |
18 | ) | |
a87a0712 | 19 | |
2ecba570 SB |
20 | add_executable(test_libftdi1 ${cpp_tests}) |
21 | target_link_libraries(test_libftdi1 ftdi1 ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) | |
a87a0712 | 22 | |
2ecba570 | 23 | add_test(test_libftdi1 test_libftdi1) |
a87a0712 | 24 | |
2ecba570 SB |
25 | # Add custom target so we run easily run "make check" |
26 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_libftdi1) | |
a87a0712 | 27 | |
2ecba570 | 28 | else(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
a87a0712 | 29 | |
2ecba570 SB |
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) |