CMakeLists.txt: fix static build with libusb and -latomic
[libftdi] / CMakeLists.txt
index 7771e80..d20aa94 100644 (file)
@@ -1,7 +1,7 @@
 # Project
 project(libftdi1 C)
 set(MAJOR_VERSION 1)
-set(MINOR_VERSION 4)
+set(MINOR_VERSION 5)
 set(PACKAGE libftdi1)
 set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
 set(VERSION ${VERSION_STRING})
@@ -25,8 +25,16 @@ if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
 endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
 
 # find libusb
-find_package ( USB1 REQUIRED )
-include_directories ( ${LIBUSB_INCLUDE_DIR} )
+find_package( PkgConfig )
+if (PkgConfig_FOUND)
+  pkg_check_modules( LIBUSB libusb-1.0 )
+  if (LIBUSB_FOUND)
+    include_directories ( ${LIBUSB_INCLUDE_DIRS} )
+  else()
+    find_package ( USB1 REQUIRED )
+    include_directories ( ${LIBUSB_INCLUDE_DIR} )
+  endif()
+endif()
 
 # Find Boost
 if (FTDIPP OR BUILD_TESTS)
@@ -136,7 +144,7 @@ endif ()
 
 add_subdirectory(src)
 if ( FTDIPP )
-  project(libftdipp1 C CXX)
+  project(libftdi1 C CXX)
   add_subdirectory(ftdipp)
 endif ()
 if ( PYTHON_BINDINGS )
@@ -150,6 +158,7 @@ if ( EXAMPLES )
 endif ()
 add_subdirectory(packages)
 if ( BUILD_TESTS )
+  project(libftdi1 C CXX)
   add_subdirectory(test)
 endif ()