cleanup(cmake): prefer target over global options (#12916)
In CMake >= 3.0 it is more idiomatic to set per-target compiler options than global compiler settings. I have kept these options and defines as `PRIVATE` so they won't be exported with the target.
Closes #12916
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12916 from coryan:cleanup-cmake-avoid-global-compile-settings 3d586dc0e889ea195433f84a31d16409fb84c5d6
PiperOrigin-RevId: 536517165
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index 9f87eaf..422754a 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -1,6 +1,7 @@
# CMake definitions for libprotobuf (the "full" C++ protobuf runtime).
include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
+include(${protobuf_SOURCE_DIR}/cmake/protobuf-configure-target.cmake)
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
${libprotobuf_srcs}
@@ -27,7 +28,7 @@
endif()
target_include_directories(libprotobuf PUBLIC ${protobuf_SOURCE_DIR}/src)
target_link_libraries(libprotobuf PUBLIC ${protobuf_ABSL_USED_TARGETS})
-target_compile_features(libprotobuf PUBLIC cxx_std_14)
+protobuf_configure_target(libprotobuf)
if(protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotobuf
PUBLIC PROTOBUF_USE_DLLS