forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libftdi1] Fix, cleanup, C++ binding, test port (microsoft#40862)
- Loading branch information
Showing
21 changed files
with
284 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 5aecafc..4158267 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1,4 +1,5 @@ | ||
# Project | ||
+cmake_minimum_required(VERSION 3.5) | ||
project(libftdi1 C) | ||
set(MAJOR_VERSION 1) | ||
set(MINOR_VERSION 5) | ||
@@ -11,8 +12,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | ||
if("${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
set(CMAKE_BUILD_TYPE RelWithDebInfo) | ||
endif("${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
-set(CMAKE_COLOR_MAKEFILE ON) | ||
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR) | ||
|
||
add_definitions(-Wall) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 4158267..61828d3 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -170,6 +170,7 @@ install(FILES ${CMAKE_BINARY_DIR}/libftdi1.pc ${CMAKE_BINARY_DIR}/libftdipp1.pc | ||
DESTINATION lib${LIB_SUFFIX}/pkgconfig) | ||
|
||
if (UNIX OR MINGW) | ||
+elseif (0) | ||
configure_file ( libftdi1-config.in ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config @ONLY ) | ||
install ( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libftdi1-config | ||
DESTINATION bin ) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index fa5b3bf..5963df0 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -166,6 +166,7 @@ endif(${UNIX}) | ||
if(${WIN32}) | ||
set(libdir ${CMAKE_INSTALL_PREFIX}/bin) | ||
endif(${WIN32}) | ||
+set(libdir ${CMAKE_INSTALL_PREFIX}/lib) | ||
|
||
configure_file(${CMAKE_SOURCE_DIR}/libftdi1.pc.in ${CMAKE_BINARY_DIR}/libftdi1.pc @ONLY) | ||
configure_file(${CMAKE_SOURCE_DIR}/libftdipp1.pc.in ${CMAKE_BINARY_DIR}/libftdipp1.pc @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 4158267..64ad5b3 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -135,7 +135,7 @@ endif () | ||
|
||
add_subdirectory(src) | ||
if ( FTDIPP ) | ||
- project(libftdipp1 C CXX) | ||
+ enable_language(CXX) | ||
add_subdirectory(ftdipp) | ||
endif () | ||
if ( PYTHON_BINDINGS ) | ||
@@ -192,6 +192,7 @@ list ( APPEND LIBFTDI_STATIC_LIBRARIES ${LIBUSB_LIBRARIES} ) | ||
if ( FTDIPP ) | ||
set ( LIBFTDIPP_LIBRARY ftdipp1 ) | ||
set ( LIBFTDIPP_LIBRARIES ${LIBFTDIPP_LIBRARY} ) | ||
+ list ( APPEND LIBFTDI_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) | ||
list ( APPEND LIBFTDIPP_LIBRARIES ${LIBUSB_LIBRARIES} ) | ||
endif () | ||
set ( LIBFTDI_LIBRARY_DIRS ${libdir} ) | ||
@@ -203,6 +204,7 @@ set ( LIBFTDI_ROOT_DIR ${prefix} ) | ||
set ( LIBFTDI_VERSION_STRING ${VERSION_STRING} ) | ||
set ( LIBFTDI_VERSION_MAJOR ${MAJOR_VERSION} ) | ||
set ( LIBFTDI_VERSION_MINOR ${MINOR_VERSION} ) | ||
+set ( LIBFTDIPP_LIBRARIES ${LIBFTDIPP_LIBRARY} ${LIBFTDI_LIBRARIES}) | ||
|
||
set ( LIBFTDI_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBFTDI_CMAKE_CONFIG_DIR}/UseLibFTDI1.cmake ) | ||
|
||
diff --git a/libftdipp1.pc.in b/libftdipp1.pc.in | ||
index 8158f38..b4fff0a 100644 | ||
--- a/libftdipp1.pc.in | ||
+++ b/libftdipp1.pc.in | ||
@@ -8,4 +8,4 @@ Description: C++ wrapper for libftdi1 | ||
Requires: libftdi1 | ||
Version: @VERSION@ | ||
Libs: -L${libdir} -lftdipp1 | ||
-Cflags: -I${includedir} | ||
+Cflags: -I${includedir} -I${prefix}/include |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index b5c812c..7fb66f7 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -24,7 +24,10 @@ if(${CMAKE_BUILD_TYPE} STREQUAL Debug) | ||
endif(${CMAKE_BUILD_TYPE} STREQUAL Debug) | ||
|
||
# find libusb | ||
-find_package ( USB1 REQUIRED ) | ||
+find_package(PkgConfig REQUIRED) | ||
+pkg_check_modules(LIBUSB REQUIRED libusb-1.0) | ||
+set(LIBUSB_INCLUDE_DIR "${LIBUSB_INCLUDE_DIRS}") | ||
+set(LIBUSB_LIBRARIES "${LIBUSB_LINK_LIBRARIES}") | ||
include_directories ( ${LIBUSB_INCLUDE_DIR} ) | ||
|
||
# Find Boost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt | ||
index fac5bcc..8a20a04 100644 | ||
--- a/ftdipp/CMakeLists.txt | ||
+++ b/ftdipp/CMakeLists.txt | ||
@@ -11,6 +11,11 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} | ||
|
||
include_directories(${Boost_INCLUDE_DIRS}) | ||
|
||
+if(WIN32) | ||
+ set(BUILD_SHARED_LIBS OFF) | ||
+ set(STATICLIBS ON) | ||
+endif() | ||
+if(BUILD_SHARED_LIBS) | ||
# Shared library | ||
add_library(ftdipp1 SHARED ${cpp_sources}) | ||
|
||
@@ -28,6 +33,7 @@ install ( TARGETS ftdipp1 | ||
LIBRARY DESTINATION lib${LIB_SUFFIX} | ||
ARCHIVE DESTINATION lib${LIB_SUFFIX} | ||
) | ||
+endif() | ||
|
||
# Static library | ||
if ( STATICLIBS ) | ||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index 17b3617..087fba8 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -19,8 +19,12 @@ configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h | ||
|
||
# Targets | ||
set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" ) | ||
+if(WIN32) | ||
+ set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/exports.def CACHE INTERNAL "List of c sources" ) | ||
+endif() | ||
set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" ) | ||
|
||
+if(BUILD_SHARED_LIBS) | ||
add_library(ftdi1 SHARED ${c_sources}) | ||
|
||
math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases | ||
@@ -37,6 +41,7 @@ install ( TARGETS ftdi1 | ||
LIBRARY DESTINATION lib${LIB_SUFFIX} | ||
ARCHIVE DESTINATION lib${LIB_SUFFIX} | ||
) | ||
+endif() | ||
|
||
if ( STATICLIBS ) | ||
add_library(ftdi1-static STATIC ${c_sources}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
|
||
vcpkg_find_acquire_program(PKGCONFIG) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${CURRENT_PORT_DIR}/project" | ||
OPTIONS | ||
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}" | ||
) | ||
vcpkg_cmake_build() |
13 changes: 13 additions & 0 deletions
13
scripts/test_ports/vcpkg-ci-libftdi1/project/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.29) | ||
project(libftdi1-test CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
add_executable(main main.cpp) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(libftdipp1 IMPORTED_TARGET REQUIRED libftdipp1) | ||
target_link_libraries(main PRIVATE PkgConfig::libftdipp1) | ||
|
||
# subdir to scope side effects | ||
add_subdirectory(cmake-usage) |
6 changes: 6 additions & 0 deletions
6
scripts/test_ports/vcpkg-ci-libftdi1/project/cmake-usage/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# not modern | ||
find_package(LIBFTDI1 NAMES LibFTDI1 REQUIRED) | ||
include("${LIBFTDI_USE_FILE}") | ||
|
||
add_executable(cmake-usage ../main.cpp) | ||
target_link_libraries(cmake-usage PRIVATE ${LIBFTDIPP_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "ftdi.hpp" | ||
|
||
int main() | ||
{ | ||
auto *context = new Ftdi::Context(); | ||
return 0; | ||
} |
Oops, something went wrong.