Skip to content

Commit fe9fcf6

Browse files
committed
cmake: Fix googletest deprecated warnings by using target_compile_options()
Previously, we attempted to disable deprecated declarations warnings when building gtest by adding `-Wno-deprecated-declarations` to the COMPILE_OPTIONS property of the googletest directory. However, this approach failed to apply the option when actually building gtest. This change applies the compile option directly to the `gtest` target using target_compile_options() instead. Verified by forcing the condition to TRUE and confirming the option is included when building `gtest-all.cc` through `cmake --build ~/dev/ceph/build --target gtest --verbose`. Signed-off-by: Kefu Chai <[email protected]>
1 parent 7a4d7c5 commit fe9fcf6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,8 @@ if(WITH_TESTS)
777777
$<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
778778
if(NOT COMPILER_IGNORES_DEPRECATED_DECL_IN_SYSTEM_HEADERS)
779779
# See https://github.com/llvm/llvm-project/issues/76515
780-
set_property(DIRECTORY googletest
781-
APPEND
782-
PROPERTY COMPILE_OPTIONS "-Wno-deprecated-declarations")
780+
target_compile_options(gtest
781+
PRIVATE "-Wno-deprecated-declarations")
783782
endif()
784783
add_library(GTest::GTest ALIAS gtest)
785784
add_library(GTest::Main ALIAS gtest_main)

0 commit comments

Comments
 (0)