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