272b8f6a76acbaf6211efe2d470db1c30d2d716d
[libftdi] / ftdipp / CMakeLists.txt
1 # Targets
2 set(cpp_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.cpp CACHE INTERNAL "List of cpp sources")
3 set(cpp_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.hpp CACHE INTERNAL "List of cpp headers")
4
5 # Includes
6 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}
7         ${CMAKE_CURRENT_SOURCE_DIR}
8         ${PROJECT_SOURCE_DIR}/src
9 )
10
11 # Shared library
12 if (SHAREDLIBS)
13     add_library(ftdipp1 SHARED ${cpp_sources})
14     math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1")    # Compatibility with previous releases
15     set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 3)
16     # Prevent clobbering each other during the build
17     set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1)
18     # Dependencies
19     target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES})
20     install(TARGETS ftdipp1
21             RUNTIME DESTINATION bin
22             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
23             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
24     )
25 endif ()
26
27 # Static library
28 if (STATICLIBS)
29     add_library(ftdipp1-static STATIC ${cpp_sources})
30     set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1")
31     set_target_properties(ftdipp1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
32     target_link_libraries(ftdipp1-static ftdi1-static ${LIBUSB_LIBRARIES})
33     install(TARGETS ftdipp1-static
34             ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
35             COMPONENT staticlibs
36     )
37 endif ()
38
39 install(FILES ${cpp_headers}
40         DESTINATION include/${PROJECT_NAME}
41         COMPONENT headers
42 )