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