On 06/12/2014 02:56 PM, Thomas Jarosch wrote:
> On Thursday, 12. June 2014 20:42:14 Xiaofan Chen wrote:
>>> If this is a common problem, how about adding a cmake switch? Something
>>> like -DBUILD_TESTS=OFF?
>>
>> I am not so sure you can call it a common problem, so far
>> I do not see many people building the whole libftdi Windows
>> thingy (except me), most of the people only need the
>> C library and they are fine.
>>
>> But still I think it is good to add the CMake switch now
>> at least you and I have this problem.
>
> fine by me, too.
>
> @Samuel: The "DOCUMENTATION" switch might provide
> a good starting point for this.
Ok, I attached a small patch that adds a 'BUILD_TESTS' switch.
Do your rather want a pull request?
As for the cross-compiling: I switched to D2XX on Windows because I
don't want to incur the whole driver mess. Now I have to write
everything twice, but that's manageable.
Cheers,
Sam
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08e5771..ee21a8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,6 +113,8 @@ add_custom_target(dist
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+# Tests
+option ( BUILD_TESTS "Build unit tests with Boost Unit Test framework" ON )
# Documentation
option ( DOCUMENTATION "Generate API documentation with Doxygen" ON )
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 53e3f7b..74e1c10 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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)