CMake: rework findlibusb module
[libftdi] / CMakeLists.txt
index 9d7f9b6..947fb34 100644 (file)
@@ -1,5 +1,7 @@
 cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
 
+message(STATUS "CMake version: ${CMAKE_VERSION}")
+
 # Project
 project(libftdi1 C)
 set(MAJOR_VERSION 1)
@@ -9,6 +11,23 @@ set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
 set(VERSION ${VERSION_STRING})
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 
+# Support new if() IN_LIST operator
+if(POLICY CMP0057)
+  cmake_policy(SET CMP0057 NEW)
+endif()
+
+# Included scripts do automatic cmake_policy() PUSH and POP
+if(POLICY CMP0011)
+  cmake_policy(SET CMP0011 NEW)
+endif()
+
+# Target link properties INTERFACE_LINK_OPTIONS, INTERFACE_LINK_DIRECTORIES
+# and INTERFACE_LINK_DEPENDS are now transitive over private dependencies
+# of static libraries
+if(POLICY CMP0099)
+  cmake_policy(SET CMP0099 NEW)
+endif()
+
 # CMake
 if("${CMAKE_BUILD_TYPE}" STREQUAL "")
   set(CMAKE_BUILD_TYPE     RelWithDebInfo)
@@ -25,17 +44,9 @@ if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
   add_definitions(-DDEBUG)
 endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
 
-# find libusb
-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 libusb
+find_package ( LibUSB REQUIRED )
+include_directories ( ${LIBUSB_INCLUDE_DIR} )
 
 # Find Boost
 if (FTDIPP OR BUILD_TESTS)
@@ -125,23 +136,8 @@ add_custom_target(dist
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
 if ( DOCUMENTATION )
-  find_package ( Doxygen REQUIRED)
-
-  # Copy doxy.config.in
-  set(top_srcdir ${CMAKE_SOURCE_DIR})
-  configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile )
-  configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.xml.in ${CMAKE_BINARY_DIR}/Doxyfile.xml )
-
-  # Run doxygen
-  add_custom_command(
-    OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html
-    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
-    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
-    DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
-  )
-
-  add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
-endif ()
+  add_subdirectory(doc)
+endif ( DOCUMENTATION )
 
 add_subdirectory(src)
 if ( FTDIPP )