| 1 | # Check |
| 2 | set(FTDI_BUILD_CPP False PARENT_SCOPE) |
| 3 | |
| 4 | option(FTDIPP "Build C++ binding library libftdi++" ON) |
| 5 | |
| 6 | if (FTDIPP) |
| 7 | |
| 8 | if(Boost_FOUND) |
| 9 | |
| 10 | # Includes |
| 11 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} |
| 12 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 13 | ${CMAKE_SOURCE_DIR}/src) |
| 14 | |
| 15 | include_directories(${Boost_INCLUDE_DIRS}) |
| 16 | |
| 17 | # Targets |
| 18 | set(cpp_sources ftdi.cpp) |
| 19 | set(cpp_headers ftdi.hpp) |
| 20 | |
| 21 | set(FTDI_BUILD_CPP True PARENT_SCOPE) |
| 22 | message(STATUS "Building libftdi++") |
| 23 | |
| 24 | # Shared library |
| 25 | add_library(ftdipp SHARED ${cpp_sources}) |
| 26 | |
| 27 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
| 28 | set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) |
| 29 | |
| 30 | # Static library |
| 31 | add_library(ftdipp-static STATIC ${cpp_sources}) |
| 32 | set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") |
| 33 | |
| 34 | # Prevent clobbering each other during the build |
| 35 | set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 36 | set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 37 | |
| 38 | # Dependencies |
| 39 | target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) |
| 40 | |
| 41 | # Install |
| 42 | if(${UNIX}) |
| 43 | install( TARGETS ftdipp |
| 44 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
| 45 | COMPONENT sharedlibs |
| 46 | ) |
| 47 | install( TARGETS ftdipp-static |
| 48 | ARCHIVE DESTINATION lib${LIB_SUFFIX} |
| 49 | COMPONENT staticlibs |
| 50 | ) |
| 51 | install( FILES ${cpp_headers} |
| 52 | DESTINATION include/${PROJECT_NAME} |
| 53 | COMPONENT headers |
| 54 | ) |
| 55 | endif(${UNIX}) |
| 56 | |
| 57 | if(${WIN32}) |
| 58 | install( TARGETS ftdipp |
| 59 | DESTINATION bin |
| 60 | COMPONENT sharedlibs |
| 61 | ) |
| 62 | install( TARGETS ftdipp-static |
| 63 | DESTINATION bin |
| 64 | COMPONENT staticlibs |
| 65 | ) |
| 66 | install( FILES ${cpp_headers} |
| 67 | DESTINATION include/${PROJECT_NAME} |
| 68 | COMPONENT headers |
| 69 | ) |
| 70 | endif(${WIN32}) |
| 71 | |
| 72 | else(Boost_FOUND) |
| 73 | message(STATUS "Boost not found, won't build libftdi++") |
| 74 | endif(Boost_FOUND) |
| 75 | |
| 76 | else(FTDIPP) |
| 77 | |
| 78 | message(STATUS "Not building libftdi++") |
| 79 | |
| 80 | endif(FTDIPP) |