Commit | Line | Data |
---|---|---|
0b2d00fc MV |
1 | # Check |
2 | set(FTDI_BUILD_CPP False PARENT_SCOPE) | |
3 | ||
a03fea79 | 4 | option(FTDIPP "Build C++ binding library libftdi++" ON) |
0b2d00fc | 5 | |
a03fea79 | 6 | if (FTDIPP) |
0b2d00fc | 7 | |
a03fea79 | 8 | if(Boost_FOUND) |
0b2d00fc | 9 | |
998266bf EB |
10 | # Includes |
11 | include_directories(${Boost_INCLUDE_DIRS} | |
12 | ${CMAKE_CURRENT_BINARY_DIR} | |
13 | ${CMAKE_CURRENT_SOURCE_DIR} | |
14 | ${CMAKE_CURRENT_SOURCE_DIR}/../src) | |
b80aee72 | 15 | |
998266bf EB |
16 | # Targets |
17 | set(cpp_sources ftdi.cpp) | |
18 | set(cpp_headers ftdi.hpp) | |
0b2d00fc | 19 | |
998266bf EB |
20 | set(FTDI_BUILD_CPP True PARENT_SCOPE) |
21 | message(STATUS "Building libftdi++") | |
0b2d00fc | 22 | |
998266bf EB |
23 | # Shared library |
24 | add_library(ftdipp SHARED ${cpp_sources}) | |
0b2d00fc | 25 | |
998266bf EB |
26 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
27 | set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1) | |
0b2d00fc | 28 | |
998266bf EB |
29 | # Static library |
30 | add_library(ftdipp-static STATIC ${cpp_sources}) | |
31 | set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp") | |
b80aee72 | 32 | |
998266bf EB |
33 | # Prevent clobbering each other during the build |
34 | set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
35 | set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
0b2d00fc | 36 | |
998266bf EB |
37 | # Dependencies |
38 | target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) | |
a03fea79 | 39 | |
998266bf EB |
40 | # Install |
41 | if(${UNIX}) | |
42 | install( TARGETS ftdipp | |
43 | LIBRARY DESTINATION lib${LIB_SUFFIX} | |
44 | COMPONENT sharedlibs | |
45 | ) | |
46 | install( TARGETS ftdipp-static | |
47 | ARCHIVE DESTINATION lib${LIB_SUFFIX} | |
48 | COMPONENT staticlibs | |
49 | ) | |
50 | install( FILES ${cpp_headers} | |
51 | DESTINATION include/${PROJECT_NAME} | |
52 | COMPONENT headers | |
53 | ) | |
54 | endif(${UNIX}) | |
a03fea79 | 55 | |
998266bf EB |
56 | if(${WIN32}) |
57 | install( TARGETS ftdipp | |
58 | DESTINATION bin | |
59 | COMPONENT sharedlibs | |
60 | ) | |
61 | install( TARGETS ftdipp-static | |
62 | DESTINATION bin | |
63 | COMPONENT staticlibs | |
64 | ) | |
65 | install( FILES ${cpp_headers} | |
66 | DESTINATION include/${PROJECT_NAME} | |
67 | COMPONENT headers | |
68 | ) | |
69 | endif(${WIN32}) | |
a03fea79 GE |
70 | |
71 | else(Boost_FOUND) | |
998266bf | 72 | message(STATUS "Boost not found, won't build libftdi++") |
a03fea79 GE |
73 | endif(Boost_FOUND) |
74 | ||
75 | else(FTDIPP) | |
76 | ||
77 | message(STATUS "Not building libftdi++") | |
78 | ||
79 | endif(FTDIPP) |