| 1 | # Includes |
| 2 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} |
| 3 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 4 | ) |
| 5 | |
| 6 | # Version information |
| 7 | set(SNAPSHOT_VERSION "unknown") |
| 8 | execute_process(COMMAND git describe |
| 9 | OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT |
| 10 | RESULT_VARIABLE GIT_DESCRIBE_RESULT |
| 11 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 12 | ) |
| 13 | if(${GIT_DESCRIBE_RESULT} STREQUAL 0) |
| 14 | set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) |
| 15 | endif(${GIT_DESCRIBE_RESULT} STREQUAL 0) |
| 16 | message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}") |
| 17 | |
| 18 | configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY) |
| 19 | |
| 20 | # Targets |
| 21 | set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" ) |
| 22 | set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" ) |
| 23 | |
| 24 | add_library(ftdi1 SHARED ${c_sources}) |
| 25 | |
| 26 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
| 27 | set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) |
| 28 | |
| 29 | # Static library |
| 30 | add_library(ftdi1-static STATIC ${c_sources}) |
| 31 | if (STATICLIBS) |
| 32 | set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1") |
| 33 | endif (STATICLIBS) |
| 34 | |
| 35 | # Prevent clobbering each other during the build |
| 36 | set_target_properties(ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 37 | if (STATICLIBS) |
| 38 | set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 39 | endif (STATICLIBS) |
| 40 | |
| 41 | # Dependencies |
| 42 | target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) |
| 43 | |
| 44 | # Install |
| 45 | if(${UNIX}) |
| 46 | |
| 47 | install( TARGETS ftdi1 |
| 48 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
| 49 | COMPONENT sharedlibs |
| 50 | ) |
| 51 | |
| 52 | if (STATICLIBS) |
| 53 | install( TARGETS ftdi1-static |
| 54 | ARCHIVE DESTINATION lib${LIB_SUFFIX} |
| 55 | COMPONENT staticlibs |
| 56 | ) |
| 57 | endif (STATICLIBS) |
| 58 | |
| 59 | install( FILES ${c_headers} |
| 60 | DESTINATION include/${PROJECT_NAME} |
| 61 | COMPONENT headers |
| 62 | ) |
| 63 | |
| 64 | endif(${UNIX}) |
| 65 | |
| 66 | if(${WIN32}) |
| 67 | |
| 68 | install( TARGETS ftdi1 |
| 69 | DESTINATION bin |
| 70 | COMPONENT sharedlibs |
| 71 | ) |
| 72 | |
| 73 | if (STATICLIBS) |
| 74 | install( TARGETS ftdi1-static |
| 75 | DESTINATION bin |
| 76 | COMPONENT staticlibs |
| 77 | ) |
| 78 | endif (STATICLIBS) |
| 79 | |
| 80 | install( FILES ${c_headers} |
| 81 | DESTINATION include/${PROJECT_NAME} |
| 82 | COMPONENT headers |
| 83 | ) |
| 84 | |
| 85 | endif(${WIN32}) |