summaryrefslogtreecommitdiff
path: root/tpool
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-20 16:23:47 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-20 16:23:47 +0200
commite8113f7572ef7eab45b7b696429101690caeeed4 (patch)
tree8a49dbb8a5ad672cd5e002726a6a79a1cf799ad7 /tpool
parent4eeea4e212755408ca963d22faa11c12963c1d0a (diff)
downloadmariadb-git-e8113f7572ef7eab45b7b696429101690caeeed4.tar.gz
CMake cleanup: Make WITH_URING, WITH_PMEM Boolean
The new default values WITH_URING:BOOL=OFF, WITH_PMEM:BOOL=OFF imply that the dependencies are optional. An explicit request WITH_URING=ON or WITH_PMEM=ON will cause the build to fail if the requested dependencies are not available. Last, to prevent a feature to be built in even though the built-time dependencies are available, the following can be used: cmake -DCMAKE_DISABLE_FIND_PACKAGE_URING=1 cmake -DCMAKE_DISABLE_FIND_PACKAGE_PMEM=1 This cleanup was suggested by Vladislav Vaintroub.
Diffstat (limited to 'tpool')
-rw-r--r--tpool/CMakeLists.txt43
1 files changed, 25 insertions, 18 deletions
diff --git a/tpool/CMakeLists.txt b/tpool/CMakeLists.txt
index b27f2c84938..213cef7b5de 100644
--- a/tpool/CMakeLists.txt
+++ b/tpool/CMakeLists.txt
@@ -1,20 +1,29 @@
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include)
IF(WIN32)
SET(EXTRA_SOURCES tpool_win.cc aio_win.cc)
-ENDIF()
-
-IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LIBURING)
- SET(EXTRA_SOURCES aio_liburing.cc)
-ENDIF()
-
-IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT LIBURING)
- CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H)
- CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
- IF(HAVE_LIBAIO_H AND HAVE_LIBAIO)
- ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1)
- LINK_LIBRARIES(aio)
- SET(EXTRA_SOURCES aio_linux.cc)
- ENDIF()
+ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ OPTION(WITH_URING "Require that io_uring be used" OFF)
+ FIND_PACKAGE(URING)
+ IF(URING_FOUND)
+ SET(URING_FOUND ${URING_FOUND} PARENT_SCOPE)
+ SET(TPOOL_DEFINES "-DHAVE_URING" PARENT_SCOPE)
+ ADD_DEFINITIONS(-DHAVE_URING)
+ LINK_LIBRARIES(${LIBURING_LIBRARIES})
+ INCLUDE_DIRECTORIES(${LIBURING_INCLUDE_DIR})
+ SET(EXTRA_SOURCES aio_liburing.cc)
+ ELSE()
+ IF(WITH_URING)
+ MESSAGE(FATAL_ERROR "WITH_URING=ON cannot be satisfied")
+ ENDIF()
+ CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H)
+ CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
+ IF(HAVE_LIBAIO_H AND HAVE_LIBAIO)
+ SET(TPOOL_DEFINES "-DLINUX_NATIVE_AIO" PARENT_SCOPE)
+ ADD_DEFINITIONS(-DLINUX_NATIVE_AIO)
+ LINK_LIBRARIES(aio)
+ SET(EXTRA_SOURCES aio_linux.cc)
+ ENDIF()
+ ENDIF()
ENDIF()
ADD_LIBRARY(tpool STATIC
@@ -29,8 +38,6 @@ ADD_LIBRARY(tpool STATIC
${EXTRA_SOURCES}
)
-IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LIBURING)
+IF(URING_FOUND)
ADD_DEPENDENCIES(tpool GenError)
ENDIF()
-
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)