Merge pull request #40336 from tchaikov/wip-cmake-fio

cmake: pass compile options by fio interface library

Reviewed-by: Josh Durgin <jdurgin@redhat.com>
This commit is contained in:
Kefu Chai 2021-03-26 09:28:31 +08:00 committed by GitHub
commit 6152076c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 27 deletions

View File

@ -9,14 +9,15 @@ function(build_fio)
include(FindMake)
find_make("MAKE_EXECUTABLE" "make_cmd")
set(source_dir ${CMAKE_BINARY_DIR}/src/fio)
file(MAKE_DIRECTORY ${source_dir})
ExternalProject_Add(fio_ext
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/src/
UPDATE_COMMAND "" # this disables rebuild on each run
GIT_REPOSITORY "https://github.com/axboe/fio.git"
GIT_CONFIG advice.detachedHead=false
GIT_SHALLOW 1
GIT_TAG "fio-3.15"
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/fio
SOURCE_DIR ${source_dir}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure
BUILD_COMMAND ${make_cmd} fio EXTFLAGS=-Wno-format-truncation ${FIO_EXTLIBS}
@ -25,5 +26,6 @@ function(build_fio)
add_library(fio INTERFACE IMPORTED)
add_dependencies(fio fio_ext)
set_target_properties(fio PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/src/fio)
INTERFACE_INCLUDE_DIRECTORIES ${source_dir}
INTERFACE_COMPILE_OPTIONS "-include;${source_dir}/config-host.h;$<$<COMPILE_LANGUAGE:C>:-std=gnu99>$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>")
endfunction()

View File

@ -10,30 +10,6 @@ target_link_libraries(fio_ceph_messenger fio)
add_library(fio_librgw SHARED fio_librgw.cc)
target_link_libraries(fio_librgw rgw fio)
# prevent fio from adding 'typedef int bool' and gettid()
if(HAVE_GETTID)
set(FIO_CFLAGS "-DCONFIG_HAVE_BOOL -DCONFIG_HAVE_GETTID")
else()
set(FIO_CFLAGS "-DCONFIG_HAVE_BOOL")
endif()
# fio headers use typeof(), which requires c++11 extensions
set_target_properties(fio_ceph_objectstore PROPERTIES
CXX_EXTENSIONS ON
COMPILE_FLAGS "${FIO_CFLAGS}")
set_target_properties(fio_ceph_messenger PROPERTIES
CXX_EXTENSIONS ON
COMPILE_FLAGS "${FIO_CFLAGS}")
set_target_properties(fio_librgw PROPERTIES
CXX_EXTENSIONS ON
COMPILE_FLAGS "${FIO_CFLAGS}")
if(WITH_FIO)
add_dependencies(fio_ceph_objectstore fio_ext)
add_dependencies(fio_ceph_messenger fio_ext)
add_dependencies(fio_librgw fio_ext)
endif()
target_link_libraries(fio_ceph_objectstore os global)
install(TARGETS fio_ceph_objectstore DESTINATION lib)