cmake: add -DFTDID2xx and use FindFtd2xx.cmake
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -55,6 +55,7 @@ option (BUILDSWIGPYTHON "Build swig python modules." ON)
|
||||
option (BUILDSWIGNODE "Build swig node modules." ON)
|
||||
option (BUILDSWIGJAVA "Build Java API." OFF)
|
||||
option (USBPLAT "Detection USB platform." ON)
|
||||
option (FTDID2XX "Build with FTDI D2xx subplatform support." OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
option (BUILDPYTHON3 "Use python3 for building/installing" OFF)
|
||||
|
||||
22
cmake/modules/COPYING-CMAKE-SCRIPTS
Normal file
22
cmake/modules/COPYING-CMAKE-SCRIPTS
Normal file
@@ -0,0 +1,22 @@
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
73
cmake/modules/FindFtd2xx.cmake
Normal file
73
cmake/modules/FindFtd2xx.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# - Try to find libftd2xx
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBFTD2XX_FOUND - system has libftd2xx
|
||||
# LIBFTD2XX_INCLUDE_DIRS - the libftd2xx include directory
|
||||
# LIBFTD2XX_LIBRARIES - Link these to use libftd2xx
|
||||
# LIBFTD2XX_DEFINITIONS - Compiler switches required for using libftd2xx
|
||||
#
|
||||
# Adapted from cmake-modules Google Code project
|
||||
#
|
||||
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
|
||||
#
|
||||
# (Changes for libftd2xx) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBFTD2XX_FOUND TRUE)
|
||||
else (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
||||
find_path(LIBFTD2XX_INCLUDE_DIR
|
||||
NAMES
|
||||
ftd2xx.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
)
|
||||
|
||||
SET(FTD2XX_LIBNAME ftd2xx)
|
||||
IF(WIN32)
|
||||
SET(FTD2XX_LIBNAME ftd2xx.lib)
|
||||
ENDIF(WIN32)
|
||||
|
||||
find_library(LIBFTD2XX_LIBRARY
|
||||
NAMES
|
||||
${FTD2XX_LIBNAME}
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
if(LIBFTD2XX_INCLUDE_DIR)
|
||||
set(LIBFTD2XX_INCLUDE_DIRS
|
||||
${LIBFTD2XX_INCLUDE_DIR}
|
||||
)
|
||||
endif(LIBFTD2XX_INCLUDE_DIR)
|
||||
set(LIBFTD2XX_LIBRARIES
|
||||
${LIBFTD2XX_LIBRARY}
|
||||
)
|
||||
|
||||
if (LIBFTD2XX_INCLUDE_DIRS AND LIBFTD2XX_LIBRARIES)
|
||||
set(LIBFTD2XX_FOUND TRUE)
|
||||
endif (LIBFTD2XX_INCLUDE_DIRS AND LIBFTD2XX_LIBRARIES)
|
||||
|
||||
if (LIBFTD2XX_FOUND)
|
||||
if (NOT libftd2xx_FIND_QUIETLY)
|
||||
message(STATUS "Found libftd2xx: ${LIBFTD2XX_LIBRARIES}")
|
||||
endif (NOT libftd2xx_FIND_QUIETLY)
|
||||
else (LIBFTD2XX_FOUND)
|
||||
if (libftd2xx_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find libftd2xx")
|
||||
endif (libftd2xx_FIND_REQUIRED)
|
||||
endif (LIBFTD2XX_FOUND)
|
||||
|
||||
# show the LIBFTD2XX_INCLUDE_DIRS and LIBFTD2XX_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(LIBFTD2XX_INCLUDE_DIRS LIBFTD2XX_LIBRARIES)
|
||||
|
||||
endif (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
||||
@@ -50,8 +50,16 @@ endif()
|
||||
if (USBPLAT)
|
||||
add_subdirectory(usb)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
|
||||
set (mraa_LIBS ${mraa_LIBS} ft4222)
|
||||
endif()
|
||||
find_package (Ftd2xx)
|
||||
if (FTDID2xx)
|
||||
if (${LIBFTD2XX_FOUND})
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1")
|
||||
set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES})
|
||||
else ()
|
||||
message (WARNING " - Enabled FTDID2xx support but library not found")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
set (mraa_LIB_SRCS
|
||||
|
||||
@@ -115,11 +115,12 @@ mraa_init()
|
||||
// This is a platform extender so create null base platform if one doesn't already exist
|
||||
if (plat == NULL) {
|
||||
plat = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
plat->platform_name = "Null platform";
|
||||
plat->platform_name = "Unknown platform";
|
||||
if (plat != NULL) {
|
||||
int usb_platform_type = mraa_usb_platform_extender(plat);
|
||||
if (platform_type == MRAA_UNKNOWN_PLATFORM)
|
||||
if (platform_type == MRAA_UNKNOWN_PLATFORM) {
|
||||
platform_type = usb_platform_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plat == NULL) {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
message (INFO " - Adding USB platforms")
|
||||
set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO}
|
||||
${PROJECT_SOURCE_DIR}/src/usb/usb.c
|
||||
${PROJECT_SOURCE_DIR}/src/usb/ftdi_ft4222.c
|
||||
PARENT_SCOPE
|
||||
)
|
||||
if (FTDID2XX)
|
||||
set (mraa_LIB_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/usb/ftdi_ft4222.c
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -26,13 +26,16 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "mraa_internal.h"
|
||||
#ifdef FTDID2XX
|
||||
#include "usb/ftdi_ft4222.h"
|
||||
#endif
|
||||
|
||||
|
||||
mraa_platform_t
|
||||
mraa_usb_platform_extender(mraa_board_t* board)
|
||||
{
|
||||
mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
|
||||
#ifdef FTDID2XX
|
||||
if (mraa_ftdi_ft4222_init() == MRAA_SUCCESS) {
|
||||
unsigned int versionChip, versionLib;
|
||||
if (mraa_ftdi_ft4222_get_version(&versionChip, &versionLib) == MRAA_SUCCESS) {
|
||||
@@ -47,5 +50,6 @@ mraa_usb_platform_extender(mraa_board_t* board)
|
||||
default:
|
||||
syslog(LOG_ERR, "Unknown USB Platform Extender, currently not supported by MRAA");
|
||||
}
|
||||
#endif
|
||||
return platform_type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user