CMake: rework subdirectory handling
[libftdi] / CMakeLists.txt
index f36912d..7f72e0c 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)
@@ -42,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)
@@ -141,49 +135,34 @@ add_custom_target(dist
             | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
+add_subdirectory(src)
+add_subdirectory(packages)
+
 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
-    COMMENT "Generating API documentation"
-    DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
-  )
-
-  add_custom_target(
-    docs ALL
-    COMMENT "Documentation target docs"
-    DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
-  )
+  add_subdirectory(doc)
 endif ( DOCUMENTATION )
 
-add_subdirectory(src)
 if ( FTDIPP )
   project(libftdi1 C CXX)
   add_subdirectory(ftdipp)
-endif ()
+endif ( FTDIPP )
+
 if ( PYTHON_BINDINGS )
-add_subdirectory(python)
-endif ()
+  add_subdirectory(python)
+endif ( PYTHON_BINDINGS )
+
 if ( FTDI_EEPROM )
   add_subdirectory(ftdi_eeprom)
-endif ()
+endif ( FTDI_EEPROM )
+
 if ( EXAMPLES )
   add_subdirectory(examples)
-endif ()
-add_subdirectory(packages)
+endif ( EXAMPLES )
+
 if ( BUILD_TESTS )
   project(libftdi1 C CXX)
   add_subdirectory(test)
-endif ()
+endif ( BUILD_TESTS )
 
 # PkgConfig
 set(prefix      ${CMAKE_INSTALL_PREFIX})