| 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 ftdi.c ftdi_stream.c) |
| 22 | set(c_headers ftdi.h) |
| 23 | |
| 24 | add_library(ftdi SHARED ${c_sources}) |
| 25 | |
| 26 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
| 27 | set_target_properties(ftdi PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) |
| 28 | |
| 29 | # Static library |
| 30 | add_library(ftdi-static STATIC ${c_sources}) |
| 31 | set_target_properties(ftdi-static PROPERTIES OUTPUT_NAME "ftdi") |
| 32 | |
| 33 | # Prevent clobbering each other during the build |
| 34 | set_target_properties(ftdi PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 35 | set_target_properties(ftdi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 36 | |
| 37 | # Dependencies |
| 38 | target_link_libraries(ftdi ${LIBUSB_LIBRARIES}) |
| 39 | |
| 40 | # Install |
| 41 | if(${UNIX}) |
| 42 | |
| 43 | install( TARGETS ftdi |
| 44 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
| 45 | COMPONENT sharedlibs |
| 46 | ) |
| 47 | |
| 48 | install( TARGETS ftdi-static |
| 49 | ARCHIVE DESTINATION lib${LIB_SUFFIX} |
| 50 | COMPONENT staticlibs |
| 51 | ) |
| 52 | |
| 53 | install( FILES ${c_headers} |
| 54 | DESTINATION include/${PROJECT_NAME} |
| 55 | COMPONENT headers |
| 56 | ) |
| 57 | |
| 58 | endif(${UNIX}) |
| 59 | |
| 60 | if(${WIN32}) |
| 61 | |
| 62 | install( TARGETS ftdi |
| 63 | DESTINATION bin |
| 64 | COMPONENT sharedlibs |
| 65 | ) |
| 66 | |
| 67 | install( TARGETS ftdi-static |
| 68 | DESTINATION bin |
| 69 | COMPONENT staticlibs |
| 70 | ) |
| 71 | |
| 72 | install( FILES ${c_headers} |
| 73 | DESTINATION include/${PROJECT_NAME} |
| 74 | COMPONENT headers |
| 75 | ) |
| 76 | |
| 77 | endif(${WIN32}) |