building parts of libftdi via cmake is now optional.
[libftdi] / ftdipp / CMakeLists.txt
CommitLineData
0b2d00fc
MV
1# Check
2set(FTDI_BUILD_CPP False PARENT_SCOPE)
3
a03fea79 4option(FTDIPP "Build C++ binding library libftdi++" ON)
0b2d00fc 5
a03fea79 6if (FTDIPP)
0b2d00fc 7
a03fea79
GE
8 # Includes
9 include_directories( ${CMAKE_CURRENT_BINARY_DIR}
10 ${CMAKE_CURRENT_SOURCE_DIR}
11 ${CMAKE_CURRENT_SOURCE_DIR}/../src
12 )
0b2d00fc 13
a03fea79
GE
14 # Targets
15 set(cpp_sources ftdi.cpp)
16 set(cpp_headers ftdi.hpp)
0b2d00fc 17
a03fea79
GE
18 # Find Boost
19 find_package(Boost)
20 if(Boost_FOUND)
21 set(FTDI_BUILD_CPP True PARENT_SCOPE)
22 message(STATUS "Building libftdi++")
52448565 23
a03fea79
GE
24 # Targets
25 add_library(ftdipp SHARED ${cpp_sources})
b80aee72 26
a03fea79
GE
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)
b80aee72 29
a03fea79
GE
30 # Static library
31 add_library(ftdipp-static STATIC ${cpp_sources})
32 set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp")
0b2d00fc 33
a03fea79
GE
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
a03fea79
GE
38 # Dependencies
39 target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES})
0b2d00fc 40
a03fea79
GE
41 # Install
42 if(${UNIX})
b80aee72 43
a03fea79
GE
44 install( TARGETS ftdipp
45 LIBRARY DESTINATION lib${LIB_SUFFIX}
46 COMPONENT sharedlibs
47 )
0b2d00fc 48
a03fea79
GE
49 install( TARGETS ftdipp-static
50 ARCHIVE DESTINATION lib${LIB_SUFFIX}
51 COMPONENT staticlibs
52 )
0b2d00fc 53
a03fea79
GE
54 install( FILES ${cpp_headers}
55 DESTINATION include/${PROJECT_NAME}
56 COMPONENT headers
57 )
0b2d00fc 58
a03fea79 59 endif(${UNIX})
0b2d00fc 60
a03fea79 61 if(${WIN32})
b80aee72 62
a03fea79
GE
63 install( TARGETS ftdipp
64 DESTINATION bin
65 COMPONENT sharedlibs
66 )
0b2d00fc 67
a03fea79
GE
68 install( TARGETS ftdipp-static
69 DESTINATION bin
70 COMPONENT staticlibs
71 )
72
73 install( FILES ${cpp_headers}
74 DESTINATION include/${PROJECT_NAME}
75 COMPONENT headers
76 )
77
78 endif(${WIN32})
79
80 else(Boost_FOUND)
81 message(STATUS "Boost not found, won't build libftdi++")
82 endif(Boost_FOUND)
83
84else(FTDIPP)
85
86 message(STATUS "Not building libftdi++")
87
88endif(FTDIPP)
0b2d00fc 89