| 1 | # Includes |
| 2 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} |
| 3 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 4 | ) |
| 5 | |
| 6 | # Targets |
| 7 | set(c_sources ftdi.c) |
| 8 | set(c_headers ftdi.h) |
| 9 | |
| 10 | add_library(ftdi SHARED ${c_sources}) |
| 11 | |
| 12 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
| 13 | set_target_properties(ftdi PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) |
| 14 | |
| 15 | # Static library |
| 16 | add_library(ftdi-static STATIC ${c_sources}) |
| 17 | set_target_properties(ftdi-static PROPERTIES OUTPUT_NAME "ftdi") |
| 18 | |
| 19 | # Prevent clobbering each other during the build |
| 20 | set_target_properties(ftdi PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 21 | set_target_properties(ftdi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 22 | |
| 23 | # Dependencies |
| 24 | target_link_libraries(ftdi ${LIBUSB_LIBRARIES}) |
| 25 | |
| 26 | # Install |
| 27 | if(${UNIX}) |
| 28 | |
| 29 | install( TARGETS ftdi |
| 30 | LIBRARY DESTINATION lib |
| 31 | COMPONENT sharedlibs |
| 32 | ) |
| 33 | |
| 34 | install( TARGETS ftdi-static |
| 35 | ARCHIVE DESTINATION lib |
| 36 | COMPONENT staticlibs |
| 37 | ) |
| 38 | |
| 39 | install( FILES ${c_headers} |
| 40 | DESTINATION include/${PROJECT_NAME} |
| 41 | COMPONENT headers |
| 42 | ) |
| 43 | |
| 44 | endif(${UNIX}) |
| 45 | |
| 46 | if(${WIN32}) |
| 47 | |
| 48 | install( TARGETS ftdi |
| 49 | DESTINATION bin |
| 50 | COMPONENT sharedlibs |
| 51 | ) |
| 52 | |
| 53 | install( TARGETS ftdi-static |
| 54 | DESTINATION bin |
| 55 | COMPONENT staticlibs |
| 56 | ) |
| 57 | |
| 58 | install( FILES ${c_headers} |
| 59 | DESTINATION include/${PROJECT_NAME} |
| 60 | COMPONENT headers |
| 61 | ) |
| 62 | |
| 63 | endif(${WIN32}) |