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