Commit | Line | Data |
---|---|---|
0b2d00fc MV |
1 | # Check |
2 | set(FTDI_BUILD_CPP False PARENT_SCOPE) | |
3 | ||
42ece760 | 4 | option(FTDIPP "Build C++ binding library libftdi1++" 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 | 21 | set(FTDI_BUILD_CPP True PARENT_SCOPE) |
42ece760 | 22 | message(STATUS "Building libftdi1++") |
0b2d00fc | 23 | |
998266bf | 24 | # Shared library |
42ece760 | 25 | add_library(ftdipp1 SHARED ${cpp_sources}) |
0b2d00fc | 26 | |
998266bf | 27 | math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatiblity with previous releases |
42ece760 | 28 | set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) |
0b2d00fc | 29 | |
998266bf | 30 | # Static library |
42ece760 TJ |
31 | add_library(ftdipp1-static STATIC ${cpp_sources}) |
32 | set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") | |
b80aee72 | 33 | |
998266bf | 34 | # Prevent clobbering each other during the build |
42ece760 TJ |
35 | set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) |
36 | set_target_properties(ftdipp1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) | |
0b2d00fc | 37 | |
998266bf | 38 | # Dependencies |
42ece760 | 39 | target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) |
a03fea79 | 40 | |
998266bf EB |
41 | # Install |
42 | if(${UNIX}) | |
42ece760 | 43 | install( TARGETS ftdipp1 |
998266bf EB |
44 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
45 | COMPONENT sharedlibs | |
46 | ) | |
42ece760 | 47 | install( TARGETS ftdipp1-static |
998266bf EB |
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 | 57 | if(${WIN32}) |
42ece760 | 58 | install( TARGETS ftdipp1 |
998266bf EB |
59 | DESTINATION bin |
60 | COMPONENT sharedlibs | |
61 | ) | |
42ece760 | 62 | install( TARGETS ftdipp1-static |
998266bf EB |
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) | |
42ece760 | 73 | message(STATUS "Boost not found, won't build libftdi1++") |
a03fea79 GE |
74 | endif(Boost_FOUND) |
75 | ||
76 | else(FTDIPP) | |
77 | ||
42ece760 | 78 | message(STATUS "Not building libftdi1++") |
a03fea79 GE |
79 | |
80 | endif(FTDIPP) |