Build and install static versions of the libraries
[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 # Static library
24 add_library(ftdipp-static STATIC ${cpp_sources})
25 set_target_properties(ftdipp-static PROPERTIES OUTPUT_NAME "ftdipp")
26
27 # Prevent clobbering each other during the build
28 set_target_properties(ftdipp PROPERTIES CLEAN_DIRECT_OUTPUT 1)
29 set_target_properties(ftdipp-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
30
31 # Dependencies
32 target_link_libraries(ftdipp ftdi ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES})
33
34 # Install
35 if(${UNIX})
36
37    install( TARGETS ftdipp
38             LIBRARY DESTINATION lib
39             COMPONENT sharedlibs
40             )
41
42    install( TARGETS ftdipp-static
43             ARCHIVE DESTINATION lib
44             COMPONENT staticlibs
45             )
46
47    install( FILES ${cpp_headers}
48             DESTINATION include/${PROJECT_NAME}
49             COMPONENT headers
50             )
51
52 endif(${UNIX})
53
54 if(${WIN32})
55
56    install( TARGETS ftdipp
57             DESTINATION bin
58             COMPONENT sharedlibs
59             )
60
61    install( TARGETS ftdipp-static
62             DESTINATION bin
63             COMPONENT staticlibs
64             )
65
66    install( FILES ${cpp_headers}
67             DESTINATION include/${PROJECT_NAME}
68             COMPONENT headers
69             )
70
71 endif(${WIN32})
72
73 else(Boost_FOUND)
74    message(STATUS "Boost not found, won't build libftdi++")
75 endif(Boost_FOUND)