From: Kefu Chai Date: Fri, 22 Jul 2016 04:51:04 +0000 (+0800) Subject: cmake: fix libaio detection X-Git-Tag: v11.0.1~646^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=94db627c315fba2dd7933f1e5fc19d424e6bc105;p=ceph-ci.git cmake: fix libaio detection * 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 --- diff --git a/cmake/modules/Findaio.cmake b/cmake/modules/Findaio.cmake index da4ac11e071..04b064297c0 100644 --- a/cmake/modules/Findaio.cmake +++ b/cmake/modules/Findaio.cmake @@ -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) diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index ad79e1b0220..9cc14367c1b 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -54,7 +54,7 @@ endif() add_library(os STATIC ${libos_srcs} $) if(HAVE_LIBAIO) - target_link_libraries(os aio) + target_link_libraries(os ${AIO_LIBRARIES}) endif() if(HAVE_LIBFUSE)