Build and install static versions of the libraries
[libftdi] / src / CMakeLists.txt
1 # Includes
2 include_directories( ${CMAKE_CURRENT_BINARY_DIR}
3                      ${CMAKE_CURRENT_SOURCE_DIR}
4                      )
5
6 # Targets
7 set(c_sources     ftdi.c)
8 set(c_headers     ftdi.h)
9
10 add_library(ftdi SHARED ${c_sources})
11
12 # Static library
13 add_library(ftdi-static STATIC ${c_sources})
14 set_target_properties(ftdi-static PROPERTIES OUTPUT_NAME "ftdi")
15
16 # Prevent clobbering each other during the build
17 set_target_properties(ftdi PROPERTIES CLEAN_DIRECT_OUTPUT 1)
18 set_target_properties(ftdi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
19
20 # Dependencies
21 target_link_libraries(ftdi ${LIBUSB_LIBRARIES})
22
23 # Install
24 if(${UNIX})
25
26    install( TARGETS ftdi
27             LIBRARY DESTINATION lib
28             COMPONENT sharedlibs
29             )
30
31    install( TARGETS ftdi-static
32             ARCHIVE DESTINATION lib
33             COMPONENT staticlibs
34             )
35
36    install( FILES ${c_headers}
37             DESTINATION include/${PROJECT_NAME}
38             COMPONENT headers
39             )
40
41 endif(${UNIX})
42
43 if(${WIN32})
44
45    install( TARGETS ftdi
46             DESTINATION bin
47             COMPONENT sharedlibs
48             )
49
50    install( TARGETS ftdi-static
51             DESTINATION bin
52             COMPONENT staticlibs
53             )
54
55    install( FILES ${c_headers}
56             DESTINATION include/${PROJECT_NAME}
57             COMPONENT headers
58             )
59
60 endif(${WIN32})