Make build of the unit tests configurable
[libftdi] / test / CMakeLists.txt
index 53e3f7b..74e1c10 100644 (file)
@@ -1,30 +1,38 @@
 # Optional unit test
 
-find_package(Boost COMPONENTS unit_test_framework)
+if(BUILD_TESTS)
 
-if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
+    find_package(Boost COMPONENTS unit_test_framework)
 
-    message(STATUS "Building unit test")
+    if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
 
-    enable_testing()
+        message(STATUS "Building unit test")
 
-    INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS})
+        enable_testing()
 
-    set(cpp_tests
-        basic.cpp
-        baudrate.cpp
-    )
+        INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS})
 
-    add_executable(test_libftdi1 ${cpp_tests})
-    target_link_libraries(test_libftdi1 ftdi1 ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+        set(cpp_tests
+            basic.cpp
+            baudrate.cpp
+        )
 
-    add_test(test_libftdi1 test_libftdi1)
+        add_executable(test_libftdi1 ${cpp_tests})
+        target_link_libraries(test_libftdi1 ftdi1 ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
 
-    # Add custom target so we run easily run "make check"
-    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_libftdi1)
+        add_test(test_libftdi1 test_libftdi1)
 
-else(Boost_UNIT_TEST_FRAMEWORK_FOUND)
+        # Add custom target so we run easily run "make check"
+        add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_libftdi1)
 
-    message(STATUS "NOT building unit test (requires boost unit test framework)")
+    else(Boost_UNIT_TEST_FRAMEWORK_FOUND)
 
-endif(Boost_UNIT_TEST_FRAMEWORK_FOUND)
+        message(STATUS "NOT building unit test (requires boost unit test framework)")
+
+    endif(Boost_UNIT_TEST_FRAMEWORK_FOUND)
+
+else(BUILD_TESTS)
+
+    message(STATUS "NOT building unit test")
+
+endif(BUILD_TESTS)