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