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