Set VERSION and SOVERSION on shared libraries (compatible with versions from the...
[libftdi] / src / CMakeLists.txt
index 7965999..0a6a917 100644 (file)
@@ -9,6 +9,17 @@ set(c_headers     ftdi.h)
 
 add_library(ftdi SHARED ${c_sources})
 
+math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1")    # Compatiblity with previous releases
+set_target_properties(ftdi PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 1)
+
+# Static library
+add_library(ftdi-static STATIC ${c_sources})
+set_target_properties(ftdi-static PROPERTIES OUTPUT_NAME "ftdi")
+
+# Prevent clobbering each other during the build
+set_target_properties(ftdi PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+set_target_properties(ftdi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+
 # Dependencies
 target_link_libraries(ftdi ${LIBUSB_LIBRARIES})
 
@@ -20,6 +31,11 @@ if(${UNIX})
             COMPONENT sharedlibs
             )
 
+   install( TARGETS ftdi-static
+            ARCHIVE DESTINATION lib
+            COMPONENT staticlibs
+            )
+
    install( FILES ${c_headers}
             DESTINATION include/${PROJECT_NAME}
             COMPONENT headers
@@ -34,6 +50,11 @@ if(${WIN32})
             COMPONENT sharedlibs
             )
 
+   install( TARGETS ftdi-static
+            DESTINATION bin
+            COMPONENT staticlibs
+            )
+
    install( FILES ${c_headers}
             DESTINATION include/${PROJECT_NAME}
             COMPONENT headers