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