515dc91dc835efb0c876d0cc7d3357207ea4d53c
[libftdi] / ftdipp / CMakeLists.txt
1 # Check
2 set(FTDI_BUILD_CPP False PARENT_SCOPE)
3
4 # Includes
5 include_directories( ${CMAKE_CURRENT_BINARY_DIR}
6                      ${CMAKE_CURRENT_SOURCE_DIR}
7                      ${CMAKE_CURRENT_SOURCE_DIR}/../src
8                      )
9
10 # Targets
11 set(cpp_sources   ftdi.cpp)
12 set(cpp_headers   ftdi.hpp)
13
14 # Find Boost
15 find_package(Boost)
16 if(Boost_FOUND)
17 set(FTDI_BUILD_CPP True PARENT_SCOPE)
18 message(STATUS "Building libftdi++")
19
20 # Targets
21 add_library(ftdipp SHARED ${cpp_sources})
22
23 math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1")    # Compatiblity with previous releases
24 set_target_properties(ftdipp PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1)
25
26 # Static library
27 add_library(ftdipp-static STATIC ${cpp_sources})
28 set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp")
29
30 # Prevent clobbering each other during the build
31 set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1)
32 set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
33
34 # Dependencies
35 target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES})
36
37 # Install
38 if(${UNIX})
39
40    install( TARGETS ftdipp
41             LIBRARY DESTINATION lib${LIB_SUFFIX}
42             COMPONENT sharedlibs
43             )
44
45    install( TARGETS ftdipp-static
46             ARCHIVE DESTINATION lib${LIB_SUFFIX}
47             COMPONENT staticlibs
48             )
49
50    install( FILES ${cpp_headers}
51             DESTINATION include/${PROJECT_NAME}
52             COMPONENT headers
53             )
54
55 endif(${UNIX})
56
57 if(${WIN32})
58
59    install( TARGETS ftdipp
60             DESTINATION bin
61             COMPONENT sharedlibs
62             )
63
64    install( TARGETS ftdipp-static
65             DESTINATION bin
66             COMPONENT staticlibs
67             )
68
69    install( FILES ${cpp_headers}
70             DESTINATION include/${PROJECT_NAME}
71             COMPONENT headers
72             )
73
74 endif(${WIN32})
75
76 else(Boost_FOUND)
77    message(STATUS "Boost not found, won't build libftdi++")
78 endif(Boost_FOUND)