| 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 () |
| 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") # Compatibility with previous releases |
| 27 | set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) |
| 28 | # Prevent clobbering each other during the build |
| 29 | set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) |
| 30 | |
| 31 | |
| 32 | # Dependencies |
| 33 | target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) |
| 34 | |
| 35 | install ( TARGETS ftdi1 |
| 36 | RUNTIME DESTINATION bin |
| 37 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
| 38 | ARCHIVE DESTINATION lib${LIB_SUFFIX} |
| 39 | ) |
| 40 | |
| 41 | if ( STATICLIBS ) |
| 42 | add_library(ftdi1-static STATIC ${c_sources}) |
| 43 | target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES}) |
| 44 | set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1") |
| 45 | set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
| 46 | install ( TARGETS ftdi1-static |
| 47 | ARCHIVE DESTINATION lib${LIB_SUFFIX} |
| 48 | COMPONENT staticlibs |
| 49 | ) |
| 50 | endif () |
| 51 | |
| 52 | install ( FILES ${c_headers} |
| 53 | DESTINATION include/${PROJECT_NAME} |
| 54 | COMPONENT headers |
| 55 | ) |