diff options
29 files changed, 86 insertions, 241 deletions
diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index a4ed7fbd88a..4ca83eabba0 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -49,5 +49,4 @@ function(add_ceph_unittest unittest_name) endif() add_ceph_test(${unittest_name} "${UNITTEST}") target_link_libraries(${unittest_name} ${UNITTEST_LIBS}) - set_target_properties(${unittest_name} PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) endfunction() diff --git a/cmake/modules/FindGMock.cmake b/cmake/modules/FindGMock.cmake new file mode 100644 index 00000000000..ea53f648167 --- /dev/null +++ b/cmake/modules/FindGMock.cmake @@ -0,0 +1,21 @@ +find_path(GMock_INCLUDE_DIR NAMES gmock/gmock.h) +find_library(GMock_GMock_LIBRARY NAMES gmock) +find_library(GMock_Main_LIBRARY NAMES gmock_main) + +find_package_handle_standard_args(GMock + REQUIRED_VARS + GMock_GMock_LIBRARY + GMock_Main_LIBRARY + GMock_INCLUDE_DIR) + +if(GMock_FOUND) + foreach(c GMock Main) + if(NOT TARGET GMock::${c}) + add_library(GMock::${c} UNKNOWN IMPORTED) + set_target_properties(GMock::${c} PROPERTIES + IMPORTED_LOCATION "${GMock_${c}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GMock_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") + endif() + endforeach() +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 556e9c775d7..5a8bf7490a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -293,17 +293,9 @@ add_subdirectory(json_spirit) include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash") include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/rapidjson/include") -set(GMOCK_INCLUDE_DIRS - "${CMAKE_SOURCE_DIR}/src/googletest/googletest/include/gmock") -set(GTEST_INCLUDE_DIRS - "${CMAKE_SOURCE_DIR}/src/googletest/googletest/include/gtest") - include_directories("${CMAKE_SOURCE_DIR}/src/dmclock/src") include_directories("${CMAKE_SOURCE_DIR}/src/dmclock/support/src") -# needed for source files that friend unit tests (e.g., using FRIEND_TEST) -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/googletest/googletest/include") - if(WITH_SEASTAR) find_package(fmt 4.0.0 QUIET) if(NOT fmt_FOUND) @@ -541,7 +533,22 @@ add_subdirectory(erasure-code) # Support/Tools if(WITH_TESTS) - add_subdirectory(googletest/googlemock) + option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF) + if(WITH_SYSTEM_GTEST) + find_package(GTest REQUIRED) + find_package(GMock REQUIRED) + else() + add_subdirectory(googletest/googlemock) + add_library(GMock::GMock ALIAS gmock) + add_library(GMock::Main ALIAS gmock_main) + target_include_directories(gmock INTERFACE + $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>) + target_include_directories(gmock_main INTERFACE + $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>) + add_library(GTest::GTest ALIAS gtest) + add_library(GTest::Main ALIAS gtest_main) + endif() + add_subdirectory(test) endif(WITH_TESTS) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 28c5dc213cc..75deeaf7ade 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,11 +1,10 @@ include(AddCephTest) -set(UNITTEST_LIBS gmock_main gmock gtest ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) -set(UNITTEST_CXX_FLAGS "-I${CMAKE_SOURCE_DIR}/src/googletest/googlemock/include -I${CMAKE_BINARY_DIR}/src/googletest/googlemock/include -I${CMAKE_SOURCE_DIR}/src/googletest/googletest/include -I${CMAKE_BINARY_DIR}/src/googletest/googletest/include -fno-strict-aliasing") +set(UNITTEST_LIBS GMock::Main GMock::GMock GTest::GTest ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) add_library(unit-main OBJECT unit.cc) -set_source_files_properties(unit.cc PROPERTIES - COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) +target_include_directories(unit-main PRIVATE + $<TARGET_PROPERTY:GTest::GTest,INTERFACE_INCLUDE_DIRECTORIES>) add_subdirectory(cls_hello) add_subdirectory(cls_lock) @@ -186,8 +185,6 @@ if(${WITH_RADOSGW}) ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) - set_target_properties(test_cors PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) # ceph_test_cls_rgw_meta set(test_cls_rgw_meta_srcs test_rgw_admin_meta.cc) @@ -209,8 +206,6 @@ if(${WITH_RADOSGW}) ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${CRYPTO_LIBS}) - set_target_properties(ceph_test_cls_rgw_meta PROPERTIES - COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) install(TARGETS ceph_test_cls_rgw_meta @@ -242,8 +237,6 @@ if(${WITH_RADOSGW}) ${EXTRALIBS} ${CRYPTO_LIBS} ) - set_target_properties(ceph_test_cls_rgw_log PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) # ceph_test_cls_rgw_opstate set(ceph_test_cls_rgw_opstate_srcs test_rgw_admin_opstate.cc) @@ -270,15 +263,11 @@ if(${WITH_RADOSGW}) ${CRYPTO_LIBS} ${EXTRALIBS} ) - set_target_properties(ceph_test_cls_rgw_opstate PROPERTIES - COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) # ceph_test_librgw_file (nfs-like RGW interface) add_executable(ceph_test_librgw_file librgw_file.cc ) -set_target_properties(ceph_test_librgw_file PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) if(WITH_RADOSGW_FCGI_FRONTEND) target_include_directories(ceph_test_librgw_file SYSTEM PRIVATE ${FCGI_INCLUDE_DIR}) endif(WITH_RADOSGW_FCGI_FRONTEND) @@ -294,8 +283,6 @@ target_link_libraries(ceph_test_librgw_file add_executable(ceph_test_librgw_file_cd librgw_file_cd.cc ) -set_target_properties(ceph_test_librgw_file_cd PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_librgw_file_cd rgw librados @@ -308,8 +295,6 @@ target_link_libraries(ceph_test_librgw_file_cd add_executable(ceph_test_librgw_file_gp librgw_file_gp.cc ) -set_target_properties(ceph_test_librgw_file_gp PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_librgw_file_gp rgw librados @@ -322,8 +307,6 @@ target_link_libraries(ceph_test_librgw_file_gp add_executable(ceph_test_librgw_file_nfsns librgw_file_nfsns.cc ) -set_target_properties(ceph_test_librgw_file_nfsns PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) if(WITH_RADOSGW_FCGI_FRONTEND) target_include_directories(ceph_test_librgw_file_nfsns SYSTEM PRIVATE ${FCGI_INCLUDE_DIR}) endif(WITH_RADOSGW_FCGI_FRONTEND) @@ -339,8 +322,6 @@ target_link_libraries(ceph_test_librgw_file_nfsns add_executable(ceph_test_librgw_file_aw librgw_file_aw.cc ) -set_target_properties(ceph_test_librgw_file_aw PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_librgw_file_aw rgw librados @@ -353,8 +334,6 @@ target_link_libraries(ceph_test_librgw_file_aw add_executable(ceph_test_librgw_file_marker librgw_file_marker.cc ) -set_target_properties(ceph_test_librgw_file_marker PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_librgw_file_marker rgw librados @@ -367,8 +346,6 @@ target_link_libraries(ceph_test_librgw_file_marker add_executable(ceph_test_rgw_token test_rgw_token.cc ) -set_target_properties(ceph_test_rgw_token PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_rgw_token rgw os @@ -382,8 +359,6 @@ add_executable(test_rgw_ldap ${CMAKE_SOURCE_DIR}/src/rgw/rgw_ldap.cc test_rgw_ldap.cc ) -set_target_properties(test_rgw_ldap PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(test_rgw_ldap librados ceph-common @@ -393,7 +368,6 @@ target_link_libraries(test_rgw_ldap # unittest_librgw_admin_user add_executable(ceph_test_librgw_admin_user test_librgw_admin_user.cc) -set_target_properties(ceph_test_librgw_admin_user PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_librgw_admin_user rgw_admin_user cls_otp_client @@ -440,8 +414,6 @@ install(TARGETS add_executable(ceph_test_filejournal test_filejournal.cc ) -set_target_properties(ceph_test_filejournal PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_filejournal os ceph-common @@ -468,13 +440,10 @@ add_executable(ceph_test_snap_mapper $<TARGET_OBJECTS:unit-main> ) target_link_libraries(ceph_test_snap_mapper osd global ${BLKID_LIBRARIES} ${UNITTEST_LIBS}) -set_target_properties(ceph_test_snap_mapper PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) add_executable(ceph_test_stress_watch test_stress_watch.cc ) -set_target_properties(ceph_test_stress_watch PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_stress_watch librados ${UNITTEST_LIBS} diff --git a/src/test/ObjectMap/CMakeLists.txt b/src/test/ObjectMap/CMakeLists.txt index d5608f331d4..837ec5434fa 100644 --- a/src/test/ObjectMap/CMakeLists.txt +++ b/src/test/ObjectMap/CMakeLists.txt @@ -3,8 +3,6 @@ add_executable(ceph_test_object_map test_object_map.cc KeyValueDBMemory.cc ) -set_target_properties(ceph_test_object_map PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) add_ceph_unittest(ceph_test_object_map) target_link_libraries(ceph_test_object_map os @@ -19,8 +17,6 @@ target_link_libraries(ceph_test_object_map add_executable(ceph_test_keyvaluedb_atomicity test_keyvaluedb_atomicity.cc ) -set_target_properties(ceph_test_keyvaluedb_atomicity PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_keyvaluedb_atomicity os ceph-common @@ -35,8 +31,6 @@ add_executable(ceph_test_keyvaluedb_iterators test_keyvaluedb_iterators.cc KeyValueDBMemory.cc ) -set_target_properties(ceph_test_keyvaluedb_iterators PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_keyvaluedb_iterators os ceph-common diff --git a/src/test/cls_hello/CMakeLists.txt b/src/test/cls_hello/CMakeLists.txt index fa4a526afa0..4ed22132f26 100644 --- a/src/test/cls_hello/CMakeLists.txt +++ b/src/test/cls_hello/CMakeLists.txt @@ -1,8 +1,6 @@ add_executable(ceph_test_cls_hello test_cls_hello.cc ) -set_target_properties(ceph_test_cls_hello PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_hello librados global diff --git a/src/test/cls_journal/CMakeLists.txt b/src/test/cls_journal/CMakeLists.txt index 6e99cdc5af0..3f2cad9c01f 100644 --- a/src/test/cls_journal/CMakeLists.txt +++ b/src/test/cls_journal/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(ceph_test_cls_journal test_cls_journal.cc $<TARGET_OBJECTS:common_texttable_obj>) -set_target_properties(ceph_test_cls_journal PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_journal cls_journal_client librados diff --git a/src/test/cls_lock/CMakeLists.txt b/src/test/cls_lock/CMakeLists.txt index 75e3ead6067..49214e17e68 100644 --- a/src/test/cls_lock/CMakeLists.txt +++ b/src/test/cls_lock/CMakeLists.txt @@ -1,8 +1,6 @@ add_executable(ceph_test_cls_lock test_cls_lock.cc ) -set_target_properties(ceph_test_cls_lock PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_lock cls_lock_client librados diff --git a/src/test/cls_log/CMakeLists.txt b/src/test/cls_log/CMakeLists.txt index b370645cec4..acbd31d6bd9 100644 --- a/src/test/cls_log/CMakeLists.txt +++ b/src/test/cls_log/CMakeLists.txt @@ -1,8 +1,5 @@ add_executable(ceph_test_cls_log - test_cls_log.cc - ) -set_target_properties(ceph_test_cls_log PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + test_cls_log.cc) target_link_libraries(ceph_test_cls_log librados cls_log_client diff --git a/src/test/cls_lua/CMakeLists.txt b/src/test/cls_lua/CMakeLists.txt index 2ccb851cd89..1bc8c4cce6e 100644 --- a/src/test/cls_lua/CMakeLists.txt +++ b/src/test/cls_lua/CMakeLists.txt @@ -1,8 +1,6 @@ add_executable(ceph_test_cls_lua test_cls_lua.cc ) -set_target_properties(ceph_test_cls_lua PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_lua cls_lua_client liblua diff --git a/src/test/cls_numops/CMakeLists.txt b/src/test/cls_numops/CMakeLists.txt index a91137648ef..b52d7f9894a 100644 --- a/src/test/cls_numops/CMakeLists.txt +++ b/src/test/cls_numops/CMakeLists.txt @@ -1,8 +1,6 @@ # ceph_test_cls_numops add_executable(ceph_test_cls_numops test_cls_numops.cc) -set_target_properties(ceph_test_cls_numops PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_numops librados global diff --git a/src/test/cls_rbd/CMakeLists.txt b/src/test/cls_rbd/CMakeLists.txt index 7afcf33b3ba..0e1175ac3d0 100644 --- a/src/test/cls_rbd/CMakeLists.txt +++ b/src/test/cls_rbd/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(ceph_test_cls_rbd test_cls_rbd.cc $<TARGET_OBJECTS:common_texttable_obj>) -set_target_properties(ceph_test_cls_rbd PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_rbd librbd cls_rbd_client diff --git a/src/test/cls_refcount/CMakeLists.txt b/src/test/cls_refcount/CMakeLists.txt index ab036315d08..9983828456f 100644 --- a/src/test/cls_refcount/CMakeLists.txt +++ b/src/test/cls_refcount/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(ceph_test_cls_refcount test_cls_refcount.cc ) -set_target_properties(ceph_test_cls_refcount PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_refcount librados cls_refcount_client diff --git a/src/test/cls_rgw/CMakeLists.txt b/src/test/cls_rgw/CMakeLists.txt index 3352db233ce..ca53e9dfc7d 100644 --- a/src/test/cls_rgw/CMakeLists.txt +++ b/src/test/cls_rgw/CMakeLists.txt @@ -2,8 +2,6 @@ if(${WITH_RADOSGW}) add_executable(ceph_test_cls_rgw test_cls_rgw.cc ) - set_target_properties(ceph_test_cls_rgw PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_rgw cls_rgw_client librados diff --git a/src/test/cls_sdk/CMakeLists.txt b/src/test/cls_sdk/CMakeLists.txt index 2579b9c76b0..d75971276c2 100644 --- a/src/test/cls_sdk/CMakeLists.txt +++ b/src/test/cls_sdk/CMakeLists.txt @@ -1,8 +1,6 @@ add_executable(ceph_test_cls_sdk test_cls_sdk.cc ) -set_target_properties(ceph_test_cls_sdk PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_sdk librados global diff --git a/src/test/cls_statelog/CMakeLists.txt b/src/test/cls_statelog/CMakeLists.txt index 5f77979de0a..91e7861005f 100644 --- a/src/test/cls_statelog/CMakeLists.txt +++ b/src/test/cls_statelog/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(ceph_test_cls_statelog test_cls_statelog.cc ) -set_target_properties(ceph_test_cls_statelog PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_statelog librados cls_statelog_client diff --git a/src/test/cls_version/CMakeLists.txt b/src/test/cls_version/CMakeLists.txt index 24fabc933e0..7334ce43624 100644 --- a/src/test/cls_version/CMakeLists.txt +++ b/src/test/cls_version/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(ceph_test_cls_version test_cls_version.cc ) -set_target_properties(ceph_test_cls_version PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cls_version librados cls_version_client diff --git a/src/test/erasure-code/CMakeLists.txt b/src/test/erasure-code/CMakeLists.txt index e49e7f82ab6..2cd7cf2c983 100644 --- a/src/test/erasure-code/CMakeLists.txt +++ b/src/test/erasure-code/CMakeLists.txt @@ -165,7 +165,6 @@ target_link_libraries(unittest_erasure_code_example erasure_code ${UNITTEST_LIBS} ) -set_target_properties(unittest_erasure_code_example PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/src/erasure-code/jerasure/jerasure/include) include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/src/erasure-code//jerasure/gf-complete/include) diff --git a/src/test/filestore/CMakeLists.txt b/src/test/filestore/CMakeLists.txt index 82a47f8c48b..ae29faacf86 100644 --- a/src/test/filestore/CMakeLists.txt +++ b/src/test/filestore/CMakeLists.txt @@ -1,8 +1,6 @@ #ceph_test_filestore add_executable(ceph_test_filestore TestFileStore.cc) -set_target_properties(ceph_test_filestore PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_filestore os global ${UNITTEST_LIBS}) diff --git a/src/test/journal/CMakeLists.txt b/src/test/journal/CMakeLists.txt index 1afa97c75b2..213630e941c 100644 --- a/src/test/journal/CMakeLists.txt +++ b/src/test/journal/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(journal_test_mock STATIC mock/MockJournaler.cc) -set_target_properties(journal_test_mock PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) +target_link_libraries(journal_test_mock + PUBLIC GMock::GMock) # unittest_journal set(unittest_journal_srcs diff --git a/src/test/libcephfs/CMakeLists.txt b/src/test/libcephfs/CMakeLists.txt index 022f48191be..41c2716de3f 100644 --- a/src/test/libcephfs/CMakeLists.txt +++ b/src/test/libcephfs/CMakeLists.txt @@ -10,8 +10,6 @@ if(${WITH_CEPHFS}) main.cc deleg.cc ) - set_target_properties(ceph_test_libcephfs PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_libcephfs ceph-common cephfs @@ -26,8 +24,6 @@ if(${WITH_CEPHFS}) test.cc access.cc ) - set_target_properties(ceph_test_libcephfs_access PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_libcephfs_access ceph-common cephfs diff --git a/src/test/librados/CMakeLists.txt b/src/test/librados/CMakeLists.txt index 1c909ee1ce0..33ac156f9d1 100644 --- a/src/test/librados/CMakeLists.txt +++ b/src/test/librados/CMakeLists.txt @@ -1,160 +1,103 @@ # radostest add_library(libradostest_obj OBJECT test.cc) +target_include_directories(libradostest_obj PRIVATE + $<TARGET_PROPERTY:GTest::GTest,INTERFACE_INCLUDE_DIRECTORIES>) set(libradostest_srcs test_common.cc TestCase.cc) add_library(radostest STATIC ${libradostest_srcs} $<TARGET_OBJECTS:libradostest_obj>) -target_link_libraries(radostest librados ceph-common json_spirit ${EXTRALIBS}) -set_target_properties(radostest PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) +target_link_libraries(radostest + GTest::GTest + librados + ceph-common + json_spirit + ${EXTRALIBS}) + -# ceph_test_rados_api_cmd add_executable(ceph_test_rados_api_cmd - cmd.cc - ) -set_target_properties(ceph_test_rados_api_cmd PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + cmd.cc) target_link_libraries(ceph_test_rados_api_cmd librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_io add_executable(ceph_test_rados_api_io - io.cc - ) -set_target_properties(ceph_test_rados_api_io PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + io.cc) target_link_libraries(ceph_test_rados_api_io librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_c_write_operations add_executable(ceph_test_rados_api_c_write_operations - c_write_operations.cc - ) -set_target_properties(ceph_test_rados_api_c_write_operations PROPERTIES - COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) + c_write_operations.cc) target_link_libraries(ceph_test_rados_api_c_write_operations librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_c_read_operations add_executable(ceph_test_rados_api_c_read_operations - c_read_operations.cc - ) -set_target_properties(ceph_test_rados_api_c_read_operations PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + c_read_operations.cc) target_link_libraries(ceph_test_rados_api_c_read_operations librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_aio add_executable(ceph_test_rados_api_aio - aio.cc - ) -set_target_properties(ceph_test_rados_api_aio PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + aio.cc) target_link_libraries(ceph_test_rados_api_aio librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_asio add_executable(ceph_test_rados_api_asio asio.cc) -set_target_properties(ceph_test_rados_api_asio PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_rados_api_asio global librados ${UNITTEST_LIBS}) if(WITH_BOOST_CONTEXT) target_link_libraries(ceph_test_rados_api_asio Boost::coroutine Boost::context) endif() -# ceph_test_rados_api_list add_executable(ceph_test_rados_api_list list.cc - $<TARGET_OBJECTS:unit-main> - ) -set_target_properties(ceph_test_rados_api_list PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + $<TARGET_OBJECTS:unit-main>) target_link_libraries(ceph_test_rados_api_list librados global ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_pool add_executable(ceph_test_rados_api_pool - pool.cc - ) -set_target_properties(ceph_test_rados_api_pool PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS} - ) + pool.cc) target_link_libraries(ceph_test_rados_api_pool librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_stat add_executable(ceph_test_rados_api_stat - stat.cc - ) -set_target_properties(ceph_test_rados_api_stat PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + stat.cc) target_link_libraries(ceph_test_rados_api_stat librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_watch_notify add_executable(ceph_test_rados_api_watch_notify - watch_notify.cc - ) -set_target_properties(ceph_test_rados_api_watch_notify PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + watch_notify.cc) target_link_libraries(ceph_test_rados_api_watch_notify librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_cls add_executable(ceph_test_rados_api_cls - cls.cc - ) -set_target_properties(ceph_test_rados_api_cls PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + cls.cc) target_link_libraries(ceph_test_rados_api_cls librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_misc add_executable(ceph_test_rados_api_misc misc.cc - $<TARGET_OBJECTS:unit-main> - ) -set_target_properties(ceph_test_rados_api_misc PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + $<TARGET_OBJECTS:unit-main>) target_link_libraries(ceph_test_rados_api_misc librados global ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_lock add_executable(ceph_test_rados_api_lock - lock.cc - ) -set_target_properties(ceph_test_rados_api_lock PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + lock.cc) target_link_libraries(ceph_test_rados_api_lock librados ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_service add_executable(ceph_test_rados_api_service - service.cc - ) -set_target_properties(ceph_test_rados_api_service PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + service.cc) target_link_libraries(ceph_test_rados_api_service librados global ${UNITTEST_LIBS} radostest) -# ceph_test_rados_api_tier add_executable(ceph_test_rados_api_tier tier.cc - $<TARGET_OBJECTS:unit-main> - ) -set_target_properties(ceph_test_rados_api_tier PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + $<TARGET_OBJECTS:unit-main>) target_link_libraries(ceph_test_rados_api_tier librados global ${UNITTEST_LIBS} Boost::system radostest) -# ceph_test_rados_api_snapshots add_executable(ceph_test_rados_api_snapshots - snapshots.cc - ) -set_target_properties(ceph_test_rados_api_snapshots PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + snapshots.cc) target_link_libraries(ceph_test_rados_api_snapshots librados ${UNITTEST_LIBS} radostest) diff --git a/src/test/libradosstriper/CMakeLists.txt b/src/test/libradosstriper/CMakeLists.txt index b328acb31bd..79dd6c53714 100644 --- a/src/test/libradosstriper/CMakeLists.txt +++ b/src/test/libradosstriper/CMakeLists.txt @@ -1,15 +1,13 @@ add_library(rados_striper_test STATIC TestCase.cc) -target_link_libraries(rados_striper_test radostest) -set_target_properties(rados_striper_test PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) +target_link_libraries(rados_striper_test + radostest + GTest::GTest) add_executable(ceph_test_rados_striper_api_striping striping.cc ) target_link_libraries(ceph_test_rados_striper_api_striping librados radosstriper ${UNITTEST_LIBS} rados_striper_test) -set_target_properties(ceph_test_rados_striper_api_striping PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) install(TARGETS ceph_test_rados_striper_api_striping DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -17,8 +15,6 @@ add_executable(ceph_test_rados_striper_api_io io.cc) target_link_libraries(ceph_test_rados_striper_api_io librados radosstriper ${UNITTEST_LIBS} rados_striper_test) -set_target_properties(ceph_test_rados_striper_api_io PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) install(TARGETS ceph_test_rados_striper_api_io DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -26,7 +22,5 @@ add_executable(ceph_test_rados_striper_api_aio aio.cc) target_link_libraries(ceph_test_rados_striper_api_aio librados radosstriper ${UNITTEST_LIBS} rados_striper_test) -set_target_properties(ceph_test_rados_striper_api_aio PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) install(TARGETS ceph_test_rados_striper_api_aio DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/test/librbd/CMakeLists.txt b/src/test/librbd/CMakeLists.txt index 2c685849259..4c58e997458 100644 --- a/src/test/librbd/CMakeLists.txt +++ b/src/test/librbd/CMakeLists.txt @@ -15,15 +15,17 @@ set(librbd_test journal/test_Entries.cc journal/test_Replay.cc) add_library(rbd_test STATIC ${librbd_test}) -target_link_libraries(rbd_test PRIVATE Boost::thread) -set_target_properties(rbd_test PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) +target_link_libraries(rbd_test PRIVATE + Boost::thread + GMock::GMock + GTest::GTest) set(librbd_test_mock_srcs mock/MockImageCtx.cc mock/MockJournal.cc) add_library(rbd_test_mock STATIC ${librbd_test_mock_srcs}) -set_target_properties(rbd_test_mock PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) +target_link_libraries(rbd_test_mock PUBLIC + GMock::GMock) # unittest_librbd # doesn't use add_ceph_test because it is called by run-rbd-unit-tests.sh @@ -89,8 +91,6 @@ add_executable(unittest_librbd ${unittest_librbd_srcs} $<TARGET_OBJECTS:common_texttable_obj>) target_compile_definitions(unittest_librbd PUBLIC "-DTEST_LIBRBD_INTERNALS") -set_target_properties(unittest_librbd PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(unittest_librbd cls_rbd cls_rbd_client @@ -127,8 +127,6 @@ target_link_libraries(ceph_test_librbd ${UNITTEST_LIBS} radostest) target_compile_definitions(ceph_test_librbd PUBLIC "-DTEST_LIBRBD_INTERNALS") -set_target_properties(ceph_test_librbd PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) add_executable(ceph_test_librbd_api test_support.cc @@ -140,8 +138,6 @@ target_link_libraries(ceph_test_librbd_api librbd librados ${UNITTEST_LIBS}) -set_target_properties(ceph_test_librbd_api PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) add_executable(ceph_test_librbd_fsx fsx.cc diff --git a/src/test/mon/CMakeLists.txt b/src/test/mon/CMakeLists.txt index 16374308e4f..53b57dfe4d2 100644 --- a/src/test/mon/CMakeLists.txt +++ b/src/test/mon/CMakeLists.txt @@ -17,8 +17,6 @@ add_executable(ceph_test_mon_msg test-mon-msg.cc ) target_link_libraries(ceph_test_mon_msg os osdc global ${UNITTEST_LIBS}) -set_target_properties(ceph_test_mon_msg PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) # unittest_mon_moncap add_executable(unittest_mon_moncap diff --git a/src/test/msgr/CMakeLists.txt b/src/test/msgr/CMakeLists.txt index 6222087c464..1f3e85d99da 100644 --- a/src/test/msgr/CMakeLists.txt +++ b/src/test/msgr/CMakeLists.txt @@ -3,16 +3,12 @@ add_executable(ceph_test_async_driver test_async_driver.cc $<TARGET_OBJECTS:unit-main> ) -set_target_properties(ceph_test_async_driver PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_async_driver os global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) # ceph_test_msgr add_executable(ceph_test_msgr test_msgr.cc ) -set_target_properties(ceph_test_msgr PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_msgr os global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) # ceph_test_async_networkstack @@ -20,20 +16,14 @@ add_executable(ceph_test_async_networkstack test_async_networkstack.cc $<TARGET_OBJECTS:unit-main> ) -set_target_properties(ceph_test_async_networkstack PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_async_networkstack global ${CRYPTO_LIBS} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) #ceph_perf_msgr_server add_executable(ceph_perf_msgr_server perf_msgr_server.cc) -set_target_properties(ceph_perf_msgr_server PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_perf_msgr_server os global ${UNITTEST_LIBS}) #ceph_perf_msgr_client add_executable(ceph_perf_msgr_client perf_msgr_client.cc) -set_target_properties(ceph_perf_msgr_client PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_perf_msgr_client os global ${UNITTEST_LIBS}) # test_userspace_event @@ -41,9 +31,7 @@ if(HAVE_DPDK) add_executable(ceph_test_userspace_event test_userspace_event.cc $<TARGET_OBJECTS:unit-main>) -set_target_properties(ceph_test_userspace_event PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) -target_link_libraries(ceph_test_userspace_event + target_link_libraries(ceph_test_userspace_event global ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) diff --git a/src/test/objectstore/CMakeLists.txt b/src/test/objectstore/CMakeLists.txt index 06f90727474..506f3f6e5e3 100644 --- a/src/test/objectstore/CMakeLists.txt +++ b/src/test/objectstore/CMakeLists.txt @@ -1,23 +1,16 @@ -#ceph_perf_objectstore add_executable(ceph_perf_objectstore - ObjectStoreTransactionBenchmark.cc - ) -set_target_properties(ceph_perf_objectstore PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + ObjectStoreTransactionBenchmark.cc) target_link_libraries(ceph_perf_objectstore os osdc global ${UNITTEST_LIBS}) install(TARGETS ceph_perf_objectstore DESTINATION bin) -#ceph_test_objectstore add_library(store_test_fixture OBJECT store_test_fixture.cc) -set_target_properties(store_test_fixture PROPERTIES - COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) +target_include_directories(store_test_fixture PRIVATE + $<TARGET_PROPERTY:GTest::GTest,INTERFACE_INCLUDE_DIRECTORIES>) add_executable(ceph_test_objectstore store_test.cc $<TARGET_OBJECTS:store_test_fixture>) -set_target_properties(ceph_test_objectstore PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_objectstore os ceph-common @@ -30,12 +23,8 @@ target_link_libraries(ceph_test_objectstore install(TARGETS ceph_test_objectstore DESTINATION ${CMAKE_INSTALL_BINDIR}) -#ceph_test_keyvaluedb add_executable(ceph_test_keyvaluedb - test_kv.cc - ) -set_target_properties(ceph_test_keyvaluedb PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + test_kv.cc) target_link_libraries(ceph_test_keyvaluedb os ceph-common @@ -108,7 +97,6 @@ if(WITH_BLUESTORE) Allocator_bench.cc $<TARGET_OBJECTS:unit-main> ) - set_target_properties(unittest_alloc_bench PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) target_link_libraries(unittest_alloc_bench ${UNITTEST_LIBS} os global) add_executable(unittest_fastbmap_allocator @@ -118,10 +106,6 @@ if(WITH_BLUESTORE) add_ceph_unittest(unittest_fastbmap_allocator) target_link_libraries(unittest_fastbmap_allocator os global) - set_target_properties(unittest_fastbmap_allocator PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) - - # unittest_bluefs add_executable(unittest_bluefs test_bluefs.cc ) diff --git a/src/test/rbd_mirror/CMakeLists.txt b/src/test/rbd_mirror/CMakeLists.txt index a86dca523ef..b9ecbb1beaf 100644 --- a/src/test/rbd_mirror/CMakeLists.txt +++ b/src/test/rbd_mirror/CMakeLists.txt @@ -11,8 +11,8 @@ set(rbd_mirror_test_srcs image_map/test_Policy.cc ) add_library(rbd_mirror_test STATIC ${rbd_mirror_test_srcs}) -set_target_properties(rbd_mirror_test PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) +target_link_libraries(rbd_mirror_test + GTest::GTest) add_executable(unittest_rbd_mirror test_main.cc @@ -40,8 +40,7 @@ add_executable(unittest_rbd_mirror pool_watcher/test_mock_RefreshImagesRequest.cc ) add_ceph_unittest(unittest_rbd_mirror) -set_target_properties(unittest_rbd_mirror PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + add_dependencies(unittest_rbd_mirror cls_journal cls_lock @@ -69,8 +68,7 @@ target_link_libraries(unittest_rbd_mirror add_executable(ceph_test_rbd_mirror test_main.cc ) -set_target_properties(ceph_test_rbd_mirror PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + target_link_libraries(ceph_test_rbd_mirror rbd_mirror_test rbd_mirror_internal @@ -88,8 +86,6 @@ target_link_libraries(ceph_test_rbd_mirror add_executable(ceph_test_rbd_mirror_random_write random_write.cc) -set_target_properties(ceph_test_rbd_mirror_random_write PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_rbd_mirror_random_write librbd librados global) diff --git a/src/test/rgw/CMakeLists.txt b/src/test/rgw/CMakeLists.txt index a51dade9674..b050b4c7b83 100644 --- a/src/test/rgw/CMakeLists.txt +++ b/src/test/rgw/CMakeLists.txt @@ -47,12 +47,8 @@ target_link_libraries(ceph_test_rgw_manifest ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} - ${CRYPTO_LIBS} - ) -set_target_properties(ceph_test_rgw_manifest PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) + ${CRYPTO_LIBS}) -# ceph_test_rgw_obj set(test_rgw_obj_srcs test_rgw_obj.cc) add_executable(ceph_test_rgw_obj ${test_rgw_obj_srcs} @@ -75,16 +71,12 @@ target_link_libraries(ceph_test_rgw_obj ${UNITTEST_LIBS} ${CRYPTO_LIBS} ) -set_target_properties(ceph_test_rgw_obj PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) -# ceph_test_rgw_crypto set(test_rgw_crypto_srcs test_rgw_crypto.cc) add_executable(unittest_rgw_crypto ${test_rgw_crypto_srcs} ) add_ceph_unittest(unittest_rgw_crypto) - target_link_libraries(unittest_rgw_crypto rgw_a cls_rgw_client @@ -102,9 +94,7 @@ target_link_libraries(unittest_rgw_crypto ${UNITTEST_LIBS} ${CRYPTO_LIBS} ) -set_target_properties(unittest_rgw_crypto PROPERTIES COMPILE_FLAGS$ {UNITTEST_CXX_FLAGS}) -# ceph_test_rgw_iam_policy add_executable(unittest_rgw_iam_policy test_rgw_iam_policy.cc) add_ceph_unittest(unittest_rgw_iam_policy) target_link_libraries(unittest_rgw_iam_policy @@ -124,8 +114,6 @@ target_link_libraries(unittest_rgw_iam_policy ${UNITTEST_LIBS} ${CRYPTO_LIBS} ) -set_target_properties(unittest_rgw_iam_policy PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) -# unitttest_rgw_string add_executable(unittest_rgw_string test_rgw_string.cc) add_ceph_unittest(unittest_rgw_string) |