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