libftdi Archives

Subject: [PATCH 00/10] msvc fixes

From: Shawn Hoffman <business@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Shawn Hoffman <business@xxxxxxxxxxxx>
Date: Wed, 10 Apr 2024 07:15:39 -0700
This patchset fixes windows/msvc compilation and some other bugs/warnings
encountered while getting it to work.

I took the opportunity to remove deprecated code (it's been 5 years :))

ftdipp dependency on boost is also removed in favor of STL.
boost is still required for tests.

Feel free to accept any part of the changes with your own modifications if
necessary. The important bits for msvc are just removal of gettimeofday
(from the main library) and the cmake changes in the last commit.

For the record, I'm able to build/use libftdi with msvc with something like:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/path/to/libftdi/build/bin \
  -DLIBUSB_LIBRARIES=/path/to/libusb-1.0.lib \
  -DLIBUSB_INCLUDE_DIR=/path/to/libusb/libusb \
  -DFTDI_EEPROM=OFF -DEXAMPLES=OFF -DSTATICLIBS=ON ..
cmake --build . --target install

The other build options (examples/eeprom/tests/etc) code use
dependencies/libc features that either don't exist on msvc or I haven't
bothered to install/test. ftdipp does work, however the static build of
it is broken in a similar way that the main lib was broken. Realistically,
someone should overhaul the cmake files to modern style and properly implement
the shared+static building pattern.

Shawn Hoffman (10):
  msvc: fix warnings by using all enum values in case statements
  msvc: fix shadowed variable warning
  cmake: autoformat
  cmake: fix elseif statement
  remove deprecated code
  ftdipp: use stl instead of boost for shared_ptr
  use timespec_get instead of gettimeofday timespec_get is in C11 hide
    some internal stream state from public api this is breaking change,
    but required as the old one was unusable anyway.
  fix unit var warning if ftdi_read_eeprom_location returned error, data
    would not be initialized
  msvc: quiet uninteresting warnings GREATER_EQUAL needs cmake 3.7
  cmake: fix building static lib on windows/msvc include(GNUInstallDirs)
    is required to populate CMAKE_INSTALL_LIBDIR

 CMakeLists.txt                        | 239 +++++++++++++-------------
 README.build                          |   2 +-
 doc/CMakeLists.txt                    |   2 +-
 examples/CMakeLists.txt               |  12 +-
 examples/cmake_example/CMakeLists.txt |  14 +-
 examples/purge_test.c                 | 175 ++++++++-----------
 examples/stream_test.c                |  14 +-
 ftdi_eeprom/CMakeLists.txt            |  48 +++---
 ftdipp/CMakeLists.txt                 |  41 +++--
 ftdipp/ftdi.cpp                       |  27 ---
 ftdipp/ftdi.hpp                       |   9 +-
 packages/CMakeLists.txt               |  16 +-
 python/CMakeLists.txt                 | 106 ++++++------
 python/examples/CMakeLists.txt        |   6 +-
 src/CMakeLists.txt                    |  74 +++++---
 src/ftdi.c                            | 102 +----------
 src/ftdi.h                            |  91 ++--------
 src/ftdi_stream.c                     | 114 +++++++-----
 18 files changed, 473 insertions(+), 619 deletions(-)

-- 
2.44.0.windows.1


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread