Driver: FTD3XX: Use CMake FetchContent for lib
parent
bbf348a6ab
commit
2f7c3a2dda
|
|
@ -92,8 +92,8 @@ test windows/x86:
|
|||
script:
|
||||
- apt update -y
|
||||
- apt upgrade -y
|
||||
- apt install -y clang lld libc++-dev libc++abi-dev ninja-build cmake libusb-1.0-0-dev libpcap-dev
|
||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld CXXFLAGS=-stdlib=libc++ sh ci/build-posix.sh
|
||||
- apt install -y clang lld ninja-build cmake libusb-1.0-0-dev libpcap-dev
|
||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
|
|
@ -107,7 +107,7 @@ test windows/x86:
|
|||
script:
|
||||
- apt update -y
|
||||
- apt upgrade -y
|
||||
- apt install -y libusb-1.0-0-dev libpcap-dev libc++-dev libc++abi-dev
|
||||
- apt install -y libusb-1.0-0-dev libpcap-dev
|
||||
- build/libicsneo-tests
|
||||
tags:
|
||||
- linux-build
|
||||
|
|
@ -202,8 +202,8 @@ test linux/ubuntu/2204/amd64/clang:
|
|||
- /var/cache/dnf
|
||||
script:
|
||||
- dnf upgrade -y
|
||||
- dnf install -y clang lld libpcap-devel cmake ninja-build libusb1-devel libcxx-devel
|
||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld CXXFLAGS=-stdlib=libc++ sh ci/build-posix.sh
|
||||
- dnf install -y clang lld libpcap-devel cmake ninja-build libusb1-devel
|
||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
|
|
@ -219,7 +219,7 @@ test linux/ubuntu/2204/amd64/clang:
|
|||
- /var/cache/dnf
|
||||
script:
|
||||
- dnf upgrade -y
|
||||
- dnf install -y libpcap-devel libusb1-devel libcxx-devel
|
||||
- dnf install -y libpcap-devel libusb1-devel
|
||||
- build/libicsneo-tests
|
||||
tags:
|
||||
- linux-build
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(libicsneo VERSION 0.3.0)
|
||||
|
||||
cmake_policy(SET CMP0074 OLD)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
|
||||
option(LIBICSNEO_BUILD_TESTS "Build all tests." OFF)
|
||||
option(LIBICSNEO_BUILD_DOCS "Build documentation. Don't use in Visual Studio." OFF)
|
||||
|
|
@ -20,6 +20,7 @@ option(LIBICSNEO_ENABLE_RAW_ETHERNET "Enable devices which communicate over raw
|
|||
option(LIBICSNEO_ENABLE_CDCACM "Enable devices which communicate over USB CDC ACM" ON)
|
||||
option(LIBICSNEO_ENABLE_FTDI "Enable devices which communicate over USB FTDI2XX" ON)
|
||||
option(LIBICSNEO_ENABLE_TCP "Enable devices which communicate over TCP" OFF)
|
||||
option(LIBICSNEO_ENABLE_FTD3XX "Enable devices which communicate over USB FTD3XX" ON)
|
||||
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
|
@ -160,9 +161,43 @@ else() # Darwin or Linux
|
|||
endif()
|
||||
endif()
|
||||
|
||||
find_package(FTD3XX)
|
||||
if(FTD3XX_FOUND)
|
||||
set(LIBICSNEO_ENABLE_FTD3XX 1)
|
||||
if(LIBICSNEO_ENABLE_FTD3XX)
|
||||
if(NOT FTD3XX_ROOT) # allow system override
|
||||
include(FetchContent)
|
||||
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
FetchContent_Declare(
|
||||
ftdi3xx
|
||||
URL https://cdn.intrepidcs.net/support/libicsneo/libftd3xx/libftd3xx-1.3.0.4-win-x64.zip
|
||||
URL_HASH SHA256=7ba81100e0d4e96aca685545656c9dfa393d08587b94319551f75a6089f04b5e
|
||||
)
|
||||
elseif(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
FetchContent_Declare(
|
||||
ftdi3xx
|
||||
URL https://cdn.intrepidcs.net/support/libicsneo/libftd3xx/libftd3xx-1.3.0.4-win-i686.zip
|
||||
URL_HASH SHA256=e290bc29ee5b1a9e779225f276f7956debe7326019e066f077c46d9242beab4b
|
||||
)
|
||||
elseif(APPLE)
|
||||
FetchContent_Declare(
|
||||
ftdi3xx
|
||||
URL https://cdn.intrepidcs.net/support/libicsneo/libftd3xx/libftd3xx-1.0.5-macos-universal2.zip
|
||||
URL_HASH SHA256=a540583f3c1e80c6ebbc27a28a4168820f8b11b78752d0655f0bfe40e723129d
|
||||
)
|
||||
elseif(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
FetchContent_Declare(
|
||||
ftdi3xx
|
||||
URL https://cdn.intrepidcs.net/support/libicsneo/libftd3xx/libftd3xx-1.0.5-linux-x64.zip
|
||||
URL_HASH SHA256=e9a16a41f407ee2932fcf77468204b0009468b5c15f5441e3b1302ccfd4144af
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform for FTD3XX driver")
|
||||
endif()
|
||||
FetchContent_GetProperties(ftdi3xx)
|
||||
if(NOT ftdi3xx_POPULATED)
|
||||
FetchContent_Populate(ftdi3xx)
|
||||
endif()
|
||||
set(FTD3XX_ROOT "${ftdi3xx_SOURCE_DIR}")
|
||||
endif()
|
||||
find_package(FTD3XX REQUIRED)
|
||||
list(APPEND PLATFORM_SRC
|
||||
platform/ftd3xx.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -112,11 +112,7 @@ icsneo_closeDevice(myDevice);
|
|||
|
||||
## Building from Source
|
||||
### FTD3XX
|
||||
Some devices require FTD3XX for USB communication:
|
||||
1. Download the archive for the target platform from [FTDI's website](https://ftdichip.com/drivers/d3xx-drivers/)
|
||||
- Windows users should download the "Application Library (DLL)" package
|
||||
2. Extract the archive
|
||||
3. Configure libicsneo with the CMake option `FTD3XX_ROOT` set to the path containing `f3d3xx.h` (`-DFTD3XX_ROOT=<path to directory containing ftd3xx.h>`)
|
||||
Some devices require FTD3XX for USB communication so the [FTDI D3XX library](https://ftdichip.com/drivers/d3xx-drivers/) will be automatically downloaded and included. If you would like to use a system copy of D3XX instead you can set `FTD3XX_ROOT` to the path containing `f3d3xx.h` (`-DFTD3XX_ROOT=<path to directory containing ftd3xx.h>`).
|
||||
### Windows
|
||||
Building will require MSVC 2017 version 15.7 or newer and CMake to be installed.
|
||||
### macOS
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
find_path(FTD3XX_INCLUDE_DIR
|
||||
NAMES ftd3xx.h FTD3XX.h
|
||||
HINTS "${FTD3XX_ROOT}"
|
||||
)
|
||||
|
||||
find_library(FTD3XX_LIBRARY
|
||||
NAMES libftd3xx-static.a FTD3XX.lib
|
||||
NAMES libftd3xx.a libftd3xx-static.a FTD3XX.lib
|
||||
PATH_SUFFIXES x64/Static
|
||||
HINTS "${FTD3XX_ROOT}"
|
||||
)
|
||||
|
||||
mark_as_advanced(FTD3XX_FOUND FTD3XX_INCLUDE_DIR FTD3XX_LIBRARY)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
#include <vector>
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4091)
|
||||
#endif
|
||||
#define FTD3XX_STATIC
|
||||
#include <ftd3xx.h>
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include "icsneo/platform/ftd3xx.h"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue