]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: fix libaio detection
authorKefu Chai <kchai@redhat.com>
Fri, 22 Jul 2016 04:51:04 +0000 (12:51 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 25 Jul 2016 07:40:30 +0000 (15:40 +0800)
* we used to check the header file of "aio.h" which is part of glibc,
  the glibc async i/o, and the corresponding library is librt. but what
  we are using is libaio.
* reference libaio using AIO_LIBRARIES for consistency.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/Findaio.cmake
src/os/CMakeLists.txt

index da4ac11e071a3a48963e28182855c278298102d9..04b064297c0f96bc74ed8e6fec61e5728a1f48b7 100644 (file)
@@ -1,50 +1,18 @@
 # - Find AIO
 #
-# AIO_INCLUDE - Where to find AIO/aio.h
+# AIO_INCLUDE - Where to find libaio.h
 # AIO_LIBS - List of libraries when using AIO.
 # AIO_FOUND - True if AIO found.
 
-get_filename_component(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH)
+find_path(AIO_INCLUDE_DIR
+  libaio.h
+  HINTS $ENV{AIO_ROOT}/include)
 
-# Look for the header file.
-find_path(AIO_INCLUDE 
-NAMES aio.h 
-PATHS /usr/include  $ENV{AIO_ROOT}/include /opt/local/include /usr/local/include 
-DOC "Path in which the file AIO/aio.h is located." )
+find_library(AIO_LIBRARIES
+  aio
+  HINTS $ENV{AIO_ROOT}/lib)
 
-mark_as_advanced(AIO_INCLUDE)
-
-# Look for the library.
-# Does this work on UNIX systems? (LINUX)
-find_library(AIO_LIBS 
-NAMES aio
-PATHS /usr/lib /usr/lib/x86_64-linux-gnu $ENV{AIO_ROOT}/lib 
-DOC "Path to AIO library.")
-
-mark_as_advanced(AIO_LIBS)
-
-# Copy the results to the output variables.
-if (AIO_INCLUDE AND AIO_LIBS)
-  message(STATUS "Found AIO in ${AIO_INCLUDE} ${AIO_LIBS}")
-  set(AIO_FOUND 1)
-  include(CheckCXXSourceCompiles)
-  set(CMAKE_REQUIRED_LIBRARY ${AIO_LIBS} pthread)
-  set(CMAKE_REQUIRED_INCLUDES ${AIO_INCLUDE})
- else ()
-   set(AIO_FOUND 0)
- endif ()
-
- # Report the results.
- if (NOT AIO_FOUND)
-   set(AIO_DIR_MESSAGE "AIO was not found. Make sure AIO_LIBS and AIO_INCLUDE are set.")
-   if (AIO_FIND_REQUIRED)
-     message(FATAL_ERROR "${AIO_DIR_MESSAGE}")
-   elseif (NOT AIO_FIND_QUIETLY)
-     message(STATUS "${AIO_DIR_MESSAGE}")
-   endif ()
- endif ()
-
-# handle the QUIETLY and REQUIRED arguments and set UUID_FOUND to TRUE if
-# all listed variables are TRUE
 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(aio DEFAULT_MSG AIO_LIBS AIO_INCLUDE)
+find_package_handle_standard_args(aio DEFAULT_MSG AIO_LIBRARIES AIO_INCLUDE_DIR)
+
+mark_as_advanced(AIO_INCLUDE_DIR AIO_LIBRARIES)
index ad79e1b022010513746c87bd8357336b216bb2aa..9cc14367c1b403fe78f8d1e38ebd732c64b92926 100644 (file)
@@ -54,7 +54,7 @@ endif()
 add_library(os STATIC ${libos_srcs} $<TARGET_OBJECTS:kv_objs>)
 
 if(HAVE_LIBAIO)
-  target_link_libraries(os aio)
+  target_link_libraries(os ${AIO_LIBRARIES})
 endif()
 
 if(HAVE_LIBFUSE)