package/c-periphery: disable tests
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Sun, 7 Jun 2020 08:01:24 +0000 (10:01 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 10 Jun 2020 21:32:14 +0000 (23:32 +0200)
Add a patch to disable tests, it should be noted that -DBUILD_TESTS=OFF
is already passed by cmake-infrastructure

Fixes:
 - http://autobuild.buildroot.org/results/6bbc4de3f857dcb7ff5e6f9fa1441ba4e0af1338

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/c-periphery/0001-CMakeLists.txt-add-BUILD_TESTS-option.patch [new file with mode: 0644]

diff --git a/package/c-periphery/0001-CMakeLists.txt-add-BUILD_TESTS-option.patch b/package/c-periphery/0001-CMakeLists.txt-add-BUILD_TESTS-option.patch
new file mode 100644 (file)
index 0000000..f932ec6
--- /dev/null
@@ -0,0 +1,61 @@
+From 7b3f137af40f4355404c146af7d9764c961a2fc7 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 7 Jun 2020 09:46:10 +0200
+Subject: [PATCH] CMakeLists.txt: add BUILD_TESTS option
+
+Add an option to enable or disable tests. This will allow the user to
+build c-periphery without threads and will avoid the following build
+failure:
+
+[ 68%] Building C object CMakeFiles/test_serial.dir/tests/test_serial.c.o
+/data/buildroot/buildroot-test/instance-0/output/build/c-periphery-2.2.1/tests/test_gpio_sysfs.c:13:10: fatal error: pthread.h: No such file or directory
+ #include <pthread.h>
+          ^~~~~~~~~~~
+
+Fixes:
+ - http://autobuild.buildroot.org/results/6bbc4de3f857dcb7ff5e6f9fa1441ba4e0af1338
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://github.com/vsergeev/c-periphery/pull/26]
+---
+ CMakeLists.txt | 20 ++++++++++++--------
+ 1 file changed, 12 insertions(+), 8 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f442bce..6565557 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,6 +1,8 @@
+ cmake_minimum_required(VERSION 2.6)
+ project(periphery C)
++option(BUILD_TESTS "Build tests" ON)
++
+ # Check for Linux kernel headers
+ include(CheckIncludeFiles)
+ CHECK_INCLUDE_FILES(linux/gpio.h HAVE_LINUX_HEADERS)
+@@ -44,11 +46,13 @@ install(TARGETS periphery DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(FILES ${periphery_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
+ install(FILES ${CMAKE_BINARY_DIR}/libperiphery.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+-# Declare tests targets
+-foreach(TEST_SOURCE ${periphery_TESTS})
+-    get_filename_component(TEST_PROGRAM ${TEST_SOURCE} NAME_WE)
+-    add_executable(${TEST_PROGRAM} ${TEST_SOURCE})
+-    target_link_libraries(${TEST_PROGRAM} periphery pthread)
+-    set(TEST_PROGRAMS ${TEST_PROGRAMS} ${TEST_PROGRAM})
+-endforeach()
+-add_custom_target(tests DEPENDS periphery ${TEST_PROGRAMS})
++if(BUILD_TESTS)
++    # Declare tests targets
++    foreach(TEST_SOURCE ${periphery_TESTS})
++        get_filename_component(TEST_PROGRAM ${TEST_SOURCE} NAME_WE)
++        add_executable(${TEST_PROGRAM} ${TEST_SOURCE})
++        target_link_libraries(${TEST_PROGRAM} periphery pthread)
++        set(TEST_PROGRAMS ${TEST_PROGRAMS} ${TEST_PROGRAM})
++    endforeach()
++    add_custom_target(tests DEPENDS periphery ${TEST_PROGRAMS})
++endif()
+-- 
+2.26.2
+