Commit | Line | Data |
---|---|---|
0b2d00fc | 1 | # Includes |
a4eac204 | 2 | include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} |
0b2d00fc MV |
3 | ${CMAKE_CURRENT_SOURCE_DIR} |
4 | ) | |
5 | ||
0220adfa TJ |
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) | |
6d4f7fba | 14 | set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) |
15 | endif () | |
0220adfa TJ |
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 | ||
0b2d00fc | 20 | # Targets |
5f70b4c1 MZ |
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" ) | |
0b2d00fc | 23 | |
42ece760 | 24 | add_library(ftdi1 SHARED ${c_sources}) |
0b2d00fc | 25 | |
db9c7eba | 26 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases |
42ece760 | 27 | set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) |
b80aee72 | 28 | # Prevent clobbering each other during the build |
6d4f7fba | 29 | set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) |
30 | ||
b80aee72 | 31 | |
0b2d00fc | 32 | # Dependencies |
42ece760 | 33 | target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) |
0b2d00fc | 34 | |
6d4f7fba | 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 | ) |