Bug#965177: libftdi: ships broken cmake file

2020-07-17 Thread Gianfranco Costamagna
Hello,

I'm attaching a tested patch that also adds a new autopkgtest that spots this 
kind of failures in the future.

(the diff fixes also #965175)

G.
diff -Nru libftdi1-1.5/debian/changelog libftdi1-1.5/debian/changelog
--- libftdi1-1.5/debian/changelog   2020-07-14 23:32:06.0 +0200
+++ libftdi1-1.5/debian/changelog   2020-07-17 08:57:55.0 +0200
@@ -1,3 +1,11 @@
+libftdi1 (1.5-4) unstable; urgency=medium
+
+  * Mark one symbol as optional, disappearing on ppc64el with -O3 (Closes: 
#965175)
+  * Add again the LIBDIR in rules file to make the cmake script happy (Closes: 
#965177)
+  * Add an autopkgtest to test cmake scripts
+
+ -- Gianfranco Costamagna   Fri, 17 Jul 2020 
08:57:55 +0200
+
 libftdi1 (1.5-3) unstable; urgency=medium
 
   * Redirect autopkgtests stderr output to stdout.
diff -Nru libftdi1-1.5/debian/libftdipp1-3.symbols 
libftdi1-1.5/debian/libftdipp1-3.symbols
--- libftdi1-1.5/debian/libftdipp1-3.symbols2020-06-27 14:53:49.0 
+0200
+++ libftdi1-1.5/debian/libftdipp1-3.symbols2020-07-17 08:57:46.0 
+0200
@@ -105,7 +105,7 @@
  _ZNK4Ftdi4List6rbeginEv@Base 1.5
  _ZNK4Ftdi7Context20get_usb_read_timeoutEv@Base 1.5
  _ZNK4Ftdi7Context21get_usb_write_timeoutEv@Base 1.5
- _ZNSt7__cxx1110_List_baseIN4Ftdi7ContextESaIS2_EE8_M_clearEv@Base 1.5
+ (optional)_ZNSt7__cxx1110_List_baseIN4Ftdi7ContextESaIS2_EE8_M_clearEv@Base 
1.5
  _ZTIN5boost6detail15sp_counted_baseE@Base 1.5
  _ZTIN5boost6detail17sp_counted_impl_pIN4Ftdi4List7PrivateEEE@Base 1.5
  _ZTIN5boost6detail17sp_counted_impl_pIN4Ftdi6Eeprom7PrivateEEE@Base 1.5
diff -Nru libftdi1-1.5/debian/rules libftdi1-1.5/debian/rules
--- libftdi1-1.5/debian/rules   2020-07-13 11:23:42.0 +0200
+++ libftdi1-1.5/debian/rules   2020-07-17 08:57:55.0 +0200
@@ -11,6 +11,7 @@
 override_dh_auto_configure:
dh_auto_configure --builddirectory=build-main -- \
-DBUILD_TESTS=ON \
+   -DCMAKE_INSTALL_LIBDIR="/usr/lib/$(DEB_HOST_MULTIARCH)" \
-DDOCUMENTATION:BOOL=ON \
-DEXAMPLES:BOOL=ON \
-DFTDIPP:BOOL=ON \
@@ -19,6 +20,7 @@
for v in $(PY3VERS) ; do \
dh_auto_configure --builddirectory=build-python$$v -- \
-DBUILD_TESTS=OFF \
+   -DCMAKE_INSTALL_LIBDIR="/usr/lib/$(DEB_HOST_MULTIARCH)" 
\
-DDOCUMENTATION:BOOL=OFF \
-DEXAMPLES:BOOL=OFF \
-DFTDIPP:BOOL=ON \
diff -Nru libftdi1-1.5/debian/tests/control libftdi1-1.5/debian/tests/control
--- libftdi1-1.5/debian/tests/control   2020-07-12 14:45:44.0 +0200
+++ libftdi1-1.5/debian/tests/control   2020-07-17 08:57:55.0 +0200
@@ -1,2 +1,5 @@
 Tests: test-libftdi1
 Depends: build-essential, libftdi1-dev, libboost-test-dev, pkg-config
+
+Tests: test-libftdi1-cmake
+Depends: build-essential, libftdi1-dev, libboost-test-dev, cmake
diff -Nru libftdi1-1.5/debian/tests/test-libftdi1-cmake 
libftdi1-1.5/debian/tests/test-libftdi1-cmake
--- libftdi1-1.5/debian/tests/test-libftdi1-cmake   1970-01-01 
01:00:00.0 +0100
+++ libftdi1-1.5/debian/tests/test-libftdi1-cmake   2020-07-17 
08:57:55.0 +0200
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+set -e
+
+WORKDIR=$(mktemp -d)
+cat << EOF > $WORKDIR/CMakeLists.txt
+cmake_minimum_required(VERSION 3.16)
+project(test)
+find_package(LibFTDI1)
+
+message(STATUS "Include directories: " \${LIBFTDI_INCLUDE_DIRS})
+message(STATUS "Link directories: " \${LIBFTDI_LIBRARY_DIRS})
+message(STATUS "Libraries: " \${LIBFTDI_LIBRARIES})
+
+add_library(imp_ftdi INTERFACE IMPORTED)
+set_target_properties(imp_ftdi
+ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "\${LIBFTDI_INCLUDE_DIRS}"
+ INTERFACE_LINK_DIRECTORIES "\${LIBFTDI_LIBRARY_DIRS}"
+ INTERFACE_LINK_LIBRARIES "\${LIBFTDI_LIBRARIES}"
+ )
+
+add_executable(test-libftdi1-cmake basic.cpp baudrate.cpp)
+include_directories("\${LIBFTDI_INCLUDE_DIRS}")
+target_link_libraries(test-libftdi1-cmake PRIVATE imp_ftdi 
boost_unit_test_framework)
+EOF
+
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+
+cp test/basic.cpp test/baudrate.cpp $WORKDIR
+cd $WORKDIR
+cmake .
+make VERBOSE=1
+
+echo "build: OK"
+[ -x $WORKDIR/test-libftdi1-cmake ]
+$WORKDIR/test-libftdi1-cmake 2>&1
+echo "run: OK"


Bug#965177: libftdi: ships broken cmake file

2020-07-17 Thread Gianfranco Costamagna
Hello again:

This is an example of cmake test file that might help in the future detecting 
such issues:
(stolen and adapted from mrpt)

cat ../CMakeLists.txt 
cmake_minimum_required(VERSION 3.16)
project(test)
find_package(LibFTDI1)

message("Include directories: " ${LIBFTDI_INCLUDE_DIRS})
message("Link directories: " ${LIBFTDI_LIBRARY_DIRS})
message("Libraries: " ${LIBFTDI_LIBRARIES})

add_library(imp_ftdi INTERFACE IMPORTED)
set_target_properties(imp_ftdi
 PROPERTIES
 INTERFACE_INCLUDE_DIRECTORIES "${LIBFTDI_INCLUDE_DIRS}"
 INTERFACE_LINK_DIRECTORIES "${LIBFTDI_LIBRARY_DIRS}"
 INTERFACE_LINK_LIBRARIES "${LIBFTDI_LIBRARIES}"
 )

add_executable(main main.c)
target_link_libraries(main PRIVATE imp_ftdi)


$ cmake ..

Include directories: /usr/include/libftdi1
Link directories: lib/x86_64-linux-gnu
Libraries: ftdi1/usr/lib/x86_64-linux-gnu/libusb-1.0.so
-- Configuring done
CMake Error in CMakeLists.txt:
  Target "imp_ftdi" contains relative path in its INTERFACE_LINK_DIRECTORIES:

"lib/x86_64-linux-gnu"


CMake Error in CMakeLists.txt:
  Target "imp_ftdi" contains relative path in its INTERFACE_LINK_DIRECTORIES:

"lib/x86_64-linux-gnu"


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.


and this is the patch that fixes the issue:

diff -Nru libftdi1-1.5/debian/changelog libftdi1-1.5/debian/changelog
--- libftdi1-1.5/debian/changelog   2020-07-17 08:57:55.0 +0200
+++ libftdi1-1.5/debian/changelog   2020-07-17 09:19:25.0 +0200
@@ -1,3 +1,9 @@
+libftdi1 (1.5-3.1) unstable; urgency=medium
+
+  * Add again the LIBDIR in rules file to make the cmake script happy (Closes: 
#-1)
+
+ -- Gianfranco Costamagna   Fri, 17 Jul 2020 
09:19:25 +0200
+
 libftdi1 (1.5-3ubuntu1) groovy; urgency=medium

   * Mark one symbol as optional, disappearing on ppc64el with -O3
diff -Nru libftdi1-1.5/debian/rules libftdi1-1.5/debian/rules
--- libftdi1-1.5/debian/rules   2020-07-13 11:23:42.0 +0200
+++ libftdi1-1.5/debian/rules   2020-07-17 09:19:25.0 +0200
@@ -11,6 +11,7 @@
 override_dh_auto_configure:
dh_auto_configure --builddirectory=build-main -- \
-DBUILD_TESTS=ON \
+   -DCMAKE_INSTALL_LIBDIR="/usr/lib/$(DEB_HOST_MULTIARCH)" \
-DDOCUMENTATION:BOOL=ON \
-DEXAMPLES:BOOL=ON \
-DFTDIPP:BOOL=ON \
@@ -19,6 +20,7 @@
for v in $(PY3VERS) ; do \
dh_auto_configure --builddirectory=build-python$$v -- \
-DBUILD_TESTS=OFF \
+   -DCMAKE_INSTALL_LIBDIR="/usr/lib/$(DEB_HOST_MULTIARCH)" 
\
-DDOCUMENTATION:BOOL=OFF \
-DEXAMPLES:BOOL=OFF \
-DFTDIPP:BOOL=ON \