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 | ||
24 | add_library(ftdi SHARED ${c_sources}) | |
25 | ||
52448565 TJ |
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 1) | |
28 | ||
b80aee72 TJ |
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 | ||
0b2d00fc | 37 | # Dependencies |
89a3169e | 38 | target_link_libraries(ftdi ${LIBUSB_LIBRARIES}) |
0b2d00fc MV |
39 | |
40 | # Install | |
41 | if(${UNIX}) | |
42 | ||
43 | install( TARGETS ftdi | |
20a28968 | 44 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
0b2d00fc MV |
45 | COMPONENT sharedlibs |
46 | ) | |
47 | ||
b80aee72 | 48 | install( TARGETS ftdi-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 | ||
62 | install( TARGETS ftdi | |
63 | DESTINATION bin | |
64 | COMPONENT sharedlibs | |
65 | ) | |
66 | ||
b80aee72 TJ |
67 | install( TARGETS ftdi-static |
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}) |