Created
June 19, 2010 21:01
-
-
Save eblot/d87e3ab79b3421587a13 to your computer and use it in GitHub Desktop.
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
From 519d651c27a897e5574708001adbd183e2328726 Mon Sep 17 00:00:00 2001 | |
From: Emmanuel Blot <eblot@moaningmarmot.info> | |
Date: Sat, 19 Jun 2010 22:59:54 +0200 | |
Subject: [PATCH] Fix up build on Mac OS X (reworked): | |
* Fix up Boost library management | |
* Fix up Python bindings | |
* Discard attempt to build C++ examples when Boost is not available | |
* Fix up async API declaration | |
--- | |
CMakeLists.txt | 24 ++++++--- | |
bindings/CMakeLists.txt | 5 +- | |
examples/CMakeLists.txt | 19 ++++--- | |
ftdipp/CMakeLists.txt | 134 ++++++++++++++++++++++------------------------- | |
src/ftdi.h | 4 +- | |
5 files changed, 95 insertions(+), 91 deletions(-) | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index d082932..8a87178 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -26,6 +26,9 @@ endif(${CMAKE_BUILD_TYPE} STREQUAL Debug) | |
FIND_PACKAGE(USB1 REQUIRED) | |
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR}) | |
+# Find Boost (optional package) | |
+find_package(Boost) | |
+ | |
# Set components | |
set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers) | |
set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries") | |
@@ -43,14 +46,19 @@ set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development") | |
set(CPACK_COMPONENT_STATICLIBS_GROUP "Development") | |
set(CPACK_COMPONENT_HEADERS_GROUP "Development") | |
-# Create suffix to eventually install in lib64 | |
-IF(CMAKE_SIZEOF_VOID_P EQUAL 4) | |
- SET(LIB_SUFFIX "") | |
- SET(PACK_ARCH "") | |
- ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) | |
- SET(LIB_SUFFIX 64) | |
- SET(PACK_ARCH .x86_64) | |
-endif(CMAKE_SIZEOF_VOID_P EQUAL 4) | |
+if(NOT APPLE) | |
+ # Create suffix to eventually install in lib64 | |
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4) | |
+ SET(LIB_SUFFIX "") | |
+ SET(PACK_ARCH "") | |
+ else(CMAKE_SIZEOF_VOID_P EQUAL 8) | |
+ SET(LIB_SUFFIX 64) | |
+ SET(PACK_ARCH .x86_64) | |
+ endif(CMAKE_SIZEOF_VOID_P EQUAL 4) | |
+else(NOT APPLE) | |
+ SET(LIB_SUFFIX "") | |
+ SET(PACK_ARCH "") | |
+endif(NOT APPLE) | |
# Package information | |
set(CPACK_PACKAGE_VERSION ${VERSION_STRING}) | |
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt | |
index 48f535c..5333035 100644 | |
--- a/bindings/CMakeLists.txt | |
+++ b/bindings/CMakeLists.txt | |
@@ -7,9 +7,10 @@ option(PYTHON_BINDINGS "Build python bindings via swig" ON) | |
if(PYTHON_BINDINGS AND SWIG_FOUND AND PYTHONLIBS_FOUND) | |
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src) | |
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) | |
- | |
+ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../src) | |
+ | |
SWIG_ADD_MODULE(ftdi python ftdi.i) | |
- SWIG_LINK_LIBRARIES(ftdi ${PYTHON_LIBRARIES}) | |
+ SWIG_LINK_LIBRARIES(ftdi ftdi ${PYTHON_LIBRARIES}) | |
GET_FILENAME_COMPONENT(PYTHON_LIB_INSTALL ${PYTHON_LIBRARY} PATH) | |
GET_FILENAME_COMPONENT(SITEPACKAGE ${PYTHON_LIB_INSTALL}/../site-packages ABSOLUTE) | |
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt | |
index 7b702c2..017cbd2 100644 | |
--- a/examples/CMakeLists.txt | |
+++ b/examples/CMakeLists.txt | |
@@ -35,14 +35,17 @@ if (EXAMPLES) | |
# libftdi++ examples | |
if(FTDI_BUILD_CPP) | |
- message(STATUS "Building libftdi++ examples.") | |
- include_directories(${CMAKE_SOURCE_DIR}/ftdipp) | |
- | |
- # Targest | |
- add_executable(find_all_pp find_all_pp.cpp) | |
- | |
- # Linkage | |
- target_link_libraries(find_all_pp ftdipp) | |
+ if(Boost_FOUND) | |
+ message(STATUS "Building libftdi++ examples.") | |
+ include_directories(${CMAKE_SOURCE_DIR}/ftdipp | |
+ ${Boost_INCLUDE_DIRS}) | |
+ | |
+ # Target | |
+ add_executable(find_all_pp find_all_pp.cpp) | |
+ | |
+ # Linkage | |
+ target_link_libraries(find_all_pp ftdipp) | |
+ endif(Boost_FOUND) | |
endif(FTDI_BUILD_CPP) | |
else(EXAMPLES) | |
message(STATUS "Not building example programs.") | |
diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt | |
index 8423b2e..06822c0 100644 | |
--- a/ftdipp/CMakeLists.txt | |
+++ b/ftdipp/CMakeLists.txt | |
@@ -5,80 +5,71 @@ option(FTDIPP "Build C++ binding library libftdi++" ON) | |
if (FTDIPP) | |
- # Includes | |
- include_directories( ${CMAKE_CURRENT_BINARY_DIR} | |
- ${CMAKE_CURRENT_SOURCE_DIR} | |
- ${CMAKE_CURRENT_SOURCE_DIR}/../src | |
- ) | |
- | |
- # Targets | |
- set(cpp_sources ftdi.cpp) | |
- set(cpp_headers ftdi.hpp) | |
- | |
- # Find Boost | |
- find_package(Boost) | |
if(Boost_FOUND) | |
- set(FTDI_BUILD_CPP True PARENT_SCOPE) | |
- message(STATUS "Building libftdi++") | |
- | |
- # Targets | |
- add_library(ftdipp SHARED ${cpp_sources}) | |
- | |
- math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases | |
- set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) | |
- | |
- # Static library | |
- add_library(ftdipp-static STATIC ${cpp_sources}) | |
- set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") | |
- | |
- # Prevent clobbering each other during the build | |
- set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
- set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
- | |
- # Dependencies | |
- target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) | |
- | |
- # Install | |
- if(${UNIX}) | |
- | |
- install( TARGETS ftdipp | |
- LIBRARY DESTINATION lib${LIB_SUFFIX} | |
- COMPONENT sharedlibs | |
- ) | |
- | |
- install( TARGETS ftdipp-static | |
- ARCHIVE DESTINATION lib${LIB_SUFFIX} | |
- COMPONENT staticlibs | |
- ) | |
- | |
- install( FILES ${cpp_headers} | |
- DESTINATION include/${PROJECT_NAME} | |
- COMPONENT headers | |
- ) | |
- | |
- endif(${UNIX}) | |
- | |
- if(${WIN32}) | |
- | |
- install( TARGETS ftdipp | |
- DESTINATION bin | |
- COMPONENT sharedlibs | |
- ) | |
- | |
- install( TARGETS ftdipp-static | |
- DESTINATION bin | |
- COMPONENT staticlibs | |
- ) | |
- | |
- install( FILES ${cpp_headers} | |
- DESTINATION include/${PROJECT_NAME} | |
- COMPONENT headers | |
- ) | |
- | |
- endif(${WIN32}) | |
+ # Includes | |
+ include_directories(${Boost_INCLUDE_DIRS} | |
+ ${CMAKE_CURRENT_BINARY_DIR} | |
+ ${CMAKE_CURRENT_SOURCE_DIR} | |
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src) | |
+ | |
+ # Targets | |
+ set(cpp_sources ftdi.cpp) | |
+ set(cpp_headers ftdi.hpp) | |
+ | |
+ set(FTDI_BUILD_CPP True PARENT_SCOPE) | |
+ message(STATUS "Building libftdi++") | |
+ | |
+ # Shared library | |
+ add_library(ftdipp SHARED ${cpp_sources}) | |
+ | |
+ math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases | |
+ set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) | |
+ | |
+ # Static library | |
+ add_library(ftdipp-static STATIC ${cpp_sources}) | |
+ set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") | |
+ | |
+ # Prevent clobbering each other during the build | |
+ set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
+ set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
+ | |
+ # Dependencies | |
+ target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) | |
+ | |
+ # Install | |
+ if(${UNIX}) | |
+ install( TARGETS ftdipp | |
+ LIBRARY DESTINATION lib${LIB_SUFFIX} | |
+ COMPONENT sharedlibs | |
+ ) | |
+ install( TARGETS ftdipp-static | |
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} | |
+ COMPONENT staticlibs | |
+ ) | |
+ install( FILES ${cpp_headers} | |
+ DESTINATION include/${PROJECT_NAME} | |
+ COMPONENT headers | |
+ ) | |
+ endif(${UNIX}) | |
+ | |
+ if(${WIN32}) | |
+ install( TARGETS ftdipp | |
+ DESTINATION bin | |
+ COMPONENT sharedlibs | |
+ ) | |
+ install( TARGETS ftdipp-static | |
+ DESTINATION bin | |
+ COMPONENT staticlibs | |
+ ) | |
+ install( FILES ${cpp_headers} | |
+ DESTINATION include/${PROJECT_NAME} | |
+ COMPONENT headers | |
+ ) | |
+ endif(${WIN32}) | |
+ | |
else(Boost_FOUND) | |
- message(STATUS "Boost not found, won't build libftdi++") | |
+ message(STATUS "Boost not found, won't build libftdi++") | |
endif(Boost_FOUND) | |
else(FTDIPP) | |
@@ -86,4 +77,3 @@ else(FTDIPP) | |
message(STATUS "Not building libftdi++") | |
endif(FTDIPP) | |
- | |
diff --git a/src/ftdi.h b/src/ftdi.h | |
index aaa7744..3a0de8b 100644 | |
--- a/src/ftdi.h | |
+++ b/src/ftdi.h | |
@@ -357,9 +357,11 @@ extern "C" | |
int ftdi_write_data_async(struct ftdi_context *ftdi, unsigned char *buf, int size); | |
void ftdi_async_complete(struct ftdi_context *ftdi, int wait_for_more); | |
+ #ifdef LIBFTDI_LINUX_ASYNC_MODE | |
struct ftdi_transfer_control *ftdi_read_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); | |
int ftdi_transfer_data_done(struct ftdi_transfer_control *tc); | |
- | |
+ #endif // LIBFTDI_LINUX_ASYNC_MODE | |
+ | |
int DEPRECATED(ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask)); | |
int ftdi_disable_bitbang(struct ftdi_context *ftdi); | |
int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode); | |
-- | |
1.7.0.2+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment