From f8f244da99c0d1635f7680eac1932ef9b72e1977 Mon Sep 17 00:00:00 2001 From: David Chamberlin Date: Thu, 7 Dec 2023 12:50:11 +0000 Subject: [PATCH] Minimal changes to expose DLL entry points on Windows --- CMakeLists.txt | 4960 ++++++++++++++++- include/grpcpp/support/proto_buffer_reader.h | 2 +- .../windows/grpc_polled_fd_windows.cc | 1 + templates/CMakeLists.txt.template | 109 +- 4 files changed, 5012 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4455b799b10..da33ba6b48c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") project(${PACKAGE_NAME} LANGUAGES C CXX) +if(BUILD_SHARED_LIBS AND MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + set(gRPC_INSTALL_BINDIR "bin" CACHE STRING "Installation directory for executables") set(gRPC_INSTALL_LIBDIR "lib" CACHE STRING "Installation directory for libraries") set(gRPC_INSTALL_INCLUDEDIR "include" CACHE STRING "Installation directory for headers") @@ -267,6 +271,8 @@ if(MSVC) set(_gRPC_C_CXX_FLAGS "${_gRPC_C_CXX_FLAGS} /wd4503") # Tell MSVC to build grpc using utf-8 set(_gRPC_C_CXX_FLAGS "${_gRPC_C_CXX_FLAGS} /utf-8") + # Inconsistent object sizes can cause stack corruption and should be treated as an error + set(_gRPC_C_CXX_FLAGS "${_gRPC_C_CXX_FLAGS} /we4789") endif() if (MINGW) add_definitions(-D_WIN32_WINNT=0x600) @@ -427,12 +433,12 @@ if(WIN32) set(_gRPC_ALLTARGETS_LIBRARIES ${_gRPC_ALLTARGETS_LIBRARIES} ws2_32 crypt32) set(_gRPC_STATIC_WIN32 STATIC) endif() - + if(BUILD_SHARED_LIBS AND WIN32) # Currently for shared lib on Windows (i.e. a DLL) certain bits of source code # are generated from protobuf definitions by upbc. This source code does not include -# annotations needed to export these functions from gprc.lib so we have to +# annotations needed to export these functions from grpc.lib so we have to # re-include a small subset of these. # # This is not an ideal situation because these functions will be unavailable @@ -445,9 +451,18 @@ set(gRPC_UPB_GEN_DUPL_SRC src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c src/core/ext/upb-gen/src/proto/grpc/gcp/transport_security_common.upb_minitable.c ) + set(gRPC_ADDITIONAL_DLL_SRC src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc + src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc + src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +) + +set(gRPC_ADDITIONAL_DLL_CXX_SRC + src/cpp/common/tls_certificate_provider.cc + src/cpp/common/tls_certificate_verifier.cc + src/cpp/common/tls_credentials_options.cc ) endif() # BUILD_SHARED_LIBS AND WIN32 @@ -1649,9 +1664,11 @@ if(WIN32 AND MSVC) set_target_properties(gpr PROPERTIES COMPILE_PDB_NAME "gpr" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) - set_target_properties(gpr PROPERTIES DEFINE_SYMBOL "GPR_DLL_EXPORTS") if(BUILD_SHARED_LIBS) - target_compile_definitions(gpr INTERFACE GPR_DLL_IMPORTS) + target_compile_definitions(gpr + PRIVATE + "GPR_DLL_EXPORTS" + ) endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gpr.pdb @@ -2557,9 +2574,12 @@ if(WIN32 AND MSVC) set_target_properties(grpc PROPERTIES COMPILE_PDB_NAME "grpc" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) - set_target_properties(grpc PROPERTIES DEFINE_SYMBOL "GRPC_DLL_EXPORTS") if(BUILD_SHARED_LIBS) - target_compile_definitions(grpc INTERFACE GRPC_DLL_IMPORTS) + target_compile_definitions(grpc + PRIVATE + "GRPC_DLL_EXPORTS" + "GPR_DLL_IMPORTS" + ) endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc.pdb @@ -2730,6 +2750,13 @@ if(WIN32 AND MSVC) set_target_properties(grpc_test_util PROPERTIES COMPILE_PDB_NAME "grpc_test_util" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_test_util + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -2789,6 +2816,13 @@ if(WIN32 AND MSVC) set_target_properties(grpc_test_util_unsecure PROPERTIES COMPILE_PDB_NAME "grpc_test_util_unsecure" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_test_util_unsecure + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util_unsecure.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -3238,9 +3272,12 @@ if(WIN32 AND MSVC) set_target_properties(grpc_unsecure PROPERTIES COMPILE_PDB_NAME "grpc_unsecure" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) - set_target_properties(grpc_unsecure PROPERTIES DEFINE_SYMBOL "GRPC_DLL_EXPORTS") if(BUILD_SHARED_LIBS) - target_compile_definitions(grpc_unsecure INTERFACE GRPC_DLL_IMPORTS) + target_compile_definitions(grpc_unsecure + PRIVATE + "GRPC_DLL_EXPORTS" + "GPR_DLL_IMPORTS" + ) endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_unsecure.pdb @@ -3824,7 +3861,7 @@ if(gRPC_BUILD_TESTS) if(gRPC_BUILD_CODEGEN) -add_library(benchmark_helpers +add_library(benchmark_helpers ${_gRPC_STATIC_WIN32} ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.h @@ -3866,6 +3903,14 @@ if(WIN32 AND MSVC) set_target_properties(benchmark_helpers PROPERTIES COMPILE_PDB_NAME "benchmark_helpers" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(benchmark_helpers + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/benchmark_helpers.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -3980,9 +4025,13 @@ if(WIN32 AND MSVC) set_target_properties(grpc++ PROPERTIES COMPILE_PDB_NAME "grpc++" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) - set_target_properties(grpc++ PROPERTIES DEFINE_SYMBOL "GRPCXX_DLL_EXPORTS") if(BUILD_SHARED_LIBS) - target_compile_definitions(grpc++ INTERFACE GRPCXX_DLL_IMPORTS) + target_compile_definitions(grpc++ + PRIVATE + "GRPCXX_DLL_EXPORTS" + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++.pdb @@ -4254,6 +4303,14 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_alts PROPERTIES COMPILE_PDB_NAME "grpc++_alts" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_alts + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_alts.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4318,6 +4375,14 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_error_details PROPERTIES COMPILE_PDB_NAME "grpc++_error_details" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_error_details + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_error_details.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4368,7 +4433,7 @@ endif() if(gRPC_BUILD_CODEGEN) -add_library(grpc++_reflection +add_library(grpc++_reflection ${_gRPC_STATIC_WIN32} ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1/reflection.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1/reflection.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1/reflection.pb.h @@ -4392,6 +4457,14 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_reflection PROPERTIES COMPILE_PDB_NAME "grpc++_reflection" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_reflection + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_reflection.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4460,6 +4533,14 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_test PROPERTIES COMPILE_PDB_NAME "grpc++_test" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4526,6 +4607,12 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_test_config PROPERTIES COMPILE_PDB_NAME "grpc++_test_config" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_test_config + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_config.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4593,6 +4680,14 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_test_util PROPERTIES COMPILE_PDB_NAME "grpc++_test_util" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc++_test_util + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_util.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -4662,6 +4757,7 @@ add_library(grpc++_unsecure src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc ${gRPC_UPB_GEN_DUPL_SRC} + ${gRPC_ADDITIONAL_DLL_CXX_SRC} ) target_compile_features(grpc++_unsecure PUBLIC cxx_std_14) @@ -4675,9 +4771,13 @@ if(WIN32 AND MSVC) set_target_properties(grpc++_unsecure PROPERTIES COMPILE_PDB_NAME "grpc++_unsecure" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) - set_target_properties(grpc++_unsecure PROPERTIES DEFINE_SYMBOL "GRPCXX_DLL_EXPORTS") if(BUILD_SHARED_LIBS) - target_compile_definitions(grpc++_unsecure INTERFACE GRPCXX_DLL_IMPORTS) + target_compile_definitions(grpc++_unsecure + PRIVATE + "GRPCXX_DLL_EXPORTS" + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_unsecure.pdb @@ -5225,6 +5325,12 @@ if(WIN32 AND MSVC) set_target_properties(grpc_authorization_provider PROPERTIES COMPILE_PDB_NAME "grpc_authorization_provider" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_authorization_provider + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_authorization_provider.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -5435,7 +5541,7 @@ endif() # See https://github.com/grpc/grpc/issues/19473 if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE) -add_library(grpcpp_channelz +add_library(grpcpp_channelz ${_gRPC_STATIC_WIN32} ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h @@ -5455,6 +5561,14 @@ if(WIN32 AND MSVC) set_target_properties(grpcpp_channelz PROPERTIES COMPILE_PDB_NAME "grpcpp_channelz" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpcpp_channelz + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() if(gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpcpp_channelz.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL @@ -5523,6 +5637,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fd_conservation_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(fd_conservation_posix_test PUBLIC cxx_std_14) target_include_directories(fd_conservation_posix_test PRIVATE @@ -5551,6 +5674,15 @@ if(gRPC_BUILD_TESTS) add_executable(multiple_server_queues_test test/core/end2end/multiple_server_queues_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(multiple_server_queues_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(multiple_server_queues_test PUBLIC cxx_std_14) target_include_directories(multiple_server_queues_test PRIVATE @@ -5579,6 +5711,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX OR _gRPC_PLATFORM_WINDOWS) add_executable(pollset_windows_starvation_test test/core/iomgr/pollset_windows_starvation_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(pollset_windows_starvation_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(pollset_windows_starvation_test PUBLIC cxx_std_14) target_include_directories(pollset_windows_starvation_test PRIVATE @@ -5609,6 +5750,14 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc test/core/client_channel/lb_policy/static_stride_scheduler_benchmark.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(static_stride_scheduler_benchmark + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(static_stride_scheduler_benchmark PUBLIC cxx_std_14) target_include_directories(static_stride_scheduler_benchmark PRIVATE @@ -5650,6 +5799,15 @@ add_executable(test_core_iomgr_timer_list_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_iomgr_timer_list_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_iomgr_timer_list_test PUBLIC cxx_std_14) target_include_directories(test_core_iomgr_timer_list_test PRIVATE @@ -5680,6 +5838,14 @@ add_executable(activity_test src/core/lib/promise/trace.cc test/core/promise/activity_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(activity_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(activity_test PUBLIC cxx_std_14) target_include_directories(activity_test PRIVATE @@ -5717,6 +5883,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(address_sorting_test test/cpp/naming/address_sorting_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(address_sorting_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(address_sorting_test PUBLIC cxx_std_14) target_include_directories(address_sorting_test PRIVATE @@ -5768,6 +5944,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/util/string_ref_helper.cc test/cpp/util/subprocess.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(address_sorting_test_unsecure + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(address_sorting_test_unsecure PUBLIC cxx_std_14) target_include_directories(address_sorting_test_unsecure PRIVATE @@ -5822,6 +6008,16 @@ add_executable(admin_services_end2end_test src/cpp/server/csds/csds.cc test/cpp/end2end/admin_services_end2end_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(admin_services_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(admin_services_end2end_test PUBLIC cxx_std_14) target_include_directories(admin_services_end2end_test PRIVATE @@ -5868,6 +6064,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/tracer_util.cc test/cpp/common/alarm_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alarm_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(alarm_test PUBLIC cxx_std_14) target_include_directories(alarm_test PRIVATE @@ -5905,6 +6111,14 @@ add_executable(all_ok_test src/core/lib/promise/trace.cc test/core/promise/all_ok_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(all_ok_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(all_ok_test PUBLIC cxx_std_14) target_include_directories(all_ok_test PRIVATE @@ -5941,6 +6155,15 @@ if(gRPC_BUILD_TESTS) add_executable(alloc_test test/core/gpr/alloc_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alloc_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alloc_test PUBLIC cxx_std_14) target_include_directories(alloc_test PRIVATE @@ -5974,6 +6197,15 @@ if(gRPC_BUILD_TESTS) add_executable(alpn_test test/core/transport/chttp2/alpn_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alpn_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alpn_test PUBLIC cxx_std_14) target_include_directories(alpn_test PRIVATE @@ -6019,6 +6251,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc test/core/util/fake_udp_and_tcp_server.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_concurrent_connectivity_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(alts_concurrent_connectivity_test PUBLIC cxx_std_14) target_include_directories(alts_concurrent_connectivity_test PRIVATE @@ -6055,6 +6297,15 @@ add_executable(alts_counter_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/frame_protector/alts_counter_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_counter_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_counter_test PUBLIC cxx_std_14) target_include_directories(alts_counter_test PRIVATE @@ -6089,6 +6340,15 @@ add_executable(alts_crypt_test test/core/tsi/alts/crypt/aes_gcm_test.cc test/core/tsi/alts/crypt/gsec_test_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_crypt_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_crypt_test PUBLIC cxx_std_14) target_include_directories(alts_crypt_test PRIVATE @@ -6123,6 +6383,15 @@ add_executable(alts_crypter_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/frame_protector/alts_crypter_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_crypter_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_crypter_test PUBLIC cxx_std_14) target_include_directories(alts_crypter_test PRIVATE @@ -6158,6 +6427,15 @@ add_executable(alts_frame_protector_test test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc test/core/tsi/transport_security_test_lib.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_frame_protector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_frame_protector_test PUBLIC cxx_std_14) target_include_directories(alts_frame_protector_test PRIVATE @@ -6192,6 +6470,15 @@ add_executable(alts_grpc_record_protocol_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_grpc_record_protocol_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_grpc_record_protocol_test PUBLIC cxx_std_14) target_include_directories(alts_grpc_record_protocol_test PRIVATE @@ -6226,6 +6513,15 @@ add_executable(alts_handshaker_client_test test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_handshaker_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_handshaker_client_test PUBLIC cxx_std_14) target_include_directories(alts_handshaker_client_test PRIVATE @@ -6260,6 +6556,15 @@ add_executable(alts_iovec_record_protocol_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_iovec_record_protocol_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_iovec_record_protocol_test PUBLIC cxx_std_14) target_include_directories(alts_iovec_record_protocol_test PRIVATE @@ -6303,6 +6608,15 @@ add_executable(alts_security_connector_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_security_connector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_security_connector_test PUBLIC cxx_std_14) target_include_directories(alts_security_connector_test PRIVATE @@ -6337,6 +6651,15 @@ add_executable(alts_tsi_handshaker_test test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_tsi_handshaker_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_tsi_handshaker_test PUBLIC cxx_std_14) target_include_directories(alts_tsi_handshaker_test PRIVATE @@ -6371,6 +6694,15 @@ add_executable(alts_tsi_utils_test test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_tsi_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_tsi_utils_test PUBLIC cxx_std_14) target_include_directories(alts_tsi_utils_test PRIVATE @@ -6404,6 +6736,16 @@ if(gRPC_BUILD_TESTS) add_executable(alts_util_test test/cpp/common/alts_util_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_util_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_util_test PUBLIC cxx_std_14) target_include_directories(alts_util_test PRIVATE @@ -6439,6 +6781,15 @@ add_executable(alts_zero_copy_grpc_protector_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(alts_zero_copy_grpc_protector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(alts_zero_copy_grpc_protector_test PUBLIC cxx_std_14) target_include_directories(alts_zero_copy_grpc_protector_test PRIVATE @@ -6472,6 +6823,15 @@ if(gRPC_BUILD_TESTS) add_executable(arena_promise_test test/core/promise/arena_promise_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(arena_promise_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(arena_promise_test PUBLIC cxx_std_14) target_include_directories(arena_promise_test PRIVATE @@ -6505,6 +6865,15 @@ if(gRPC_BUILD_TESTS) add_executable(arena_test test/core/resource_quota/arena_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(arena_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(arena_test PUBLIC cxx_std_14) target_include_directories(arena_test PRIVATE @@ -6562,6 +6931,16 @@ add_executable(async_end2end_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/async_end2end_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(async_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(async_end2end_test PUBLIC cxx_std_14) target_include_directories(async_end2end_test PRIVATE @@ -6605,6 +6984,15 @@ add_executable(auth_context_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(auth_context_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(auth_context_test PUBLIC cxx_std_14) target_include_directories(auth_context_test PRIVATE @@ -6638,6 +7026,16 @@ if(gRPC_BUILD_TESTS) add_executable(auth_property_iterator_test test/cpp/common/auth_property_iterator_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(auth_property_iterator_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(auth_property_iterator_test PUBLIC cxx_std_14) target_include_directories(auth_property_iterator_test PRIVATE @@ -6681,6 +7079,15 @@ add_executable(authorization_matchers_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(authorization_matchers_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(authorization_matchers_test PUBLIC cxx_std_14) target_include_directories(authorization_matchers_test PRIVATE @@ -6715,6 +7122,16 @@ add_executable(authorization_policy_provider_test src/cpp/server/authorization_policy_provider.cc test/cpp/server/authorization_policy_provider_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(authorization_policy_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(authorization_policy_provider_test PUBLIC cxx_std_14) target_include_directories(authorization_policy_provider_test PRIVATE @@ -6750,6 +7167,14 @@ if(gRPC_BUILD_TESTS) add_executable(avl_test test/core/avl/avl_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(avl_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(avl_test PUBLIC cxx_std_14) target_include_directories(avl_test PRIVATE @@ -6794,6 +7219,15 @@ add_executable(aws_request_signer_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(aws_request_signer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(aws_request_signer_test PUBLIC cxx_std_14) target_include_directories(aws_request_signer_test PRIVATE @@ -6827,6 +7261,15 @@ if(gRPC_BUILD_TESTS) add_executable(b64_test test/core/slice/b64_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(b64_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(b64_test PUBLIC cxx_std_14) target_include_directories(b64_test PRIVATE @@ -6874,9 +7317,19 @@ add_executable(backend_metrics_lb_policy_test test/cpp/interop/backend_metrics_lb_policy.cc test/cpp/interop/backend_metrics_lb_policy_test.cc ) -target_compile_features(backend_metrics_lb_policy_test PUBLIC cxx_std_14) -target_include_directories(backend_metrics_lb_policy_test - PRIVATE +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(backend_metrics_lb_policy_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(backend_metrics_lb_policy_test PUBLIC cxx_std_14) +target_include_directories(backend_metrics_lb_policy_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} @@ -6909,6 +7362,15 @@ if(gRPC_BUILD_TESTS) add_executable(backoff_test test/core/backoff/backoff_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(backoff_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(backoff_test PUBLIC cxx_std_14) target_include_directories(backoff_test PRIVATE @@ -6951,6 +7413,15 @@ add_executable(bad_ping_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bad_ping_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(bad_ping_test PUBLIC cxx_std_14) target_include_directories(bad_ping_test PRIVATE @@ -6987,6 +7458,15 @@ add_executable(bad_server_response_test test/core/end2end/bad_server_response_test.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bad_server_response_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(bad_server_response_test PUBLIC cxx_std_14) target_include_directories(bad_server_response_test PRIVATE @@ -7034,6 +7514,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bad_ssl_alpn_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(bad_ssl_alpn_test PUBLIC cxx_std_14) target_include_directories(bad_ssl_alpn_test PRIVATE @@ -7082,6 +7571,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bad_ssl_cert_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(bad_ssl_cert_test PUBLIC cxx_std_14) target_include_directories(bad_ssl_cert_test PRIVATE @@ -7118,6 +7616,15 @@ add_executable(bad_streaming_id_bad_client_test test/core/bad_client/tests/bad_streaming_id.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bad_streaming_id_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(bad_streaming_id_bad_client_test PUBLIC cxx_std_14) target_include_directories(bad_streaming_id_bad_client_test PRIVATE @@ -7153,6 +7660,15 @@ add_executable(badreq_bad_client_test test/core/bad_client/tests/badreq.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(badreq_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(badreq_bad_client_test PUBLIC cxx_std_14) target_include_directories(badreq_bad_client_test PRIVATE @@ -7186,6 +7702,15 @@ if(gRPC_BUILD_TESTS) add_executable(basic_work_queue_test test/core/event_engine/work_queue/basic_work_queue_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(basic_work_queue_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(basic_work_queue_test PUBLIC cxx_std_14) target_include_directories(basic_work_queue_test PRIVATE @@ -7220,6 +7745,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(bdp_estimator_test test/core/transport/bdp_estimator_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bdp_estimator_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(bdp_estimator_test PUBLIC cxx_std_14) target_include_directories(bdp_estimator_test PRIVATE @@ -7254,6 +7788,15 @@ if(gRPC_BUILD_TESTS) add_executable(bin_decoder_test test/core/transport/chttp2/bin_decoder_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bin_decoder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(bin_decoder_test PUBLIC cxx_std_14) target_include_directories(bin_decoder_test PRIVATE @@ -7287,6 +7830,15 @@ if(gRPC_BUILD_TESTS) add_executable(bin_encoder_test test/core/transport/chttp2/bin_encoder_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(bin_encoder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(bin_encoder_test PUBLIC cxx_std_14) target_include_directories(bin_encoder_test PRIVATE @@ -7329,6 +7881,15 @@ add_executable(binary_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(binary_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(binary_metadata_test PUBLIC cxx_std_14) target_include_directories(binary_metadata_test PRIVATE @@ -7364,6 +7925,15 @@ if(gRPC_BUILD_TESTS) add_executable(binder_resolver_test test/core/client_channel/resolvers/binder_resolver_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(binder_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(binder_resolver_test PUBLIC cxx_std_14) target_include_directories(binder_resolver_test PRIVATE @@ -7415,6 +7985,16 @@ add_executable(binder_server_test test/core/transport/binder/end2end/fake_binder.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(binder_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(binder_server_test PUBLIC cxx_std_14) target_include_directories(binder_server_test PRIVATE @@ -7511,6 +8091,15 @@ add_executable(binder_transport_test test/core/transport/binder/binder_transport_test.cc test/core/transport/binder/mock_objects.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(binder_transport_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(binder_transport_test PUBLIC cxx_std_14) target_include_directories(binder_transport_test PRIVATE @@ -7587,6 +8176,15 @@ add_executable(buffer_list_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(buffer_list_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(buffer_list_test PUBLIC cxx_std_14) target_include_directories(buffer_list_test PRIVATE @@ -7620,6 +8218,16 @@ if(gRPC_BUILD_TESTS) add_executable(byte_buffer_test test/cpp/util/byte_buffer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(byte_buffer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(byte_buffer_test PUBLIC cxx_std_14) target_include_directories(byte_buffer_test PRIVATE @@ -7653,6 +8261,15 @@ if(gRPC_BUILD_TESTS) add_executable(c_slice_buffer_test test/core/slice/c_slice_buffer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(c_slice_buffer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(c_slice_buffer_test PUBLIC cxx_std_14) target_include_directories(c_slice_buffer_test PRIVATE @@ -7695,6 +8312,15 @@ add_executable(call_creds_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(call_creds_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(call_creds_test PUBLIC cxx_std_14) target_include_directories(call_creds_test PRIVATE @@ -7730,6 +8356,15 @@ if(gRPC_BUILD_TESTS) add_executable(call_finalization_test test/core/channel/call_finalization_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(call_finalization_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(call_finalization_test PUBLIC cxx_std_14) target_include_directories(call_finalization_test PRIVATE @@ -7772,6 +8407,15 @@ add_executable(call_host_override_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(call_host_override_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(call_host_override_test PUBLIC cxx_std_14) target_include_directories(call_host_override_test PRIVATE @@ -7807,6 +8451,15 @@ if(gRPC_BUILD_TESTS) add_executable(call_tracer_test test/core/channel/call_tracer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(call_tracer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(call_tracer_test PUBLIC cxx_std_14) target_include_directories(call_tracer_test PRIVATE @@ -7849,6 +8502,15 @@ add_executable(cancel_after_accept_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_after_accept_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_after_accept_test PUBLIC cxx_std_14) target_include_directories(cancel_after_accept_test PRIVATE @@ -7893,6 +8555,15 @@ add_executable(cancel_after_client_done_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_after_client_done_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_after_client_done_test PUBLIC cxx_std_14) target_include_directories(cancel_after_client_done_test PRIVATE @@ -7937,6 +8608,15 @@ add_executable(cancel_after_invoke_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_after_invoke_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_after_invoke_test PUBLIC cxx_std_14) target_include_directories(cancel_after_invoke_test PRIVATE @@ -7981,6 +8661,15 @@ add_executable(cancel_after_round_trip_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_after_round_trip_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_after_round_trip_test PUBLIC cxx_std_14) target_include_directories(cancel_after_round_trip_test PRIVATE @@ -8019,6 +8708,16 @@ add_executable(cancel_ares_query_test test/core/util/socket_use_after_close_detector.cc test/cpp/naming/cancel_ares_query_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_ares_query_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_ares_query_test PUBLIC cxx_std_14) target_include_directories(cancel_ares_query_test PRIVATE @@ -8062,6 +8761,15 @@ add_executable(cancel_before_invoke_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_before_invoke_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_before_invoke_test PUBLIC cxx_std_14) target_include_directories(cancel_before_invoke_test PRIVATE @@ -8097,6 +8805,14 @@ if(gRPC_BUILD_TESTS) add_executable(cancel_callback_test test/core/promise/cancel_callback_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_callback_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_callback_test PUBLIC cxx_std_14) target_include_directories(cancel_callback_test PRIVATE @@ -8140,6 +8856,15 @@ add_executable(cancel_in_a_vacuum_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_in_a_vacuum_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_in_a_vacuum_test PUBLIC cxx_std_14) target_include_directories(cancel_in_a_vacuum_test PRIVATE @@ -8184,6 +8909,15 @@ add_executable(cancel_with_status_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cancel_with_status_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cancel_with_status_test PUBLIC cxx_std_14) target_include_directories(cancel_with_status_test PRIVATE @@ -8317,6 +9051,15 @@ add_executable(cel_authorization_engine_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cel_authorization_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cel_authorization_engine_test PUBLIC cxx_std_14) target_include_directories(cel_authorization_engine_test PRIVATE @@ -8350,6 +9093,15 @@ if(gRPC_BUILD_TESTS) add_executable(certificate_provider_registry_test test/core/security/certificate_provider_registry_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(certificate_provider_registry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(certificate_provider_registry_test PUBLIC cxx_std_14) target_include_directories(certificate_provider_registry_test PRIVATE @@ -8383,6 +9135,15 @@ if(gRPC_BUILD_TESTS) add_executable(certificate_provider_store_test test/core/xds/certificate_provider_store_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(certificate_provider_store_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(certificate_provider_store_test PUBLIC cxx_std_14) target_include_directories(certificate_provider_store_test PRIVATE @@ -8417,6 +9178,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(cf_engine_test test/core/event_engine/cf/cf_engine_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cf_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(cf_engine_test PUBLIC cxx_std_14) target_include_directories(cf_engine_test PRIVATE @@ -8457,6 +9227,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/tests/client_test.cc test/core/event_engine/test_suite/tests/timer_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cf_event_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(cf_event_engine_test PUBLIC cxx_std_14) target_include_directories(cf_event_engine_test PRIVATE @@ -8508,6 +9287,16 @@ add_executable(cfstream_test test/cpp/end2end/cfstream_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cfstream_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cfstream_test PUBLIC cxx_std_14) target_include_directories(cfstream_test PRIVATE @@ -8541,6 +9330,15 @@ if(gRPC_BUILD_TESTS) add_executable(channel_args_test test/core/channel/channel_args_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_args_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_args_test PUBLIC cxx_std_14) target_include_directories(channel_args_test PRIVATE @@ -8574,6 +9372,16 @@ if(gRPC_BUILD_TESTS) add_executable(channel_arguments_test test/cpp/common/channel_arguments_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_arguments_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_arguments_test PUBLIC cxx_std_14) target_include_directories(channel_arguments_test PRIVATE @@ -8618,6 +9426,15 @@ add_executable(channel_creds_registry_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_creds_registry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_creds_registry_test PUBLIC cxx_std_14) target_include_directories(channel_creds_registry_test PRIVATE @@ -8651,6 +9468,15 @@ if(gRPC_BUILD_TESTS) add_executable(channel_init_test test/core/surface/channel_init_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_init_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_init_test PUBLIC cxx_std_14) target_include_directories(channel_init_test PRIVATE @@ -8684,6 +9510,15 @@ if(gRPC_BUILD_TESTS) add_executable(channel_stack_builder_test test/core/channel/channel_stack_builder_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_stack_builder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_stack_builder_test PUBLIC cxx_std_14) target_include_directories(channel_stack_builder_test PRIVATE @@ -8717,6 +9552,15 @@ if(gRPC_BUILD_TESTS) add_executable(channel_stack_test test/core/channel/channel_stack_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_stack_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_stack_test PUBLIC cxx_std_14) target_include_directories(channel_stack_test PRIVATE @@ -8755,6 +9599,16 @@ add_executable(channel_trace_test test/core/channel/channel_trace_test.cc test/cpp/util/channel_trace_proto_helper.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channel_trace_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channel_trace_test PUBLIC cxx_std_14) target_include_directories(channel_trace_test PRIVATE @@ -8789,9 +9643,19 @@ if(gRPC_BUILD_TESTS) add_executable(channelz_registry_test test/core/channel/channelz_registry_test.cc ) -target_compile_features(channelz_registry_test PUBLIC cxx_std_14) -target_include_directories(channelz_registry_test - PRIVATE +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channelz_registry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(channelz_registry_test PUBLIC cxx_std_14) +target_include_directories(channelz_registry_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} @@ -8841,6 +9705,16 @@ add_executable(channelz_service_test test/cpp/end2end/channelz_service_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(channelz_service_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(channelz_service_test PUBLIC cxx_std_14) target_include_directories(channelz_service_test PRIVATE @@ -8885,6 +9759,15 @@ add_executable(check_gcp_environment_linux_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(check_gcp_environment_linux_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(check_gcp_environment_linux_test PUBLIC cxx_std_14) target_include_directories(check_gcp_environment_linux_test PRIVATE @@ -8928,6 +9811,15 @@ add_executable(check_gcp_environment_windows_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(check_gcp_environment_windows_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(check_gcp_environment_windows_test PUBLIC cxx_std_14) target_include_directories(check_gcp_environment_windows_test PRIVATE @@ -9006,6 +9898,14 @@ add_executable(chunked_vector_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(chunked_vector_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(chunked_vector_test PUBLIC cxx_std_14) target_include_directories(chunked_vector_test PRIVATE @@ -9071,6 +9971,16 @@ add_executable(cli_call_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cli_call_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cli_call_test PUBLIC cxx_std_14) target_include_directories(cli_call_test PRIVATE @@ -9111,6 +10021,15 @@ add_executable(client_auth_filter_test test/core/filters/client_auth_filter_test.cc test/core/filters/filter_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_auth_filter_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_auth_filter_test PUBLIC cxx_std_14) target_include_directories(client_auth_filter_test PRIVATE @@ -9151,6 +10070,15 @@ add_executable(client_authority_filter_test test/core/filters/client_authority_filter_test.cc test/core/filters/filter_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_authority_filter_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_authority_filter_test PUBLIC cxx_std_14) target_include_directories(client_authority_filter_test PRIVATE @@ -9203,6 +10131,16 @@ add_executable(client_callback_end2end_test test/cpp/end2end/interceptors_util.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_callback_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_callback_end2end_test PUBLIC cxx_std_14) target_include_directories(client_callback_end2end_test PRIVATE @@ -9236,6 +10174,15 @@ if(gRPC_BUILD_TESTS) add_executable(client_channel_service_config_test test/core/client_channel/client_channel_service_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_channel_service_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_channel_service_config_test PUBLIC cxx_std_14) target_include_directories(client_channel_service_config_test PRIVATE @@ -9269,6 +10216,15 @@ if(gRPC_BUILD_TESTS) add_executable(client_channel_test test/core/client_channel/client_channel_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_channel_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_channel_test PUBLIC cxx_std_14) target_include_directories(client_channel_test PRIVATE @@ -9302,6 +10258,16 @@ if(gRPC_BUILD_TESTS) add_executable(client_context_test_peer_test test/cpp/test/client_context_test_peer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_context_test_peer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_context_test_peer_test PUBLIC cxx_std_14) target_include_directories(client_context_test_peer_test PRIVATE @@ -9356,6 +10322,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/client_fork_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_fork_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(client_fork_test PUBLIC cxx_std_14) target_include_directories(client_fork_test PRIVATE @@ -9410,6 +10386,16 @@ add_executable(client_interceptors_end2end_test test/cpp/end2end/interceptors_util.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_interceptors_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_interceptors_end2end_test PUBLIC cxx_std_14) target_include_directories(client_interceptors_end2end_test PRIVATE @@ -9472,6 +10458,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/connection_attempt_injector.cc test/cpp/end2end/test_service_impl.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_lb_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(client_lb_end2end_test PUBLIC cxx_std_14) target_include_directories(client_lb_end2end_test PRIVATE @@ -9507,6 +10503,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(client_ssl_test test/core/handshake/client_ssl.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_ssl_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(client_ssl_test PUBLIC cxx_std_14) target_include_directories(client_ssl_test PRIVATE @@ -9550,6 +10555,15 @@ add_executable(client_streaming_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(client_streaming_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(client_streaming_test PUBLIC cxx_std_14) target_include_directories(client_streaming_test PRIVATE @@ -9595,6 +10609,15 @@ add_executable(cmdline_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cmdline_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cmdline_test PUBLIC cxx_std_14) target_include_directories(cmdline_test PRIVATE @@ -9628,6 +10651,16 @@ if(gRPC_BUILD_TESTS) add_executable(codegen_test_full test/cpp/codegen/codegen_test_full.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(codegen_test_full + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(codegen_test_full PUBLIC cxx_std_14) target_include_directories(codegen_test_full PRIVATE @@ -9662,6 +10695,16 @@ if(gRPC_BUILD_TESTS) add_executable(codegen_test_minimal test/cpp/codegen/codegen_test_minimal.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(codegen_test_minimal + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(codegen_test_minimal PUBLIC cxx_std_14) target_include_directories(codegen_test_minimal PRIVATE @@ -9707,6 +10750,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(combiner_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(combiner_test PUBLIC cxx_std_14) target_include_directories(combiner_test PRIVATE @@ -9741,6 +10793,14 @@ if(gRPC_BUILD_TESTS) add_executable(common_closures_test test/core/event_engine/common_closures_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(common_closures_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(common_closures_test PUBLIC cxx_std_14) target_include_directories(common_closures_test PRIVATE @@ -9775,6 +10835,15 @@ if(gRPC_BUILD_TESTS) add_executable(completion_queue_threading_test test/core/surface/completion_queue_threading_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(completion_queue_threading_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(completion_queue_threading_test PUBLIC cxx_std_14) target_include_directories(completion_queue_threading_test PRIVATE @@ -9817,6 +10886,15 @@ add_executable(compressed_payload_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(compressed_payload_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(compressed_payload_test PUBLIC cxx_std_14) target_include_directories(compressed_payload_test PRIVATE @@ -9852,6 +10930,15 @@ if(gRPC_BUILD_TESTS) add_executable(compression_test test/core/compression/compression_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(compression_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(compression_test PUBLIC cxx_std_14) target_include_directories(compression_test PRIVATE @@ -9885,6 +10972,15 @@ if(gRPC_BUILD_TESTS) add_executable(concurrent_connectivity_test test/core/surface/concurrent_connectivity_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(concurrent_connectivity_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(concurrent_connectivity_test PUBLIC cxx_std_14) target_include_directories(concurrent_connectivity_test PRIVATE @@ -9920,6 +11016,15 @@ add_executable(connection_prefix_bad_client_test test/core/bad_client/tests/connection_prefix.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(connection_prefix_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(connection_prefix_bad_client_test PUBLIC cxx_std_14) target_include_directories(connection_prefix_bad_client_test PRIVATE @@ -9954,6 +11059,15 @@ add_executable(connection_refused_test test/core/end2end/connection_refused_test.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(connection_refused_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(connection_refused_test PUBLIC cxx_std_14) target_include_directories(connection_refused_test PRIVATE @@ -9997,6 +11111,15 @@ add_executable(connectivity_state_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(connectivity_state_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(connectivity_state_test PUBLIC cxx_std_14) target_include_directories(connectivity_state_test PRIVATE @@ -10039,6 +11162,15 @@ add_executable(connectivity_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(connectivity_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(connectivity_test PUBLIC cxx_std_14) target_include_directories(connectivity_test PRIVATE @@ -10091,6 +11223,16 @@ add_executable(context_allocator_end2end_test test/cpp/end2end/context_allocator_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(context_allocator_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(context_allocator_end2end_test PUBLIC cxx_std_14) target_include_directories(context_allocator_end2end_test PRIVATE @@ -10124,6 +11266,14 @@ if(gRPC_BUILD_TESTS) add_executable(context_test test/core/promise/context_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(context_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(context_test PUBLIC cxx_std_14) target_include_directories(context_test PRIVATE @@ -10157,6 +11307,15 @@ if(gRPC_BUILD_TESTS) add_executable(core_configuration_test test/core/config/core_configuration_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(core_configuration_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(core_configuration_test PUBLIC cxx_std_14) target_include_directories(core_configuration_test PRIVATE @@ -10222,6 +11381,15 @@ if(gRPC_BUILD_TESTS) add_executable(cpu_test test/core/gpr/cpu_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(cpu_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(cpu_test PUBLIC cxx_std_14) target_include_directories(cpu_test PRIVATE @@ -10272,6 +11440,16 @@ add_executable(crl_provider_test test/cpp/end2end/crl_provider_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(crl_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(crl_provider_test PUBLIC cxx_std_14) target_include_directories(crl_provider_test PRIVATE @@ -10307,6 +11485,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/tsi/crl_ssl_transport_security_test.cc test/core/tsi/transport_security_test_lib.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(crl_ssl_transport_security_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(crl_ssl_transport_security_test PUBLIC cxx_std_14) target_include_directories(crl_ssl_transport_security_test PRIVATE @@ -10341,6 +11528,15 @@ if(gRPC_BUILD_TESTS) add_executable(default_engine_methods_test test/core/event_engine/default_engine_methods_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(default_engine_methods_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(default_engine_methods_test PUBLIC cxx_std_14) target_include_directories(default_engine_methods_test PRIVATE @@ -10383,6 +11579,15 @@ add_executable(default_host_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(default_host_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(default_host_test PUBLIC cxx_std_14) target_include_directories(default_host_test PRIVATE @@ -10435,6 +11640,16 @@ add_executable(delegating_channel_test test/cpp/end2end/delegating_channel_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(delegating_channel_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(delegating_channel_test PUBLIC cxx_std_14) target_include_directories(delegating_channel_test PRIVATE @@ -10468,6 +11683,16 @@ if(gRPC_BUILD_TESTS) add_executable(destroy_grpclb_channel_with_active_connect_stress_test test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(destroy_grpclb_channel_with_active_connect_stress_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(destroy_grpclb_channel_with_active_connect_stress_test PUBLIC cxx_std_14) target_include_directories(destroy_grpclb_channel_with_active_connect_stress_test PRIVATE @@ -10501,6 +11726,15 @@ if(gRPC_BUILD_TESTS) add_executable(directory_reader_test test/core/gprpp/directory_reader_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(directory_reader_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(directory_reader_test PUBLIC cxx_std_14) target_include_directories(directory_reader_test PRIVATE @@ -10543,6 +11777,15 @@ add_executable(disappearing_server_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(disappearing_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(disappearing_server_test PUBLIC cxx_std_14) target_include_directories(disappearing_server_test PRIVATE @@ -10578,6 +11821,15 @@ if(gRPC_BUILD_TESTS) add_executable(dns_resolver_cooldown_test test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(dns_resolver_cooldown_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(dns_resolver_cooldown_test PUBLIC cxx_std_14) target_include_directories(dns_resolver_cooldown_test PRIVATE @@ -10611,6 +11863,15 @@ if(gRPC_BUILD_TESTS) add_executable(dns_resolver_test test/core/client_channel/resolvers/dns_resolver_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(dns_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(dns_resolver_test PUBLIC cxx_std_14) target_include_directories(dns_resolver_test PRIVATE @@ -10644,6 +11905,15 @@ if(gRPC_BUILD_TESTS) add_executable(dual_ref_counted_test test/core/gprpp/dual_ref_counted_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(dual_ref_counted_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(dual_ref_counted_test PUBLIC cxx_std_14) target_include_directories(dual_ref_counted_test PRIVATE @@ -10679,6 +11949,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/end2end/cq_verifier.cc test/core/end2end/dualstack_socket_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(dualstack_socket_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(dualstack_socket_test PUBLIC cxx_std_14) target_include_directories(dualstack_socket_test PRIVATE @@ -10715,7 +11994,16 @@ add_executable(duplicate_header_bad_client_test test/core/bad_client/tests/duplicate_header.cc test/core/end2end/cq_verifier.cc ) -target_compile_features(duplicate_header_bad_client_test PUBLIC cxx_std_14) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(duplicate_header_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(duplicate_header_bad_client_test PUBLIC cxx_std_14) target_include_directories(duplicate_header_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} @@ -10757,6 +12045,15 @@ add_executable(empty_batch_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(empty_batch_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(empty_batch_test PUBLIC cxx_std_14) target_include_directories(empty_batch_test PRIVATE @@ -10812,6 +12109,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/transport/binder/end2end/testing_channel_create.cc test/cpp/end2end/test_service_impl.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(end2end_binder_transport_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(end2end_binder_transport_test PUBLIC cxx_std_14) target_include_directories(end2end_binder_transport_test PRIVATE @@ -10868,6 +12175,16 @@ add_executable(end2end_test test/cpp/end2end/interceptors_util.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(end2end_test PUBLIC cxx_std_14) target_include_directories(end2end_test PRIVATE @@ -10901,6 +12218,15 @@ if(gRPC_BUILD_TESTS) add_executable(endpoint_addresses_test test/core/resolver/endpoint_addresses_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(endpoint_addresses_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(endpoint_addresses_test PUBLIC cxx_std_14) target_include_directories(endpoint_addresses_test PRIVATE @@ -10997,6 +12323,15 @@ add_executable(endpoint_binder_pool_test test/core/transport/binder/endpoint_binder_pool_test.cc test/core/transport/binder/mock_objects.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(endpoint_binder_pool_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(endpoint_binder_pool_test PUBLIC cxx_std_14) target_include_directories(endpoint_binder_pool_test PRIVATE @@ -11036,6 +12371,14 @@ add_executable(endpoint_config_test src/core/lib/surface/channel_stack_type.cc test/core/event_engine/endpoint_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(endpoint_config_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(endpoint_config_test PUBLIC cxx_std_14) target_include_directories(endpoint_config_test PRIVATE @@ -11083,6 +12426,15 @@ add_executable(endpoint_pair_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(endpoint_pair_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(endpoint_pair_test PUBLIC cxx_std_14) target_include_directories(endpoint_pair_test PRIVATE @@ -11116,6 +12468,15 @@ if(gRPC_BUILD_TESTS) add_executable(env_test test/core/gpr/env_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(env_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(env_test PUBLIC cxx_std_14) target_include_directories(env_test PRIVATE @@ -11161,6 +12522,16 @@ add_executable(error_details_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/util/error_details_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(error_details_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(error_details_test PUBLIC cxx_std_14) target_include_directories(error_details_test PRIVATE @@ -11206,6 +12577,15 @@ add_executable(error_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(error_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(error_test PUBLIC cxx_std_14) target_include_directories(error_test PRIVATE @@ -11249,6 +12629,15 @@ add_executable(error_utils_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(error_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(error_utils_test PUBLIC cxx_std_14) target_include_directories(error_utils_test PRIVATE @@ -11292,6 +12681,15 @@ add_executable(evaluate_args_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(evaluate_args_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(evaluate_args_test PUBLIC cxx_std_14) target_include_directories(evaluate_args_test PRIVATE @@ -11325,6 +12723,15 @@ if(gRPC_BUILD_TESTS) add_executable(event_engine_wakeup_scheduler_test test/core/promise/event_engine_wakeup_scheduler_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(event_engine_wakeup_scheduler_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(event_engine_wakeup_scheduler_test PUBLIC cxx_std_14) target_include_directories(event_engine_wakeup_scheduler_test PRIVATE @@ -11360,6 +12767,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/posix/event_poller_posix_test.cc test/core/event_engine/posix/posix_engine_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(event_poller_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(event_poller_posix_test PUBLIC cxx_std_14) target_include_directories(event_poller_posix_test PRIVATE @@ -11395,6 +12811,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(examine_stack_test test/core/gprpp/examine_stack_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(examine_stack_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(examine_stack_test PUBLIC cxx_std_14) target_include_directories(examine_stack_test PRIVATE @@ -11445,6 +12870,16 @@ add_executable(exception_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/exception_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(exception_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(exception_test PUBLIC cxx_std_14) target_include_directories(exception_test PRIVATE @@ -11516,6 +12951,14 @@ add_executable(exec_ctx_wakeup_scheduler_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(exec_ctx_wakeup_scheduler_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(exec_ctx_wakeup_scheduler_test PUBLIC cxx_std_14) target_include_directories(exec_ctx_wakeup_scheduler_test PRIVATE @@ -11557,6 +13000,14 @@ add_executable(experiments_tag_test test/core/experiments/experiments_tag_test.cc test/core/experiments/fixtures/experiments.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(experiments_tag_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(experiments_tag_test PUBLIC cxx_std_14) target_include_directories(experiments_tag_test PRIVATE @@ -11594,6 +13045,14 @@ add_executable(experiments_test test/core/experiments/experiments_test.cc test/core/experiments/fixtures/experiments.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(experiments_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(experiments_test PUBLIC cxx_std_14) target_include_directories(experiments_test PRIVATE @@ -11627,6 +13086,15 @@ if(gRPC_BUILD_TESTS) add_executable(factory_test test/core/event_engine/factory_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(factory_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(factory_test PUBLIC cxx_std_14) target_include_directories(factory_test PRIVATE @@ -11723,6 +13191,15 @@ add_executable(fake_binder_test test/core/transport/binder/end2end/fake_binder.cc test/core/transport/binder/end2end/fake_binder_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fake_binder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(fake_binder_test PUBLIC cxx_std_14) target_include_directories(fake_binder_test PRIVATE @@ -11757,6 +13234,15 @@ if(gRPC_BUILD_TESTS) add_executable(fake_resolver_test test/core/client_channel/resolvers/fake_resolver_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fake_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(fake_resolver_test PUBLIC cxx_std_14) target_include_directories(fake_resolver_test PRIVATE @@ -11791,6 +13277,15 @@ add_executable(fake_transport_security_test test/core/tsi/fake_transport_security_test.cc test/core/tsi/transport_security_test_lib.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fake_transport_security_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(fake_transport_security_test PUBLIC cxx_std_14) target_include_directories(fake_transport_security_test PRIVATE @@ -11835,6 +13330,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fd_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(fd_posix_test PUBLIC cxx_std_14) target_include_directories(fd_posix_test PRIVATE @@ -11869,6 +13373,15 @@ if(gRPC_BUILD_TESTS) add_executable(file_watcher_certificate_provider_factory_test test/core/xds/file_watcher_certificate_provider_factory_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(file_watcher_certificate_provider_factory_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(file_watcher_certificate_provider_factory_test PUBLIC cxx_std_14) target_include_directories(file_watcher_certificate_provider_factory_test PRIVATE @@ -11911,6 +13424,15 @@ add_executable(filter_causes_close_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(filter_causes_close_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(filter_causes_close_test PUBLIC cxx_std_14) target_include_directories(filter_causes_close_test PRIVATE @@ -11955,6 +13477,15 @@ add_executable(filter_context_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(filter_context_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(filter_context_test PUBLIC cxx_std_14) target_include_directories(filter_context_test PRIVATE @@ -11999,6 +13530,15 @@ add_executable(filter_init_fails_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(filter_init_fails_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(filter_init_fails_test PUBLIC cxx_std_14) target_include_directories(filter_init_fails_test PRIVATE @@ -12040,6 +13580,15 @@ add_executable(filter_test_test test/core/filters/filter_test.cc test/core/filters/filter_test_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(filter_test_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(filter_test_test PUBLIC cxx_std_14) target_include_directories(filter_test_test PRIVATE @@ -12084,6 +13633,15 @@ add_executable(filtered_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(filtered_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(filtered_metadata_test PUBLIC cxx_std_14) target_include_directories(filtered_metadata_test PRIVATE @@ -12136,6 +13694,16 @@ add_executable(flaky_network_test test/cpp/end2end/flaky_network_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(flaky_network_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(flaky_network_test PUBLIC cxx_std_14) target_include_directories(flaky_network_test PRIVATE @@ -12216,6 +13784,14 @@ add_executable(flow_control_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(flow_control_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(flow_control_test PUBLIC cxx_std_14) target_include_directories(flow_control_test PRIVATE @@ -12300,6 +13876,14 @@ add_executable(for_each_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(for_each_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(for_each_test PUBLIC cxx_std_14) target_include_directories(for_each_test PRIVATE @@ -12340,6 +13924,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(fork_test test/core/gprpp/fork_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fork_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(fork_test PUBLIC cxx_std_14) target_include_directories(fork_test PRIVATE @@ -12376,6 +13969,14 @@ add_executable(forkable_test src/core/lib/event_engine/forkable.cc test/core/event_engine/forkable_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(forkable_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(forkable_test PUBLIC cxx_std_14) target_include_directories(forkable_test PRIVATE @@ -12424,6 +14025,15 @@ add_executable(format_request_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(format_request_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(format_request_test PUBLIC cxx_std_14) target_include_directories(format_request_test PRIVATE @@ -12458,6 +14068,15 @@ add_executable(frame_handler_test test/core/tsi/alts/crypt/gsec_test_util.cc test/core/tsi/alts/frame_protector/frame_handler_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(frame_handler_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(frame_handler_test PUBLIC cxx_std_14) target_include_directories(frame_handler_test PRIVATE @@ -12497,6 +14116,14 @@ add_executable(frame_test src/core/lib/slice/slice_string_helpers.cc test/core/transport/chttp2/frame_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(frame_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(frame_test PUBLIC cxx_std_14) target_include_directories(frame_test PRIVATE @@ -12544,6 +14171,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/tests/server_test.cc test/core/event_engine/test_suite/tests/timer_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fuzzing_event_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(fuzzing_event_engine_test PUBLIC cxx_std_14) target_include_directories(fuzzing_event_engine_test PRIVATE @@ -12584,6 +14220,15 @@ add_executable(fuzzing_event_engine_unittest test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine_unittest.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(fuzzing_event_engine_unittest + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(fuzzing_event_engine_unittest PUBLIC cxx_std_14) target_include_directories(fuzzing_event_engine_unittest PRIVATE @@ -12638,6 +14283,16 @@ add_executable(generic_end2end_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/generic_end2end_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(generic_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(generic_end2end_test PUBLIC cxx_std_14) target_include_directories(generic_end2end_test PRIVATE @@ -12672,6 +14327,15 @@ add_executable(goaway_server_test test/core/end2end/cq_verifier.cc test/core/end2end/goaway_server_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(goaway_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(goaway_server_test PUBLIC cxx_std_14) target_include_directories(goaway_server_test PRIVATE @@ -12706,6 +14370,16 @@ add_executable(google_c2p_resolver_test test/core/client_channel/resolvers/google_c2p_resolver_test.cc test/core/util/fake_udp_and_tcp_server.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(google_c2p_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(google_c2p_resolver_test PUBLIC cxx_std_14) target_include_directories(google_c2p_resolver_test PRIVATE @@ -12748,6 +14422,15 @@ add_executable(graceful_server_shutdown_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(graceful_server_shutdown_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(graceful_server_shutdown_test PUBLIC cxx_std_14) target_include_directories(graceful_server_shutdown_test PRIVATE @@ -12784,6 +14467,15 @@ add_executable(graceful_shutdown_test test/core/end2end/cq_verifier.cc test/core/transport/chttp2/graceful_shutdown_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(graceful_shutdown_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(graceful_shutdown_test PUBLIC cxx_std_14) target_include_directories(graceful_shutdown_test PRIVATE @@ -12827,9 +14519,18 @@ add_executable(grpc_alts_credentials_options_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) -target_compile_features(grpc_alts_credentials_options_test PUBLIC cxx_std_14) -target_include_directories(grpc_alts_credentials_options_test - PRIVATE +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_alts_credentials_options_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(grpc_alts_credentials_options_test PUBLIC cxx_std_14) +target_include_directories(grpc_alts_credentials_options_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} @@ -12860,6 +14561,15 @@ if(gRPC_BUILD_TESTS) add_executable(grpc_audit_logging_test test/core/security/grpc_audit_logging_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_audit_logging_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_audit_logging_test PUBLIC cxx_std_14) target_include_directories(grpc_audit_logging_test PRIVATE @@ -12904,6 +14614,15 @@ add_executable(grpc_authorization_engine_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_authorization_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_authorization_engine_test PUBLIC cxx_std_14) target_include_directories(grpc_authorization_engine_test PRIVATE @@ -12947,6 +14666,15 @@ add_executable(grpc_authorization_policy_provider_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_authorization_policy_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_authorization_policy_provider_test PUBLIC cxx_std_14) target_include_directories(grpc_authorization_policy_provider_test PRIVATE @@ -13000,6 +14728,16 @@ add_executable(grpc_authz_end2end_test test/cpp/end2end/grpc_authz_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_authz_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_authz_end2end_test PUBLIC cxx_std_14) target_include_directories(grpc_authz_end2end_test PRIVATE @@ -13043,6 +14781,15 @@ add_executable(grpc_authz_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_authz_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_authz_test PUBLIC cxx_std_14) target_include_directories(grpc_authz_test PRIVATE @@ -13078,6 +14825,15 @@ if(gRPC_BUILD_TESTS) add_executable(grpc_byte_buffer_reader_test test/core/surface/byte_buffer_reader_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_byte_buffer_reader_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_byte_buffer_reader_test PUBLIC cxx_std_14) target_include_directories(grpc_byte_buffer_reader_test PRIVATE @@ -13121,6 +14877,16 @@ add_executable(grpc_cli test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_cli + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_cli PUBLIC cxx_std_14) target_include_directories(grpc_cli PRIVATE @@ -13151,6 +14917,15 @@ if(gRPC_BUILD_TESTS) add_executable(grpc_completion_queue_test test/core/surface/completion_queue_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_completion_queue_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_completion_queue_test PUBLIC cxx_std_14) target_include_directories(grpc_completion_queue_test PRIVATE @@ -13270,6 +15045,15 @@ add_executable(grpc_ipv6_loopback_available_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_ipv6_loopback_available_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_ipv6_loopback_available_test PUBLIC cxx_std_14) target_include_directories(grpc_ipv6_loopback_available_test PRIVATE @@ -13503,6 +15287,15 @@ add_executable(grpc_tls_certificate_distributor_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_certificate_distributor_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_certificate_distributor_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_certificate_distributor_test PRIVATE @@ -13546,6 +15339,15 @@ add_executable(grpc_tls_certificate_provider_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_certificate_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_certificate_provider_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_certificate_provider_test PRIVATE @@ -13589,6 +15391,15 @@ add_executable(grpc_tls_certificate_verifier_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_certificate_verifier_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_certificate_verifier_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_certificate_verifier_test PRIVATE @@ -13632,6 +15443,15 @@ add_executable(grpc_tls_credentials_options_comparator_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_credentials_options_comparator_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_credentials_options_comparator_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_credentials_options_comparator_test PRIVATE @@ -13675,6 +15495,15 @@ add_executable(grpc_tls_credentials_options_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_credentials_options_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_credentials_options_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_credentials_options_test PRIVATE @@ -13718,6 +15547,15 @@ add_executable(grpc_tls_crl_provider_test test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc test/core/security/grpc_tls_crl_provider_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tls_crl_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpc_tls_crl_provider_test PUBLIC cxx_std_14) target_include_directories(grpc_tls_crl_provider_test PRIVATE @@ -13775,6 +15613,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpc_tool_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(grpc_tool_test PUBLIC cxx_std_14) target_include_directories(grpc_tool_test PRIVATE @@ -13816,6 +15664,16 @@ add_executable(grpclb_api_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h test/cpp/grpclb/grpclb_api_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpclb_api_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(grpclb_api_test PUBLIC cxx_std_14) target_include_directories(grpclb_api_test PRIVATE @@ -13875,6 +15733,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/grpclb_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(grpclb_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(grpclb_end2end_test PUBLIC cxx_std_14) target_include_directories(grpclb_end2end_test PRIVATE @@ -13918,6 +15786,15 @@ add_executable(h2_ssl_cert_test test/core/end2end/h2_ssl_cert_test.cc test/core/event_engine/event_engine_test_utils.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(h2_ssl_cert_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(h2_ssl_cert_test PUBLIC cxx_std_14) target_include_directories(h2_ssl_cert_test PRIVATE @@ -13952,6 +15829,15 @@ add_executable(h2_ssl_session_reuse_test test/core/end2end/cq_verifier.cc test/core/end2end/h2_ssl_session_reuse_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(h2_ssl_session_reuse_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(h2_ssl_session_reuse_test PUBLIC cxx_std_14) target_include_directories(h2_ssl_session_reuse_test PRIVATE @@ -13986,6 +15872,15 @@ add_executable(h2_tls_peer_property_external_verifier_test test/core/end2end/cq_verifier.cc test/core/end2end/h2_tls_peer_property_external_verifier_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(h2_tls_peer_property_external_verifier_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(h2_tls_peer_property_external_verifier_test PUBLIC cxx_std_14) target_include_directories(h2_tls_peer_property_external_verifier_test PRIVATE @@ -14019,6 +15914,15 @@ if(gRPC_BUILD_TESTS) add_executable(handle_tests test/core/event_engine/handle_tests.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(handle_tests + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(handle_tests PUBLIC cxx_std_14) target_include_directories(handle_tests PRIVATE @@ -14054,6 +15958,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/handshake/readahead_handshaker_server_ssl.cc test/core/handshake/server_ssl_common.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(handshake_server_with_readahead_handshaker_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(handshake_server_with_readahead_handshaker_test PUBLIC cxx_std_14) target_include_directories(handshake_server_with_readahead_handshaker_test PRIVATE @@ -14090,6 +16003,15 @@ add_executable(head_of_line_blocking_bad_client_test test/core/bad_client/tests/head_of_line_blocking.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(head_of_line_blocking_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(head_of_line_blocking_bad_client_test PUBLIC cxx_std_14) target_include_directories(head_of_line_blocking_bad_client_test PRIVATE @@ -14125,6 +16047,15 @@ add_executable(headers_bad_client_test test/core/bad_client/tests/headers.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(headers_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(headers_bad_client_test PUBLIC cxx_std_14) target_include_directories(headers_bad_client_test PRIVATE @@ -14184,6 +16115,16 @@ add_executable(health_service_end2end_test test/cpp/end2end/test_health_check_service_impl.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(health_service_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(health_service_end2end_test PUBLIC cxx_std_14) target_include_directories(health_service_end2end_test PRIVATE @@ -14226,6 +16167,15 @@ add_executable(high_initial_seqno_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(high_initial_seqno_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(high_initial_seqno_test PUBLIC cxx_std_14) target_include_directories(high_initial_seqno_test PRIVATE @@ -14271,6 +16221,15 @@ add_executable(histogram_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(histogram_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(histogram_test PUBLIC cxx_std_14) target_include_directories(histogram_test PRIVATE @@ -14304,6 +16263,15 @@ if(gRPC_BUILD_TESTS) add_executable(host_port_test test/core/gprpp/host_port_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(host_port_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(host_port_test PUBLIC cxx_std_14) target_include_directories(host_port_test PRIVATE @@ -14347,6 +16315,15 @@ add_executable(hpack_encoder_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(hpack_encoder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(hpack_encoder_test PUBLIC cxx_std_14) target_include_directories(hpack_encoder_test PRIVATE @@ -14390,6 +16367,15 @@ add_executable(hpack_parser_table_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(hpack_parser_table_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(hpack_parser_table_test PUBLIC cxx_std_14) target_include_directories(hpack_parser_table_test PRIVATE @@ -14433,6 +16419,15 @@ add_executable(hpack_parser_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(hpack_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(hpack_parser_test PUBLIC cxx_std_14) target_include_directories(hpack_parser_test PRIVATE @@ -14475,6 +16470,15 @@ add_executable(hpack_size_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(hpack_size_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(hpack_size_test PUBLIC cxx_std_14) target_include_directories(hpack_size_test PRIVATE @@ -14522,6 +16526,16 @@ add_executable(http2_client ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.h test/cpp/interop/http2_client.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(http2_client + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(http2_client PUBLIC cxx_std_14) target_include_directories(http2_client PRIVATE @@ -14560,6 +16574,15 @@ add_executable(http2_stats_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(http2_stats_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(http2_stats_test PUBLIC cxx_std_14) target_include_directories(http2_stats_test PRIVATE @@ -14595,6 +16618,15 @@ if(gRPC_BUILD_TESTS) add_executable(http_proxy_mapper_test test/core/client_channel/http_proxy_mapper_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(http_proxy_mapper_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(http_proxy_mapper_test PUBLIC cxx_std_14) target_include_directories(http_proxy_mapper_test PRIVATE @@ -14631,6 +16663,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/http/httpcli_test_util.cc test/core/util/fake_udp_and_tcp_server.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(httpcli_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(httpcli_test PUBLIC cxx_std_14) target_include_directories(httpcli_test PRIVATE @@ -14668,6 +16710,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/http/httpscli_test.cc test/core/util/fake_udp_and_tcp_server.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(httpscli_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(httpscli_test PUBLIC cxx_std_14) target_include_directories(httpscli_test PRIVATE @@ -14723,6 +16775,16 @@ add_executable(hybrid_end2end_test test/cpp/end2end/hybrid_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(hybrid_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(hybrid_end2end_test PUBLIC cxx_std_14) target_include_directories(hybrid_end2end_test PRIVATE @@ -14821,6 +16883,14 @@ if(gRPC_BUILD_TESTS) add_executable(if_test test/core/promise/if_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(if_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(if_test PUBLIC cxx_std_14) target_include_directories(if_test PRIVATE @@ -14856,6 +16926,15 @@ if(gRPC_BUILD_TESTS) add_executable(init_test test/core/surface/init_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(init_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(init_test PUBLIC cxx_std_14) target_include_directories(init_test PRIVATE @@ -14891,6 +16970,15 @@ add_executable(initial_settings_frame_bad_client_test test/core/bad_client/tests/initial_settings_frame.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(initial_settings_frame_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(initial_settings_frame_bad_client_test PUBLIC cxx_std_14) target_include_directories(initial_settings_frame_bad_client_test PRIVATE @@ -14934,6 +17022,15 @@ add_executable(insecure_security_connector_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(insecure_security_connector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(insecure_security_connector_test PUBLIC cxx_std_14) target_include_directories(insecure_security_connector_test PRIVATE @@ -14967,6 +17064,15 @@ if(gRPC_BUILD_TESTS) add_executable(inter_activity_latch_test test/core/promise/inter_activity_latch_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(inter_activity_latch_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(inter_activity_latch_test PUBLIC cxx_std_14) target_include_directories(inter_activity_latch_test PRIVATE @@ -15003,9 +17109,17 @@ add_executable(inter_activity_pipe_test src/core/lib/promise/trace.cc test/core/promise/inter_activity_pipe_test.cc ) -target_compile_features(inter_activity_pipe_test PUBLIC cxx_std_14) -target_include_directories(inter_activity_pipe_test - PRIVATE +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(inter_activity_pipe_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(inter_activity_pipe_test PUBLIC cxx_std_14) +target_include_directories(inter_activity_pipe_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} @@ -15084,6 +17198,14 @@ add_executable(interceptor_list_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(interceptor_list_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(interceptor_list_test PUBLIC cxx_std_14) target_include_directories(interceptor_list_test PRIVATE @@ -15139,6 +17261,16 @@ add_executable(interop_client test/cpp/interop/client_helper.cc test/cpp/interop/interop_client.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(interop_client + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(interop_client PUBLIC cxx_std_14) target_include_directories(interop_client PRIVATE @@ -15183,6 +17315,16 @@ add_executable(interop_server test/cpp/interop/interop_server_bootstrap.cc test/cpp/interop/server_helper.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(interop_server + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(interop_server PUBLIC cxx_std_14) target_include_directories(interop_server PRIVATE @@ -15213,6 +17355,15 @@ add_executable(invalid_call_argument_test test/core/end2end/cq_verifier.cc test/core/end2end/invalid_call_argument_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(invalid_call_argument_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(invalid_call_argument_test PUBLIC cxx_std_14) target_include_directories(invalid_call_argument_test PRIVATE @@ -15255,6 +17406,15 @@ add_executable(invoke_large_request_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(invoke_large_request_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(invoke_large_request_test PUBLIC cxx_std_14) target_include_directories(invoke_large_request_test PRIVATE @@ -15292,6 +17452,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX OR _gRPC_PLATFORM_WINDOWS) test/core/event_engine/windows/create_sockpair.cc test/core/event_engine/windows/iocp_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(iocp_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(iocp_test PUBLIC cxx_std_14) target_include_directories(iocp_test PRIVATE @@ -15331,6 +17500,16 @@ add_executable(istio_echo_server_test test/cpp/interop/istio_echo_server_lib.cc test/cpp/interop/istio_echo_server_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(istio_echo_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(istio_echo_server_test PUBLIC cxx_std_14) target_include_directories(istio_echo_server_test PRIVATE @@ -15368,6 +17547,14 @@ add_executable(join_test src/core/lib/promise/trace.cc test/core/promise/join_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(join_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(join_test PUBLIC cxx_std_14) target_include_directories(join_test PRIVATE @@ -15403,6 +17590,15 @@ if(gRPC_BUILD_TESTS) add_executable(json_object_loader_test test/core/json/json_object_loader_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(json_object_loader_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(json_object_loader_test PUBLIC cxx_std_14) target_include_directories(json_object_loader_test PRIVATE @@ -15436,6 +17632,15 @@ if(gRPC_BUILD_TESTS) add_executable(json_test test/core/json/json_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(json_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(json_test PUBLIC cxx_std_14) target_include_directories(json_test PRIVATE @@ -15479,6 +17684,15 @@ add_executable(json_token_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(json_token_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(json_token_test PUBLIC cxx_std_14) target_include_directories(json_token_test PRIVATE @@ -15522,6 +17736,15 @@ add_executable(jwt_verifier_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(jwt_verifier_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(jwt_verifier_test PUBLIC cxx_std_14) target_include_directories(jwt_verifier_test PRIVATE @@ -15564,6 +17787,15 @@ add_executable(keepalive_timeout_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(keepalive_timeout_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(keepalive_timeout_test PUBLIC cxx_std_14) target_include_directories(keepalive_timeout_test PRIVATE @@ -15600,6 +17832,15 @@ add_executable(lame_client_test test/core/end2end/cq_verifier.cc test/core/surface/lame_client_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lame_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(lame_client_test PUBLIC cxx_std_14) target_include_directories(lame_client_test PRIVATE @@ -15642,6 +17883,15 @@ add_executable(large_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(large_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(large_metadata_test PUBLIC cxx_std_14) target_include_directories(large_metadata_test PRIVATE @@ -15680,6 +17930,14 @@ add_executable(latch_test src/core/lib/promise/trace.cc test/core/promise/latch_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(latch_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(latch_test PUBLIC cxx_std_14) target_include_directories(latch_test PRIVATE @@ -15720,6 +17978,15 @@ add_executable(lb_get_cpu_stats_test src/cpp/server/load_reporter/get_cpu_stats_windows.cc test/cpp/server/load_reporter/get_cpu_stats_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lb_get_cpu_stats_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(lb_get_cpu_stats_test PUBLIC cxx_std_14) target_include_directories(lb_get_cpu_stats_test PRIVATE @@ -15754,6 +18021,16 @@ add_executable(lb_load_data_store_test src/cpp/server/load_reporter/load_data_store.cc test/cpp/server/load_reporter/load_data_store_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lb_load_data_store_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(lb_load_data_store_test PUBLIC cxx_std_14) target_include_directories(lb_load_data_store_test PRIVATE @@ -15788,6 +18065,15 @@ if(gRPC_BUILD_TESTS) add_executable(load_config_test test/core/config/load_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(load_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(load_config_test PUBLIC cxx_std_14) target_include_directories(load_config_test PRIVATE @@ -15822,6 +18108,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) add_executable(lock_free_event_test test/core/event_engine/posix/lock_free_event_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lock_free_event_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(lock_free_event_test PUBLIC cxx_std_14) target_include_directories(lock_free_event_test PRIVATE @@ -15857,6 +18152,15 @@ if(gRPC_BUILD_TESTS) add_executable(log_test test/core/gpr/log_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(log_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(log_test PUBLIC cxx_std_14) target_include_directories(log_test PRIVATE @@ -15891,6 +18195,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(log_too_many_open_files_test test/core/event_engine/posix/log_too_many_open_files_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(log_too_many_open_files_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(log_too_many_open_files_test PUBLIC cxx_std_14) target_include_directories(log_too_many_open_files_test PRIVATE @@ -15927,6 +18240,14 @@ add_executable(loop_test src/core/lib/promise/trace.cc test/core/promise/loop_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(loop_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(loop_test PUBLIC cxx_std_14) target_include_directories(loop_test PRIVATE @@ -16007,6 +18328,14 @@ add_executable(map_pipe_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(map_pipe_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(map_pipe_test PUBLIC cxx_std_14) target_include_directories(map_pipe_test PRIVATE @@ -16088,6 +18417,15 @@ add_executable(matchers_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(matchers_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(matchers_test PUBLIC cxx_std_14) target_include_directories(matchers_test PRIVATE @@ -16122,6 +18460,14 @@ add_executable(max_concurrent_streams_policy_test src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc test/core/transport/chttp2/max_concurrent_streams_policy_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(max_concurrent_streams_policy_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(max_concurrent_streams_policy_test PUBLIC cxx_std_14) target_include_directories(max_concurrent_streams_policy_test PRIVATE @@ -16164,6 +18510,15 @@ add_executable(max_concurrent_streams_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(max_concurrent_streams_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(max_concurrent_streams_test PUBLIC cxx_std_14) target_include_directories(max_concurrent_streams_test PRIVATE @@ -16208,6 +18563,15 @@ add_executable(max_connection_age_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(max_connection_age_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(max_connection_age_test PUBLIC cxx_std_14) target_include_directories(max_connection_age_test PRIVATE @@ -16252,6 +18616,15 @@ add_executable(max_connection_idle_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(max_connection_idle_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(max_connection_idle_test PUBLIC cxx_std_14) target_include_directories(max_connection_idle_test PRIVATE @@ -16296,6 +18669,15 @@ add_executable(max_message_length_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(max_message_length_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(max_message_length_test PUBLIC cxx_std_14) target_include_directories(max_message_length_test PRIVATE @@ -16332,6 +18714,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) add_executable(memory_quota_stress_test test/core/resource_quota/memory_quota_stress_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(memory_quota_stress_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(memory_quota_stress_test PUBLIC cxx_std_14) target_include_directories(memory_quota_stress_test PRIVATE @@ -16366,6 +18757,15 @@ if(gRPC_BUILD_TESTS) add_executable(memory_quota_test test/core/resource_quota/memory_quota_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(memory_quota_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(memory_quota_test PUBLIC cxx_std_14) target_include_directories(memory_quota_test PRIVATE @@ -16416,6 +18816,16 @@ add_executable(message_allocator_end2end_test test/cpp/end2end/message_allocator_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(message_allocator_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(message_allocator_end2end_test PUBLIC cxx_std_14) target_include_directories(message_allocator_end2end_test PRIVATE @@ -16459,6 +18869,15 @@ add_executable(message_compress_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(message_compress_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(message_compress_test PUBLIC cxx_std_14) target_include_directories(message_compress_test PRIVATE @@ -16492,6 +18911,15 @@ if(gRPC_BUILD_TESTS) add_executable(message_size_service_config_test test/core/message_size/message_size_service_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(message_size_service_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(message_size_service_config_test PUBLIC cxx_std_14) target_include_directories(message_size_service_config_test PRIVATE @@ -16535,6 +18963,15 @@ add_executable(metadata_map_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(metadata_map_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(metadata_map_test PUBLIC cxx_std_14) target_include_directories(metadata_map_test PRIVATE @@ -16568,6 +19005,15 @@ if(gRPC_BUILD_TESTS) add_executable(minimal_stack_is_minimal_test test/core/channel/minimal_stack_is_minimal_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(minimal_stack_is_minimal_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(minimal_stack_is_minimal_test PUBLIC cxx_std_14) target_include_directories(minimal_stack_is_minimal_test PRIVATE @@ -16649,6 +19095,16 @@ add_executable(mock_stream_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/test/mock_stream_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(mock_stream_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(mock_stream_test PUBLIC cxx_std_14) target_include_directories(mock_stream_test PRIVATE @@ -16702,6 +19158,16 @@ add_executable(mock_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/mock_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(mock_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(mock_test PUBLIC cxx_std_14) target_include_directories(mock_test PRIVATE @@ -16736,6 +19202,14 @@ add_executable(mpsc_test src/core/lib/promise/activity.cc test/core/promise/mpsc_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(mpsc_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(mpsc_test PUBLIC cxx_std_14) target_include_directories(mpsc_test PRIVATE @@ -16773,6 +19247,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(mpscq_test test/core/gprpp/mpscq_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(mpscq_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(mpscq_test PUBLIC cxx_std_14) target_include_directories(mpscq_test PRIVATE @@ -16816,6 +19299,15 @@ add_executable(negative_deadline_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(negative_deadline_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(negative_deadline_test PUBLIC cxx_std_14) target_include_directories(negative_deadline_test PRIVATE @@ -16892,6 +19384,15 @@ add_executable(no_logging_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(no_logging_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(no_logging_test PUBLIC cxx_std_14) target_include_directories(no_logging_test PRIVATE @@ -16936,6 +19437,15 @@ add_executable(no_op_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(no_op_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(no_op_test PUBLIC cxx_std_14) target_include_directories(no_op_test PRIVATE @@ -16972,9 +19482,18 @@ add_executable(no_server_test test/core/end2end/cq_verifier.cc test/core/end2end/no_server_test.cc ) -target_compile_features(no_server_test PUBLIC cxx_std_14) -target_include_directories(no_server_test - PRIVATE +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(no_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(no_server_test PUBLIC cxx_std_14) +target_include_directories(no_server_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} @@ -17021,6 +19540,16 @@ add_executable(nonblocking_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/nonblocking_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(nonblocking_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(nonblocking_test PUBLIC cxx_std_14) target_include_directories(nonblocking_test PRIVATE @@ -17054,6 +19583,14 @@ if(gRPC_BUILD_TESTS) add_executable(notification_test test/core/gprpp/notification_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(notification_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(notification_test PUBLIC cxx_std_14) target_include_directories(notification_test PRIVATE @@ -17087,6 +19624,15 @@ if(gRPC_BUILD_TESTS) add_executable(num_external_connectivity_watchers_test test/core/surface/num_external_connectivity_watchers_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(num_external_connectivity_watchers_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(num_external_connectivity_watchers_test PUBLIC cxx_std_14) target_include_directories(num_external_connectivity_watchers_test PRIVATE @@ -17126,6 +19672,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/tests/client_test.cc test/core/event_engine/test_suite/tests/server_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(oracle_event_engine_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(oracle_event_engine_posix_test PUBLIC cxx_std_14) target_include_directories(oracle_event_engine_posix_test PRIVATE @@ -17169,6 +19724,16 @@ add_executable(orca_service_end2end_test src/cpp/server/orca/orca_service.cc test/cpp/end2end/orca_service_end2end_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(orca_service_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(orca_service_end2end_test PUBLIC cxx_std_14) target_include_directories(orca_service_end2end_test PRIVATE @@ -17202,6 +19767,15 @@ if(gRPC_BUILD_TESTS) add_executable(orphanable_test test/core/gprpp/orphanable_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(orphanable_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(orphanable_test PUBLIC cxx_std_14) target_include_directories(orphanable_test PRIVATE @@ -17270,6 +19844,15 @@ add_executable(out_of_bounds_bad_client_test test/core/bad_client/tests/out_of_bounds.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(out_of_bounds_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(out_of_bounds_bad_client_test PUBLIC cxx_std_14) target_include_directories(out_of_bounds_bad_client_test PRIVATE @@ -17303,6 +19886,15 @@ if(gRPC_BUILD_TESTS) add_executable(outlier_detection_lb_config_parser_test test/core/client_channel/lb_policy/outlier_detection_lb_config_parser_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(outlier_detection_lb_config_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(outlier_detection_lb_config_parser_test PUBLIC cxx_std_14) target_include_directories(outlier_detection_lb_config_parser_test PRIVATE @@ -17342,6 +19934,15 @@ add_executable(outlier_detection_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(outlier_detection_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(outlier_detection_test PUBLIC cxx_std_14) target_include_directories(outlier_detection_test PRIVATE @@ -17408,6 +20009,15 @@ if(gRPC_BUILD_TESTS) add_executable(parse_address_test test/core/address_utils/parse_address_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(parse_address_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(parse_address_test PUBLIC cxx_std_14) target_include_directories(parse_address_test PRIVATE @@ -17442,6 +20052,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(parse_address_with_named_scope_id_test test/core/address_utils/parse_address_with_named_scope_id_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(parse_address_with_named_scope_id_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(parse_address_with_named_scope_id_test PUBLIC cxx_std_14) target_include_directories(parse_address_with_named_scope_id_test PRIVATE @@ -17476,6 +20095,15 @@ if(gRPC_BUILD_TESTS) add_executable(parsed_metadata_test test/core/transport/parsed_metadata_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(parsed_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(parsed_metadata_test PUBLIC cxx_std_14) target_include_directories(parsed_metadata_test PRIVATE @@ -17523,6 +20151,15 @@ add_executable(parser_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(parser_test PUBLIC cxx_std_14) target_include_directories(parser_test PRIVATE @@ -17556,6 +20193,15 @@ if(gRPC_BUILD_TESTS) add_executable(party_test test/core/promise/party_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(party_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(party_test PUBLIC cxx_std_14) target_include_directories(party_test PRIVATE @@ -17598,6 +20244,15 @@ add_executable(payload_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(payload_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(payload_test PUBLIC cxx_std_14) target_include_directories(payload_test PRIVATE @@ -17633,6 +20288,15 @@ if(gRPC_BUILD_TESTS) add_executable(percent_encoding_test test/core/slice/percent_encoding_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(percent_encoding_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(percent_encoding_test PUBLIC cxx_std_14) target_include_directories(percent_encoding_test PRIVATE @@ -17704,6 +20368,14 @@ add_executable(periodic_update_test third_party/upb/upb/wire/eps_copy_input_stream.c third_party/upb/upb/wire/reader.c ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(periodic_update_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(periodic_update_test PUBLIC cxx_std_14) target_include_directories(periodic_update_test PRIVATE @@ -17748,6 +20420,15 @@ add_executable(pick_first_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(pick_first_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(pick_first_test PUBLIC cxx_std_14) target_include_directories(pick_first_test PRIVATE @@ -17792,6 +20473,15 @@ add_executable(ping_abuse_policy_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_abuse_policy_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_abuse_policy_test PUBLIC cxx_std_14) target_include_directories(ping_abuse_policy_test PRIVATE @@ -17825,6 +20515,15 @@ if(gRPC_BUILD_TESTS) add_executable(ping_callbacks_test test/core/transport/chttp2/ping_callbacks_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_callbacks_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_callbacks_test PUBLIC cxx_std_14) target_include_directories(ping_callbacks_test PRIVATE @@ -17868,6 +20567,15 @@ add_executable(ping_configuration_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_configuration_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_configuration_test PUBLIC cxx_std_14) target_include_directories(ping_configuration_test PRIVATE @@ -17910,6 +20618,15 @@ add_executable(ping_pong_streaming_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_pong_streaming_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_pong_streaming_test PUBLIC cxx_std_14) target_include_directories(ping_pong_streaming_test PRIVATE @@ -17955,6 +20672,15 @@ add_executable(ping_rate_policy_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_rate_policy_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_rate_policy_test PUBLIC cxx_std_14) target_include_directories(ping_rate_policy_test PRIVATE @@ -17997,6 +20723,15 @@ add_executable(ping_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ping_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ping_test PUBLIC cxx_std_14) target_include_directories(ping_test PRIVATE @@ -18032,6 +20767,15 @@ if(gRPC_BUILD_TESTS) add_executable(pipe_test test/core/promise/pipe_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(pipe_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(pipe_test PUBLIC cxx_std_14) target_include_directories(pipe_test PRIVATE @@ -18065,6 +20809,14 @@ if(gRPC_BUILD_TESTS) add_executable(poll_test test/core/promise/poll_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(poll_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(poll_test PUBLIC cxx_std_14) target_include_directories(poll_test PRIVATE @@ -18115,6 +20867,16 @@ add_executable(port_sharing_end2end_test test/cpp/end2end/port_sharing_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(port_sharing_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(port_sharing_end2end_test PUBLIC cxx_std_14) target_include_directories(port_sharing_end2end_test PRIVATE @@ -18153,6 +20915,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/event_engine_test_framework.cc test/core/event_engine/test_suite/posix/oracle_event_engine_posix.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(posix_endpoint_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(posix_endpoint_test PUBLIC cxx_std_14) target_include_directories(posix_endpoint_test PRIVATE @@ -18188,6 +20959,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(posix_engine_listener_utils_test test/core/event_engine/posix/posix_engine_listener_utils_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(posix_engine_listener_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(posix_engine_listener_utils_test PUBLIC cxx_std_14) target_include_directories(posix_engine_listener_utils_test PRIVATE @@ -18226,6 +21006,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/event_engine_test_framework.cc test/core/event_engine/test_suite/posix/oracle_event_engine_posix.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(posix_event_engine_connect_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(posix_event_engine_connect_test PUBLIC cxx_std_14) target_include_directories(posix_event_engine_connect_test PRIVATE @@ -18268,6 +21057,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/cpp/util/get_grpc_test_runfile_dir.cc test/cpp/util/windows/manifest_file.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(posix_event_engine_native_dns_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(posix_event_engine_native_dns_test PUBLIC cxx_std_14) target_include_directories(posix_event_engine_native_dns_test PRIVATE @@ -18313,6 +21112,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/cpp/util/get_grpc_test_runfile_dir.cc test/cpp/util/windows/manifest_file.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(posix_event_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(posix_event_engine_test PUBLIC cxx_std_14) target_include_directories(posix_event_engine_test PRIVATE @@ -18388,6 +21197,16 @@ add_executable(pre_stop_hook_server_test test/cpp/interop/pre_stop_hook_server_test.cc test/cpp/interop/xds_interop_server_lib.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(pre_stop_hook_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(pre_stop_hook_server_test PUBLIC cxx_std_14) target_include_directories(pre_stop_hook_server_test PRIVATE @@ -18424,6 +21243,14 @@ if(gRPC_BUILD_TESTS) add_executable(prioritized_race_test test/core/promise/prioritized_race_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(prioritized_race_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(prioritized_race_test PUBLIC cxx_std_14) target_include_directories(prioritized_race_test PRIVATE @@ -18458,6 +21285,15 @@ add_executable(promise_endpoint_test src/core/lib/transport/promise_endpoint.cc test/core/transport/promise_endpoint_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(promise_endpoint_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(promise_endpoint_test PUBLIC cxx_std_14) target_include_directories(promise_endpoint_test PRIVATE @@ -18491,6 +21327,14 @@ if(gRPC_BUILD_TESTS) add_executable(promise_factory_test test/core/promise/promise_factory_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(promise_factory_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(promise_factory_test PUBLIC cxx_std_14) target_include_directories(promise_factory_test PRIVATE @@ -18526,6 +21370,14 @@ if(gRPC_BUILD_TESTS) add_executable(promise_map_test test/core/promise/map_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(promise_map_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(promise_map_test PUBLIC cxx_std_14) target_include_directories(promise_map_test PRIVATE @@ -18563,6 +21415,14 @@ add_executable(promise_mutex_test src/core/lib/promise/trace.cc test/core/promise/promise_mutex_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(promise_mutex_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(promise_mutex_test PUBLIC cxx_std_14) target_include_directories(promise_mutex_test PRIVATE @@ -18599,6 +21459,14 @@ if(gRPC_BUILD_TESTS) add_executable(promise_test test/core/promise/promise_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(promise_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(promise_test PUBLIC cxx_std_14) target_include_directories(promise_test PRIVATE @@ -18633,6 +21501,16 @@ if(gRPC_BUILD_TESTS) add_executable(proto_buffer_reader_test test/cpp/util/proto_buffer_reader_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(proto_buffer_reader_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(proto_buffer_reader_test PUBLIC cxx_std_14) target_include_directories(proto_buffer_reader_test PRIVATE @@ -18666,6 +21544,16 @@ if(gRPC_BUILD_TESTS) add_executable(proto_buffer_writer_test test/cpp/util/proto_buffer_writer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(proto_buffer_writer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(proto_buffer_writer_test PUBLIC cxx_std_14) target_include_directories(proto_buffer_writer_test PRIVATE @@ -18721,6 +21609,16 @@ add_executable(proto_server_reflection_test test/cpp/end2end/test_service_impl.cc test/cpp/util/proto_reflection_descriptor_database.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(proto_server_reflection_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(proto_server_reflection_test PUBLIC cxx_std_14) target_include_directories(proto_server_reflection_test PRIVATE @@ -18755,6 +21653,16 @@ if(gRPC_BUILD_TESTS) add_executable(proto_utils_test test/cpp/codegen/proto_utils_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(proto_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(proto_utils_test PUBLIC cxx_std_14) target_include_directories(proto_utils_test PRIVATE @@ -18798,6 +21706,15 @@ add_executable(proxy_auth_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(proxy_auth_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(proxy_auth_test PUBLIC cxx_std_14) target_include_directories(proxy_auth_test PRIVATE @@ -18874,6 +21791,16 @@ add_executable(qps_json_driver test/cpp/qps/server_sync.cc test/cpp/qps/usage_timer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(qps_json_driver + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(qps_json_driver PUBLIC cxx_std_14) target_include_directories(qps_json_driver PRIVATE @@ -18936,11 +21863,21 @@ add_executable(qps_worker test/cpp/qps/usage_timer.cc test/cpp/qps/worker.cc ) -target_compile_features(qps_worker PUBLIC cxx_std_14) -target_include_directories(qps_worker - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(qps_worker + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(qps_worker PUBLIC cxx_std_14) +target_include_directories(qps_worker + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} ${_gRPC_RE2_INCLUDE_DIR} ${_gRPC_SSL_INCLUDE_DIR} @@ -18965,6 +21902,14 @@ if(gRPC_BUILD_TESTS) add_executable(query_extensions_test test/core/event_engine/query_extensions_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(query_extensions_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(query_extensions_test PUBLIC cxx_std_14) target_include_directories(query_extensions_test PRIVATE @@ -18999,6 +21944,14 @@ if(gRPC_BUILD_TESTS) add_executable(race_test test/core/promise/race_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(race_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(race_test PUBLIC cxx_std_14) target_include_directories(race_test PRIVATE @@ -19089,6 +22042,16 @@ add_executable(raw_end2end_test test/cpp/end2end/raw_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(raw_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(raw_end2end_test PUBLIC cxx_std_14) target_include_directories(raw_end2end_test PRIVATE @@ -19122,6 +22085,15 @@ if(gRPC_BUILD_TESTS) add_executable(rbac_service_config_parser_test test/core/ext/filters/rbac/rbac_service_config_parser_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(rbac_service_config_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(rbac_service_config_parser_test PUBLIC cxx_std_14) target_include_directories(rbac_service_config_parser_test PRIVATE @@ -19165,6 +22137,15 @@ add_executable(rbac_translator_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(rbac_translator_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(rbac_translator_test PUBLIC cxx_std_14) target_include_directories(rbac_translator_test PRIVATE @@ -19199,6 +22180,15 @@ if(gRPC_BUILD_TESTS) add_executable(ref_counted_ptr_test test/core/gprpp/ref_counted_ptr_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ref_counted_ptr_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ref_counted_ptr_test PUBLIC cxx_std_14) target_include_directories(ref_counted_ptr_test PRIVATE @@ -19232,6 +22222,15 @@ if(gRPC_BUILD_TESTS) add_executable(ref_counted_test test/core/gprpp/ref_counted_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ref_counted_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ref_counted_test PUBLIC cxx_std_14) target_include_directories(ref_counted_test PRIVATE @@ -19274,6 +22273,15 @@ add_executable(registered_call_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(registered_call_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(registered_call_test PUBLIC cxx_std_14) target_include_directories(registered_call_test PRIVATE @@ -19310,6 +22318,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(remove_stream_from_stalled_lists_test test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(remove_stream_from_stalled_lists_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(remove_stream_from_stalled_lists_test PUBLIC cxx_std_14) target_include_directories(remove_stream_from_stalled_lists_test PRIVATE @@ -19353,6 +22370,15 @@ add_executable(request_with_flags_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(request_with_flags_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(request_with_flags_test PUBLIC cxx_std_14) target_include_directories(request_with_flags_test PRIVATE @@ -19397,6 +22423,15 @@ add_executable(request_with_payload_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(request_with_payload_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(request_with_payload_test PUBLIC cxx_std_14) target_include_directories(request_with_payload_test PRIVATE @@ -19443,6 +22478,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resolve_address_using_ares_resolver_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(resolve_address_using_ares_resolver_posix_test PUBLIC cxx_std_14) target_include_directories(resolve_address_using_ares_resolver_posix_test PRIVATE @@ -19488,6 +22532,15 @@ add_executable(resolve_address_using_ares_resolver_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resolve_address_using_ares_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(resolve_address_using_ares_resolver_test PUBLIC cxx_std_14) target_include_directories(resolve_address_using_ares_resolver_test PRIVATE @@ -19533,6 +22586,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resolve_address_using_native_resolver_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(resolve_address_using_native_resolver_posix_test PUBLIC cxx_std_14) target_include_directories(resolve_address_using_native_resolver_posix_test PRIVATE @@ -19578,6 +22640,15 @@ add_executable(resolve_address_using_native_resolver_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resolve_address_using_native_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(resolve_address_using_native_resolver_test PUBLIC cxx_std_14) target_include_directories(resolve_address_using_native_resolver_test PRIVATE @@ -19628,6 +22699,16 @@ add_executable(resource_quota_end2end_stress_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/resource_quota_end2end_stress_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resource_quota_end2end_stress_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(resource_quota_end2end_stress_test PUBLIC cxx_std_14) target_include_directories(resource_quota_end2end_stress_test PRIVATE @@ -19670,6 +22751,15 @@ add_executable(resource_quota_server_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resource_quota_server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(resource_quota_server_test PUBLIC cxx_std_14) target_include_directories(resource_quota_server_test PRIVATE @@ -19705,6 +22795,15 @@ if(gRPC_BUILD_TESTS) add_executable(resource_quota_test test/core/resource_quota/resource_quota_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(resource_quota_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(resource_quota_test PUBLIC cxx_std_14) target_include_directories(resource_quota_test PRIVATE @@ -19747,6 +22846,15 @@ add_executable(retry_cancel_after_first_attempt_starts_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_cancel_after_first_attempt_starts_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_cancel_after_first_attempt_starts_test PUBLIC cxx_std_14) target_include_directories(retry_cancel_after_first_attempt_starts_test PRIVATE @@ -19791,6 +22899,15 @@ add_executable(retry_cancel_during_delay_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_cancel_during_delay_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_cancel_during_delay_test PUBLIC cxx_std_14) target_include_directories(retry_cancel_during_delay_test PRIVATE @@ -19835,6 +22952,15 @@ add_executable(retry_cancel_with_multiple_send_batches_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_cancel_with_multiple_send_batches_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_cancel_with_multiple_send_batches_test PUBLIC cxx_std_14) target_include_directories(retry_cancel_with_multiple_send_batches_test PRIVATE @@ -19879,6 +23005,15 @@ add_executable(retry_cancellation_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_cancellation_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_cancellation_test PUBLIC cxx_std_14) target_include_directories(retry_cancellation_test PRIVATE @@ -19923,6 +23058,15 @@ add_executable(retry_disabled_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_disabled_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_disabled_test PUBLIC cxx_std_14) target_include_directories(retry_disabled_test PRIVATE @@ -19967,6 +23111,15 @@ add_executable(retry_exceeds_buffer_size_in_delay_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_exceeds_buffer_size_in_delay_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_exceeds_buffer_size_in_delay_test PUBLIC cxx_std_14) target_include_directories(retry_exceeds_buffer_size_in_delay_test PRIVATE @@ -20011,6 +23164,15 @@ add_executable(retry_exceeds_buffer_size_in_initial_batch_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_exceeds_buffer_size_in_initial_batch_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_exceeds_buffer_size_in_initial_batch_test PUBLIC cxx_std_14) target_include_directories(retry_exceeds_buffer_size_in_initial_batch_test PRIVATE @@ -20055,6 +23217,15 @@ add_executable(retry_exceeds_buffer_size_in_subsequent_batch_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_exceeds_buffer_size_in_subsequent_batch_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_exceeds_buffer_size_in_subsequent_batch_test PUBLIC cxx_std_14) target_include_directories(retry_exceeds_buffer_size_in_subsequent_batch_test PRIVATE @@ -20099,6 +23270,15 @@ add_executable(retry_lb_drop_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_lb_drop_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_lb_drop_test PUBLIC cxx_std_14) target_include_directories(retry_lb_drop_test PRIVATE @@ -20143,6 +23323,15 @@ add_executable(retry_lb_fail_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_lb_fail_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_lb_fail_test PUBLIC cxx_std_14) target_include_directories(retry_lb_fail_test PRIVATE @@ -20187,6 +23376,15 @@ add_executable(retry_non_retriable_status_before_trailers_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_non_retriable_status_before_trailers_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_non_retriable_status_before_trailers_test PUBLIC cxx_std_14) target_include_directories(retry_non_retriable_status_before_trailers_test PRIVATE @@ -20231,6 +23429,15 @@ add_executable(retry_non_retriable_status_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_non_retriable_status_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_non_retriable_status_test PUBLIC cxx_std_14) target_include_directories(retry_non_retriable_status_test PRIVATE @@ -20275,6 +23482,15 @@ add_executable(retry_per_attempt_recv_timeout_on_last_attempt_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_per_attempt_recv_timeout_on_last_attempt_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_per_attempt_recv_timeout_on_last_attempt_test PUBLIC cxx_std_14) target_include_directories(retry_per_attempt_recv_timeout_on_last_attempt_test PRIVATE @@ -20319,6 +23535,15 @@ add_executable(retry_per_attempt_recv_timeout_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_per_attempt_recv_timeout_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_per_attempt_recv_timeout_test PUBLIC cxx_std_14) target_include_directories(retry_per_attempt_recv_timeout_test PRIVATE @@ -20363,6 +23588,15 @@ add_executable(retry_recv_initial_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_recv_initial_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_recv_initial_metadata_test PUBLIC cxx_std_14) target_include_directories(retry_recv_initial_metadata_test PRIVATE @@ -20407,6 +23641,15 @@ add_executable(retry_recv_message_replay_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_recv_message_replay_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_recv_message_replay_test PUBLIC cxx_std_14) target_include_directories(retry_recv_message_replay_test PRIVATE @@ -20451,6 +23694,15 @@ add_executable(retry_recv_message_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_recv_message_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_recv_message_test PUBLIC cxx_std_14) target_include_directories(retry_recv_message_test PRIVATE @@ -20495,6 +23747,15 @@ add_executable(retry_recv_trailing_metadata_error_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_recv_trailing_metadata_error_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_recv_trailing_metadata_error_test PUBLIC cxx_std_14) target_include_directories(retry_recv_trailing_metadata_error_test PRIVATE @@ -20539,6 +23800,15 @@ add_executable(retry_send_initial_metadata_refs_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_send_initial_metadata_refs_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_send_initial_metadata_refs_test PUBLIC cxx_std_14) target_include_directories(retry_send_initial_metadata_refs_test PRIVATE @@ -20583,6 +23853,15 @@ add_executable(retry_send_op_fails_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_send_op_fails_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_send_op_fails_test PUBLIC cxx_std_14) target_include_directories(retry_send_op_fails_test PRIVATE @@ -20627,6 +23906,15 @@ add_executable(retry_send_recv_batch_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_send_recv_batch_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_send_recv_batch_test PUBLIC cxx_std_14) target_include_directories(retry_send_recv_batch_test PRIVATE @@ -20671,6 +23959,15 @@ add_executable(retry_server_pushback_delay_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_server_pushback_delay_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_server_pushback_delay_test PUBLIC cxx_std_14) target_include_directories(retry_server_pushback_delay_test PRIVATE @@ -20715,6 +24012,15 @@ add_executable(retry_server_pushback_disabled_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_server_pushback_disabled_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_server_pushback_disabled_test PUBLIC cxx_std_14) target_include_directories(retry_server_pushback_disabled_test PRIVATE @@ -20750,6 +24056,15 @@ if(gRPC_BUILD_TESTS) add_executable(retry_service_config_test test/core/client_channel/retry_service_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_service_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_service_config_test PUBLIC cxx_std_14) target_include_directories(retry_service_config_test PRIVATE @@ -20792,6 +24107,15 @@ add_executable(retry_streaming_after_commit_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_streaming_after_commit_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_streaming_after_commit_test PUBLIC cxx_std_14) target_include_directories(retry_streaming_after_commit_test PRIVATE @@ -20836,6 +24160,15 @@ add_executable(retry_streaming_succeeds_before_replay_finished_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_streaming_succeeds_before_replay_finished_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_streaming_succeeds_before_replay_finished_test PUBLIC cxx_std_14) target_include_directories(retry_streaming_succeeds_before_replay_finished_test PRIVATE @@ -20880,6 +24213,15 @@ add_executable(retry_streaming_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_streaming_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_streaming_test PUBLIC cxx_std_14) target_include_directories(retry_streaming_test PRIVATE @@ -20924,6 +24266,15 @@ add_executable(retry_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_test PUBLIC cxx_std_14) target_include_directories(retry_test PRIVATE @@ -20959,6 +24310,15 @@ if(gRPC_BUILD_TESTS) add_executable(retry_throttle_test test/core/client_channel/retry_throttle_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_throttle_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_throttle_test PUBLIC cxx_std_14) target_include_directories(retry_throttle_test PRIVATE @@ -21001,6 +24361,15 @@ add_executable(retry_throttled_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_throttled_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_throttled_test PUBLIC cxx_std_14) target_include_directories(retry_throttled_test PRIVATE @@ -21045,6 +24414,15 @@ add_executable(retry_too_many_attempts_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_too_many_attempts_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_too_many_attempts_test PUBLIC cxx_std_14) target_include_directories(retry_too_many_attempts_test PRIVATE @@ -21089,6 +24467,15 @@ add_executable(retry_transparent_goaway_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_transparent_goaway_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_transparent_goaway_test PUBLIC cxx_std_14) target_include_directories(retry_transparent_goaway_test PRIVATE @@ -21133,6 +24520,15 @@ add_executable(retry_transparent_max_concurrent_streams_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_transparent_max_concurrent_streams_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_transparent_max_concurrent_streams_test PUBLIC cxx_std_14) target_include_directories(retry_transparent_max_concurrent_streams_test PRIVATE @@ -21177,6 +24573,15 @@ add_executable(retry_transparent_not_sent_on_wire_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_transparent_not_sent_on_wire_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_transparent_not_sent_on_wire_test PUBLIC cxx_std_14) target_include_directories(retry_transparent_not_sent_on_wire_test PRIVATE @@ -21221,6 +24626,15 @@ add_executable(retry_unref_before_finish_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_unref_before_finish_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_unref_before_finish_test PUBLIC cxx_std_14) target_include_directories(retry_unref_before_finish_test PRIVATE @@ -21265,6 +24679,15 @@ add_executable(retry_unref_before_recv_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(retry_unref_before_recv_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(retry_unref_before_recv_test PUBLIC cxx_std_14) target_include_directories(retry_unref_before_recv_test PRIVATE @@ -21306,6 +24729,15 @@ add_executable(ring_hash_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ring_hash_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(ring_hash_test PUBLIC cxx_std_14) target_include_directories(ring_hash_test PRIVATE @@ -21367,6 +24799,16 @@ add_executable(rls_end2end_test test/cpp/end2end/rls_server.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(rls_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(rls_end2end_test PUBLIC cxx_std_14) target_include_directories(rls_end2end_test PRIVATE @@ -21401,6 +24843,15 @@ if(gRPC_BUILD_TESTS) add_executable(rls_lb_config_parser_test test/core/client_channel/lb_policy/rls_lb_config_parser_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(rls_lb_config_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(rls_lb_config_parser_test PUBLIC cxx_std_14) target_include_directories(rls_lb_config_parser_test PRIVATE @@ -21440,6 +24891,15 @@ add_executable(round_robin_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(round_robin_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(round_robin_test PUBLIC cxx_std_14) target_include_directories(round_robin_test PRIVATE @@ -21474,6 +24934,16 @@ if(gRPC_BUILD_TESTS) add_executable(secure_auth_context_test test/cpp/common/secure_auth_context_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(secure_auth_context_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(secure_auth_context_test PUBLIC cxx_std_14) target_include_directories(secure_auth_context_test PRIVATE @@ -21507,6 +24977,15 @@ if(gRPC_BUILD_TESTS) add_executable(secure_channel_create_test test/core/surface/secure_channel_create_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(secure_channel_create_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(secure_channel_create_test PUBLIC cxx_std_14) target_include_directories(secure_channel_create_test PRIVATE @@ -21551,6 +25030,15 @@ add_executable(secure_endpoint_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(secure_endpoint_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(secure_endpoint_test PUBLIC cxx_std_14) target_include_directories(secure_endpoint_test PRIVATE @@ -21594,6 +25082,15 @@ add_executable(security_connector_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(security_connector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(security_connector_test PUBLIC cxx_std_14) target_include_directories(security_connector_test PRIVATE @@ -21629,6 +25126,14 @@ add_executable(seq_test src/core/lib/promise/trace.cc test/core/promise/seq_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(seq_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(seq_test PUBLIC cxx_std_14) target_include_directories(seq_test PRIVATE @@ -21664,6 +25169,15 @@ if(gRPC_BUILD_TESTS) add_executable(sequential_connectivity_test test/core/surface/sequential_connectivity_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(sequential_connectivity_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(sequential_connectivity_test PUBLIC cxx_std_14) target_include_directories(sequential_connectivity_test PRIVATE @@ -21718,6 +25232,16 @@ add_executable(server_builder_plugin_test test/cpp/end2end/server_builder_plugin_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_builder_plugin_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_builder_plugin_test PUBLIC cxx_std_14) target_include_directories(server_builder_plugin_test PRIVATE @@ -21778,6 +25302,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/tracer_util.cc test/cpp/server/server_builder_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_builder_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(server_builder_test PUBLIC cxx_std_14) target_include_directories(server_builder_test PRIVATE @@ -21840,6 +25374,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/tracer_util.cc test/cpp/server/server_builder_with_socket_mutator_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_builder_with_socket_mutator_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(server_builder_with_socket_mutator_test PUBLIC cxx_std_14) target_include_directories(server_builder_with_socket_mutator_test PRIVATE @@ -21875,6 +25419,15 @@ if(gRPC_BUILD_TESTS) add_executable(server_call_tracer_factory_test test/core/channel/server_call_tracer_factory_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_call_tracer_factory_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_call_tracer_factory_test PUBLIC cxx_std_14) target_include_directories(server_call_tracer_factory_test PRIVATE @@ -21908,6 +25461,15 @@ if(gRPC_BUILD_TESTS) add_executable(server_chttp2_test test/core/surface/server_chttp2_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_chttp2_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_chttp2_test PUBLIC cxx_std_14) target_include_directories(server_chttp2_test PRIVATE @@ -21941,6 +25503,15 @@ if(gRPC_BUILD_TESTS) add_executable(server_config_selector_test test/core/server_config_selector/server_config_selector_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_config_selector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_config_selector_test PUBLIC cxx_std_14) target_include_directories(server_config_selector_test PRIVATE @@ -21974,6 +25545,16 @@ if(gRPC_BUILD_TESTS) add_executable(server_context_test_spouse_test test/cpp/test/server_context_test_spouse_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_context_test_spouse_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_context_test_spouse_test PUBLIC cxx_std_14) target_include_directories(server_context_test_spouse_test PRIVATE @@ -22023,6 +25604,16 @@ add_executable(server_early_return_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/server_early_return_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_early_return_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_early_return_test PUBLIC cxx_std_14) target_include_directories(server_early_return_test PRIVATE @@ -22065,6 +25656,15 @@ add_executable(server_finishes_request_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_finishes_request_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_finishes_request_test PUBLIC cxx_std_14) target_include_directories(server_finishes_request_test PRIVATE @@ -22118,6 +25718,16 @@ add_executable(server_interceptors_end2end_test test/cpp/end2end/server_interceptors_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_interceptors_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_interceptors_end2end_test PUBLIC cxx_std_14) target_include_directories(server_interceptors_end2end_test PRIVATE @@ -22153,6 +25763,15 @@ add_executable(server_registered_method_bad_client_test test/core/bad_client/tests/server_registered_method.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_registered_method_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_registered_method_bad_client_test PUBLIC cxx_std_14) target_include_directories(server_registered_method_bad_client_test PRIVATE @@ -22213,6 +25832,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/tracer_util.cc test/cpp/server/server_request_call_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_request_call_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(server_request_call_test PUBLIC cxx_std_14) target_include_directories(server_request_call_test PRIVATE @@ -22250,6 +25879,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/handshake/server_ssl.cc test/core/handshake/server_ssl_common.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_ssl_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(server_ssl_test PUBLIC cxx_std_14) target_include_directories(server_ssl_test PRIVATE @@ -22293,6 +25931,15 @@ add_executable(server_streaming_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_streaming_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_streaming_test PUBLIC cxx_std_14) target_include_directories(server_streaming_test PRIVATE @@ -22328,6 +25975,15 @@ if(gRPC_BUILD_TESTS) add_executable(server_test test/core/surface/server_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(server_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(server_test PUBLIC cxx_std_14) target_include_directories(server_test PRIVATE @@ -22382,6 +26038,16 @@ add_executable(service_config_end2end_test test/cpp/end2end/service_config_end2end_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(service_config_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(service_config_end2end_test PUBLIC cxx_std_14) target_include_directories(service_config_end2end_test PRIVATE @@ -22415,6 +26081,15 @@ if(gRPC_BUILD_TESTS) add_executable(service_config_test test/core/service_config/service_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(service_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(service_config_test PUBLIC cxx_std_14) target_include_directories(service_config_test PRIVATE @@ -22458,6 +26133,15 @@ add_executable(settings_timeout_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(settings_timeout_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(settings_timeout_test PUBLIC cxx_std_14) target_include_directories(settings_timeout_test PRIVATE @@ -22500,6 +26184,15 @@ add_executable(shutdown_finishes_calls_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(shutdown_finishes_calls_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(shutdown_finishes_calls_test PUBLIC cxx_std_14) target_include_directories(shutdown_finishes_calls_test PRIVATE @@ -22544,6 +26237,15 @@ add_executable(shutdown_finishes_tags_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(shutdown_finishes_tags_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(shutdown_finishes_tags_test PUBLIC cxx_std_14) target_include_directories(shutdown_finishes_tags_test PRIVATE @@ -22599,6 +26301,16 @@ add_executable(shutdown_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/shutdown_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(shutdown_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(shutdown_test PUBLIC cxx_std_14) target_include_directories(shutdown_test PRIVATE @@ -22641,6 +26353,15 @@ add_executable(simple_delayed_request_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(simple_delayed_request_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(simple_delayed_request_test PUBLIC cxx_std_14) target_include_directories(simple_delayed_request_test PRIVATE @@ -22685,6 +26406,15 @@ add_executable(simple_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(simple_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(simple_metadata_test PUBLIC cxx_std_14) target_include_directories(simple_metadata_test PRIVATE @@ -22722,6 +26452,15 @@ add_executable(simple_request_bad_client_test test/core/bad_client/tests/simple_request.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(simple_request_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(simple_request_bad_client_test PUBLIC cxx_std_14) target_include_directories(simple_request_bad_client_test PRIVATE @@ -22764,6 +26503,15 @@ add_executable(simple_request_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(simple_request_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(simple_request_test PUBLIC cxx_std_14) target_include_directories(simple_request_test PRIVATE @@ -22799,6 +26547,14 @@ if(gRPC_BUILD_TESTS) add_executable(single_set_ptr_test test/core/gprpp/single_set_ptr_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(single_set_ptr_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(single_set_ptr_test PUBLIC cxx_std_14) target_include_directories(single_set_ptr_test PRIVATE @@ -22832,6 +26588,15 @@ if(gRPC_BUILD_TESTS) add_executable(sleep_test test/core/promise/sleep_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(sleep_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(sleep_test PUBLIC cxx_std_14) target_include_directories(sleep_test PRIVATE @@ -22869,6 +26634,14 @@ add_executable(slice_string_helpers_test src/core/lib/slice/slice_string_helpers.cc test/core/slice/slice_string_helpers_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(slice_string_helpers_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(slice_string_helpers_test PUBLIC cxx_std_14) target_include_directories(slice_string_helpers_test PRIVATE @@ -22904,6 +26677,15 @@ if(gRPC_BUILD_TESTS) add_executable(smoke_test test/core/event_engine/smoke_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(smoke_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(smoke_test PUBLIC cxx_std_14) target_include_directories(smoke_test PRIVATE @@ -22937,6 +26719,15 @@ if(gRPC_BUILD_TESTS) add_executable(sockaddr_resolver_test test/core/client_channel/resolvers/sockaddr_resolver_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(sockaddr_resolver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(sockaddr_resolver_test PUBLIC cxx_std_14) target_include_directories(sockaddr_resolver_test PRIVATE @@ -22970,6 +26761,15 @@ if(gRPC_BUILD_TESTS) add_executable(sockaddr_utils_test test/core/address_utils/sockaddr_utils_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(sockaddr_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(sockaddr_utils_test PUBLIC cxx_std_14) target_include_directories(sockaddr_utils_test PRIVATE @@ -23014,6 +26814,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(socket_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(socket_utils_test PUBLIC cxx_std_14) target_include_directories(socket_utils_test PRIVATE @@ -23080,6 +26889,15 @@ if(gRPC_BUILD_TESTS) add_executable(spinlock_test test/core/gpr/spinlock_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(spinlock_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(spinlock_test PUBLIC cxx_std_14) target_include_directories(spinlock_test PRIVATE @@ -23115,6 +26933,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/tsi/ssl_transport_security_test.cc test/core/tsi/transport_security_test_lib.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ssl_transport_security_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(ssl_transport_security_test PUBLIC cxx_std_14) target_include_directories(ssl_transport_security_test PRIVATE @@ -23150,6 +26977,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(ssl_transport_security_utils_test test/core/tsi/ssl_transport_security_utils_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(ssl_transport_security_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(ssl_transport_security_utils_test PUBLIC cxx_std_14) target_include_directories(ssl_transport_security_utils_test PRIVATE @@ -23185,6 +27021,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(stack_tracer_test test/core/util/stack_tracer_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(stack_tracer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(stack_tracer_test PUBLIC cxx_std_14) target_include_directories(stack_tracer_test PRIVATE @@ -23219,6 +27064,15 @@ if(gRPC_BUILD_TESTS) add_executable(stat_test test/core/gprpp/stat_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(stat_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(stat_test PUBLIC cxx_std_14) target_include_directories(stat_test PRIVATE @@ -23253,6 +27107,14 @@ add_executable(static_stride_scheduler_test src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc test/core/client_channel/lb_policy/static_stride_scheduler_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(static_stride_scheduler_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(static_stride_scheduler_test PUBLIC cxx_std_14) target_include_directories(static_stride_scheduler_test PRIVATE @@ -23287,6 +27149,15 @@ if(gRPC_BUILD_TESTS) add_executable(stats_test test/core/debug/stats_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(stats_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(stats_test PUBLIC cxx_std_14) target_include_directories(stats_test PRIVATE @@ -23330,6 +27201,15 @@ add_executable(status_conversion_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(status_conversion_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(status_conversion_test PUBLIC cxx_std_14) target_include_directories(status_conversion_test PRIVATE @@ -23363,6 +27243,14 @@ if(gRPC_BUILD_TESTS) add_executable(status_flag_test test/core/promise/status_flag_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(status_flag_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(status_flag_test PUBLIC cxx_std_14) target_include_directories(status_flag_test PRIVATE @@ -23397,6 +27285,15 @@ if(gRPC_BUILD_TESTS) add_executable(status_helper_test test/core/gprpp/status_helper_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(status_helper_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(status_helper_test PUBLIC cxx_std_14) target_include_directories(status_helper_test PRIVATE @@ -23430,6 +27327,15 @@ if(gRPC_BUILD_TESTS) add_executable(status_util_test test/core/channel/status_util_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(status_util_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(status_util_test PUBLIC cxx_std_14) target_include_directories(status_util_test PRIVATE @@ -23463,6 +27369,15 @@ if(gRPC_BUILD_TESTS) add_executable(stream_leak_with_queued_flow_control_update_test test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(stream_leak_with_queued_flow_control_update_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(stream_leak_with_queued_flow_control_update_test PUBLIC cxx_std_14) target_include_directories(stream_leak_with_queued_flow_control_update_test PRIVATE @@ -23505,6 +27420,15 @@ add_executable(streaming_error_response_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(streaming_error_response_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(streaming_error_response_test PUBLIC cxx_std_14) target_include_directories(streaming_error_response_test PRIVATE @@ -23561,6 +27485,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/streaming_throughput_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(streaming_throughput_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(streaming_throughput_test PUBLIC cxx_std_14) target_include_directories(streaming_throughput_test PRIVATE @@ -23606,6 +27540,15 @@ add_executable(streams_not_seen_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(streams_not_seen_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(streams_not_seen_test PUBLIC cxx_std_14) target_include_directories(streams_not_seen_test PRIVATE @@ -23639,6 +27582,16 @@ if(gRPC_BUILD_TESTS) add_executable(string_ref_test test/cpp/util/string_ref_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(string_ref_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(string_ref_test PUBLIC cxx_std_14) target_include_directories(string_ref_test PRIVATE @@ -23673,6 +27626,15 @@ if(gRPC_BUILD_TESTS) add_executable(string_test test/core/gpr/string_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(string_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(string_test PUBLIC cxx_std_14) target_include_directories(string_test PRIVATE @@ -23706,6 +27668,14 @@ if(gRPC_BUILD_TESTS) add_executable(switch_test test/core/promise/switch_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(switch_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(switch_test PUBLIC cxx_std_14) target_include_directories(switch_test PRIVATE @@ -23741,6 +27711,15 @@ if(gRPC_BUILD_TESTS) add_executable(sync_test test/core/gpr/sync_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(sync_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(sync_test PUBLIC cxx_std_14) target_include_directories(sync_test PRIVATE @@ -23784,6 +27763,15 @@ add_executable(system_roots_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(system_roots_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(system_roots_test PUBLIC cxx_std_14) target_include_directories(system_roots_test PRIVATE @@ -23862,6 +27850,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tcp_client_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(tcp_client_posix_test PUBLIC cxx_std_14) target_include_directories(tcp_client_posix_test PRIVATE @@ -23897,6 +27894,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(tcp_posix_socket_utils_test test/core/event_engine/posix/tcp_posix_socket_utils_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tcp_posix_socket_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(tcp_posix_socket_utils_test PUBLIC cxx_std_14) target_include_directories(tcp_posix_socket_utils_test PRIVATE @@ -23943,6 +27949,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tcp_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(tcp_posix_test PUBLIC cxx_std_14) target_include_directories(tcp_posix_test PRIVATE @@ -23988,6 +28003,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tcp_server_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(tcp_server_posix_test PUBLIC cxx_std_14) target_include_directories(tcp_server_posix_test PRIVATE @@ -24022,6 +28046,15 @@ if(gRPC_BUILD_TESTS) add_executable(tcp_socket_utils_test test/core/event_engine/tcp_socket_utils_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tcp_socket_utils_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(tcp_socket_utils_test PUBLIC cxx_std_14) target_include_directories(tcp_socket_utils_test PRIVATE @@ -24061,6 +28094,16 @@ add_executable(test_core_channel_channelz_test test/core/event_engine/event_engine_test_utils.cc test/cpp/util/channel_trace_proto_helper.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_channel_channelz_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_channel_channelz_test PUBLIC cxx_std_14) target_include_directories(test_core_channel_channelz_test PRIVATE @@ -24104,6 +28147,15 @@ add_executable(test_core_end2end_channelz_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_end2end_channelz_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_end2end_channelz_test PUBLIC cxx_std_14) target_include_directories(test_core_end2end_channelz_test PRIVATE @@ -24143,6 +28195,14 @@ add_executable(test_core_event_engine_posix_timer_heap_test src/core/lib/gprpp/time_averaged_stats.cc test/core/event_engine/posix/timer_heap_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_event_engine_posix_timer_heap_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_event_engine_posix_timer_heap_test PUBLIC cxx_std_14) target_include_directories(test_core_event_engine_posix_timer_heap_test PRIVATE @@ -24181,6 +28241,14 @@ add_executable(test_core_event_engine_posix_timer_list_test src/core/lib/gprpp/time_averaged_stats.cc test/core/event_engine/posix/timer_list_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_event_engine_posix_timer_list_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_event_engine_posix_timer_list_test PUBLIC cxx_std_14) target_include_directories(test_core_event_engine_posix_timer_list_test PRIVATE @@ -24224,6 +28292,14 @@ add_executable(test_core_event_engine_slice_buffer_test src/core/lib/slice/slice_string_helpers.cc test/core/event_engine/slice_buffer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_event_engine_slice_buffer_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_event_engine_slice_buffer_test PUBLIC cxx_std_14) target_include_directories(test_core_event_engine_slice_buffer_test PRIVATE @@ -24260,6 +28336,15 @@ if(gRPC_BUILD_TESTS) add_executable(test_core_gpr_time_test test/core/gpr/time_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_gpr_time_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_gpr_time_test PUBLIC cxx_std_14) target_include_directories(test_core_gpr_time_test PRIVATE @@ -24293,6 +28378,15 @@ if(gRPC_BUILD_TESTS) add_executable(test_core_gprpp_load_file_test test/core/gprpp/load_file_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_gprpp_load_file_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_gprpp_load_file_test PUBLIC cxx_std_14) target_include_directories(test_core_gprpp_load_file_test PRIVATE @@ -24327,6 +28421,14 @@ add_executable(test_core_gprpp_time_test src/core/lib/gprpp/time.cc test/core/gprpp/time_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_gprpp_time_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_gprpp_time_test PUBLIC cxx_std_14) target_include_directories(test_core_gprpp_time_test PRIVATE @@ -24371,6 +28473,15 @@ add_executable(test_core_iomgr_load_file_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_iomgr_load_file_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_iomgr_load_file_test PUBLIC cxx_std_14) target_include_directories(test_core_iomgr_load_file_test PRIVATE @@ -24414,6 +28525,15 @@ add_executable(test_core_iomgr_timer_heap_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_iomgr_timer_heap_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_iomgr_timer_heap_test PUBLIC cxx_std_14) target_include_directories(test_core_iomgr_timer_heap_test PRIVATE @@ -24457,6 +28577,15 @@ add_executable(test_core_security_credentials_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_security_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_security_credentials_test PUBLIC cxx_std_14) target_include_directories(test_core_security_credentials_test PRIVATE @@ -24500,6 +28629,15 @@ add_executable(test_core_security_ssl_credentials_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_security_ssl_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_security_ssl_credentials_test PUBLIC cxx_std_14) target_include_directories(test_core_security_ssl_credentials_test PRIVATE @@ -24533,6 +28671,15 @@ if(gRPC_BUILD_TESTS) add_executable(test_core_slice_slice_buffer_test test/core/slice/slice_buffer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_slice_slice_buffer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_slice_slice_buffer_test PUBLIC cxx_std_14) target_include_directories(test_core_slice_slice_buffer_test PRIVATE @@ -24567,6 +28714,15 @@ add_executable(test_core_slice_slice_test test/core/slice/slice_test.cc test/core/util/build.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_core_slice_slice_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_core_slice_slice_test PUBLIC cxx_std_14) target_include_directories(test_core_slice_slice_test PRIVATE @@ -24601,6 +28757,16 @@ add_executable(test_cpp_client_credentials_test test/cpp/client/credentials_test.cc test/cpp/util/tls_test_utils.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_cpp_client_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_cpp_client_credentials_test PUBLIC cxx_std_14) target_include_directories(test_cpp_client_credentials_test PRIVATE @@ -24652,6 +28818,16 @@ add_executable(test_cpp_end2end_ssl_credentials_test test/cpp/end2end/ssl_credentials_test.cc test/cpp/end2end/test_service_impl.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_cpp_end2end_ssl_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_cpp_end2end_ssl_credentials_test PUBLIC cxx_std_14) target_include_directories(test_cpp_end2end_ssl_credentials_test PRIVATE @@ -24686,6 +28862,16 @@ add_executable(test_cpp_server_credentials_test test/cpp/server/credentials_test.cc test/cpp/util/tls_test_utils.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_cpp_server_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_cpp_server_credentials_test PUBLIC cxx_std_14) target_include_directories(test_cpp_server_credentials_test PRIVATE @@ -24720,6 +28906,16 @@ if(gRPC_BUILD_TESTS) add_executable(test_cpp_util_slice_test test/cpp/util/slice_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_cpp_util_slice_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_cpp_util_slice_test PUBLIC cxx_std_14) target_include_directories(test_cpp_util_slice_test PRIVATE @@ -24753,6 +28949,16 @@ if(gRPC_BUILD_TESTS) add_executable(test_cpp_util_time_test test/cpp/util/time_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(test_cpp_util_time_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(test_cpp_util_time_test PUBLIC cxx_std_14) target_include_directories(test_cpp_util_time_test PRIVATE @@ -24786,6 +28992,15 @@ if(gRPC_BUILD_TESTS) add_executable(thd_test test/core/gprpp/thd_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thd_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(thd_test PUBLIC cxx_std_14) target_include_directories(thd_test PRIVATE @@ -24819,6 +29034,16 @@ if(gRPC_BUILD_TESTS) add_executable(thread_manager_test test/cpp/thread_manager/thread_manager_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thread_manager_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(thread_manager_test PUBLIC cxx_std_14) target_include_directories(thread_manager_test PRIVATE @@ -24853,6 +29078,15 @@ if(gRPC_BUILD_TESTS) add_executable(thread_pool_test test/core/event_engine/thread_pool_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thread_pool_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(thread_pool_test PUBLIC cxx_std_14) target_include_directories(thread_pool_test PRIVATE @@ -24888,6 +29122,14 @@ add_executable(thread_quota_test src/core/lib/resource_quota/thread_quota.cc test/core/resource_quota/thread_quota_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thread_quota_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(thread_quota_test PUBLIC cxx_std_14) target_include_directories(thread_quota_test PRIVATE @@ -24943,6 +29185,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/thread_stress_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thread_stress_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(thread_stress_test PUBLIC cxx_std_14) target_include_directories(thread_stress_test PRIVATE @@ -24984,6 +29236,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/tests/timer_test.cc test/core/event_engine/test_suite/thready_posix_event_engine_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(thready_posix_event_engine_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(thready_posix_event_engine_test PUBLIC cxx_std_14) target_include_directories(thready_posix_event_engine_test PRIVATE @@ -25019,6 +29280,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(time_jump_test test/cpp/common/time_jump_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(time_jump_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(time_jump_test PUBLIC cxx_std_14) target_include_directories(time_jump_test PRIVATE @@ -25054,6 +29325,15 @@ if(gRPC_BUILD_TESTS) add_executable(time_util_test test/core/gprpp/time_util_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(time_util_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(time_util_test PUBLIC cxx_std_14) target_include_directories(time_util_test PRIVATE @@ -25096,6 +29376,15 @@ add_executable(timeout_before_request_call_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(timeout_before_request_call_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(timeout_before_request_call_test PUBLIC cxx_std_14) target_include_directories(timeout_before_request_call_test PRIVATE @@ -25141,6 +29430,15 @@ add_executable(timeout_encoding_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(timeout_encoding_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(timeout_encoding_test PUBLIC cxx_std_14) target_include_directories(timeout_encoding_test PRIVATE @@ -25174,6 +29472,15 @@ if(gRPC_BUILD_TESTS) add_executable(timer_manager_test test/core/event_engine/posix/timer_manager_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(timer_manager_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(timer_manager_test PUBLIC cxx_std_14) target_include_directories(timer_manager_test PRIVATE @@ -25207,6 +29514,16 @@ if(gRPC_BUILD_TESTS) add_executable(timer_test test/cpp/common/timer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(timer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(timer_test PUBLIC cxx_std_14) target_include_directories(timer_test PRIVATE @@ -25242,6 +29559,16 @@ add_executable(tls_certificate_verifier_test test/cpp/security/tls_certificate_verifier_test.cc test/cpp/util/tls_test_utils.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tls_certificate_verifier_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(tls_certificate_verifier_test PUBLIC cxx_std_14) target_include_directories(tls_certificate_verifier_test PRIVATE @@ -25293,6 +29620,16 @@ add_executable(tls_credentials_test test/cpp/end2end/test_service_impl.cc test/cpp/end2end/tls_credentials_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tls_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(tls_credentials_test PUBLIC cxx_std_14) target_include_directories(tls_credentials_test PRIVATE @@ -25342,6 +29679,16 @@ add_executable(tls_key_export_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h test/cpp/end2end/tls_key_export_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tls_key_export_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(tls_key_export_test PUBLIC cxx_std_14) target_include_directories(tls_key_export_test PRIVATE @@ -25385,6 +29732,15 @@ add_executable(tls_security_connector_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(tls_security_connector_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(tls_security_connector_test PUBLIC cxx_std_14) target_include_directories(tls_security_connector_test PRIVATE @@ -25419,6 +29775,16 @@ add_executable(too_many_pings_test test/core/end2end/cq_verifier.cc test/core/transport/chttp2/too_many_pings_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(too_many_pings_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(too_many_pings_test PUBLIC cxx_std_14) target_include_directories(too_many_pings_test PRIVATE @@ -25454,6 +29820,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(traced_buffer_list_test test/core/event_engine/posix/traced_buffer_list_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(traced_buffer_list_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(traced_buffer_list_test PUBLIC cxx_std_14) target_include_directories(traced_buffer_list_test PRIVATE @@ -25497,6 +29872,15 @@ add_executable(trailing_metadata_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(trailing_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(trailing_metadata_test PUBLIC cxx_std_14) target_include_directories(trailing_metadata_test PRIVATE @@ -25532,6 +29916,15 @@ if(gRPC_BUILD_TESTS) add_executable(transport_security_common_api_test test/core/tsi/alts/handshaker/transport_security_common_api_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(transport_security_common_api_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(transport_security_common_api_test PUBLIC cxx_std_14) target_include_directories(transport_security_common_api_test PRIVATE @@ -25565,6 +29958,15 @@ if(gRPC_BUILD_TESTS) add_executable(transport_security_test test/core/tsi/transport_security_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(transport_security_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(transport_security_test PUBLIC cxx_std_14) target_include_directories(transport_security_test PRIVATE @@ -25660,6 +30062,15 @@ add_executable(transport_stream_receiver_test src/cpp/util/time_cc.cc test/core/transport/binder/transport_stream_receiver_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(transport_stream_receiver_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(transport_stream_receiver_test PUBLIC cxx_std_14) target_include_directories(transport_stream_receiver_test PRIVATE @@ -25696,6 +30107,14 @@ add_executable(try_join_test src/core/lib/promise/trace.cc test/core/promise/try_join_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(try_join_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(try_join_test PUBLIC cxx_std_14) target_include_directories(try_join_test PRIVATE @@ -25732,6 +30151,15 @@ if(gRPC_BUILD_TESTS) add_executable(try_seq_metadata_test test/core/promise/try_seq_metadata_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(try_seq_metadata_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(try_seq_metadata_test PUBLIC cxx_std_14) target_include_directories(try_seq_metadata_test PRIVATE @@ -25767,6 +30195,14 @@ add_executable(try_seq_test src/core/lib/promise/trace.cc test/core/promise/try_seq_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(try_seq_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(try_seq_test PUBLIC cxx_std_14) target_include_directories(try_seq_test PRIVATE @@ -25837,6 +30273,15 @@ add_executable(unknown_frame_bad_client_test test/core/bad_client/tests/unknown_frame.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(unknown_frame_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(unknown_frame_bad_client_test PUBLIC cxx_std_14) target_include_directories(unknown_frame_bad_client_test PRIVATE @@ -25870,6 +30315,15 @@ if(gRPC_BUILD_TESTS) add_executable(uri_parser_test test/core/uri/uri_parser_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(uri_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(uri_parser_test PUBLIC cxx_std_14) target_include_directories(uri_parser_test PRIVATE @@ -25936,6 +30390,15 @@ add_executable(uuid_v4_test src/core/lib/gprpp/uuid_v4.cc test/core/gprpp/uuid_v4_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(uuid_v4_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(uuid_v4_test PUBLIC cxx_std_14) target_include_directories(uuid_v4_test PRIVATE @@ -25969,6 +30432,15 @@ if(gRPC_BUILD_TESTS) add_executable(validation_errors_test test/core/gprpp/validation_errors_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(validation_errors_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(validation_errors_test PUBLIC cxx_std_14) target_include_directories(validation_errors_test PRIVATE @@ -26002,6 +30474,15 @@ if(gRPC_BUILD_TESTS) add_executable(varint_test test/core/transport/chttp2/varint_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(varint_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(varint_test PUBLIC cxx_std_14) target_include_directories(varint_test PRIVATE @@ -26036,6 +30517,14 @@ add_executable(wait_for_callback_test src/core/lib/promise/activity.cc test/core/promise/wait_for_callback_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(wait_for_callback_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(wait_for_callback_test PUBLIC cxx_std_14) target_include_directories(wait_for_callback_test PRIVATE @@ -26073,6 +30562,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(wakeup_fd_posix_test test/core/event_engine/posix/wakeup_fd_posix_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(wakeup_fd_posix_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(wakeup_fd_posix_test PUBLIC cxx_std_14) target_include_directories(wakeup_fd_posix_test PRIVATE @@ -26107,6 +30605,15 @@ if(gRPC_BUILD_TESTS) add_executable(weighted_round_robin_config_test test/core/client_channel/lb_policy/weighted_round_robin_config_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(weighted_round_robin_config_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(weighted_round_robin_config_test PUBLIC cxx_std_14) target_include_directories(weighted_round_robin_config_test PRIVATE @@ -26146,6 +30653,15 @@ add_executable(weighted_round_robin_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(weighted_round_robin_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(weighted_round_robin_test PUBLIC cxx_std_14) target_include_directories(weighted_round_robin_test PRIVATE @@ -26182,6 +30698,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX OR _gRPC_PLATFORM_WINDOWS) test/core/event_engine/windows/create_sockpair.cc test/core/event_engine/windows/win_socket_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(win_socket_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(win_socket_test PUBLIC cxx_std_14) target_include_directories(win_socket_test PRIVATE @@ -26218,6 +30743,15 @@ add_executable(window_overflow_bad_client_test test/core/bad_client/tests/window_overflow.cc test/core/end2end/cq_verifier.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(window_overflow_bad_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(window_overflow_bad_client_test PUBLIC cxx_std_14) target_include_directories(window_overflow_bad_client_test PRIVATE @@ -26253,6 +30787,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX OR _gRPC_PLATFORM_WINDOWS) test/core/event_engine/windows/create_sockpair.cc test/core/event_engine/windows/windows_endpoint_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(windows_endpoint_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(windows_endpoint_test PUBLIC cxx_std_14) target_include_directories(windows_endpoint_test PRIVATE @@ -26350,6 +30893,15 @@ add_executable(wire_reader_test test/core/transport/binder/mock_objects.cc test/core/transport/binder/wire_reader_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(wire_reader_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(wire_reader_test PUBLIC cxx_std_14) target_include_directories(wire_reader_test PRIVATE @@ -26447,6 +30999,15 @@ add_executable(wire_writer_test test/core/transport/binder/mock_objects.cc test/core/transport/binder/wire_writer_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(wire_writer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(wire_writer_test PUBLIC cxx_std_14) target_include_directories(wire_writer_test PRIVATE @@ -26483,6 +31044,15 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/event_engine/event_engine_test_utils.cc test/core/gprpp/work_serializer_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(work_serializer_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(work_serializer_test PUBLIC cxx_std_14) target_include_directories(work_serializer_test PRIVATE @@ -26526,6 +31096,15 @@ add_executable(write_buffering_at_end_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(write_buffering_at_end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(write_buffering_at_end_test PUBLIC cxx_std_14) target_include_directories(write_buffering_at_end_test PRIVATE @@ -26570,6 +31149,15 @@ add_executable(write_buffering_test test/core/event_engine/event_engine_test_utils.cc test/core/util/test_lb_policies.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(write_buffering_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(write_buffering_test PUBLIC cxx_std_14) target_include_directories(write_buffering_test PRIVATE @@ -26607,6 +31195,14 @@ add_executable(write_size_policy_test src/core/lib/gprpp/time.cc test/core/transport/chttp2/write_size_policy_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(write_size_policy_test + PRIVATE + "GPR_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(write_size_policy_test PUBLIC cxx_std_14) target_include_directories(write_size_policy_test PRIVATE @@ -26668,6 +31264,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/tracer_util.cc test/cpp/performance/writes_per_rpc_test.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(writes_per_rpc_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(writes_per_rpc_test PUBLIC cxx_std_14) target_include_directories(writes_per_rpc_test PRIVATE @@ -26768,6 +31374,16 @@ add_executable(xds_audit_logger_registry_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_audit_logger_registry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_audit_logger_registry_test PUBLIC cxx_std_14) target_include_directories(xds_audit_logger_registry_test PRIVATE @@ -26803,6 +31419,15 @@ if(gRPC_BUILD_TESTS) add_executable(xds_bootstrap_test test/core/xds/xds_bootstrap_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_bootstrap_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_bootstrap_test PUBLIC cxx_std_14) target_include_directories(xds_bootstrap_test PRIVATE @@ -26836,6 +31461,15 @@ if(gRPC_BUILD_TESTS) add_executable(xds_certificate_provider_test test/core/xds/xds_certificate_provider_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_certificate_provider_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_certificate_provider_test PUBLIC cxx_std_14) target_include_directories(xds_certificate_provider_test PRIVATE @@ -26883,6 +31517,15 @@ add_executable(xds_client_test test/core/xds/xds_client_test.cc test/core/xds/xds_transport_fake.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_client_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_client_test PUBLIC cxx_std_14) target_include_directories(xds_client_test PRIVATE @@ -27048,6 +31691,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_cluster_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_cluster_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_cluster_end2end_test PRIVATE @@ -27155,6 +31808,15 @@ add_executable(xds_cluster_resource_type_test src/cpp/util/status.cc test/core/xds/xds_cluster_resource_type_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_cluster_resource_type_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_cluster_resource_type_test PUBLIC cxx_std_14) target_include_directories(xds_cluster_resource_type_test PRIVATE @@ -27324,6 +31986,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_cluster_type_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_cluster_type_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_cluster_type_end2end_test PRIVATE @@ -27399,6 +32071,16 @@ add_executable(xds_common_types_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_common_types_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_common_types_test PUBLIC cxx_std_14) target_include_directories(xds_common_types_test PRIVATE @@ -27564,6 +32246,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_core_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_core_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_core_end2end_test PRIVATE @@ -27615,6 +32307,16 @@ add_executable(xds_credentials_end2end_test test/cpp/end2end/test_service_impl.cc test/cpp/end2end/xds/xds_credentials_end2end_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_credentials_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_credentials_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_credentials_end2end_test PRIVATE @@ -27658,6 +32360,15 @@ add_executable(xds_credentials_test test/core/util/slice_splitter.cc test/core/util/tracer_util.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_credentials_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_credentials_test PUBLIC cxx_std_14) target_include_directories(xds_credentials_test PRIVATE @@ -27830,6 +32541,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_csds_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_csds_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_csds_end2end_test PRIVATE @@ -28015,6 +32736,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_end2end_test PRIVATE @@ -28071,6 +32802,15 @@ add_executable(xds_endpoint_resource_type_test src/cpp/util/status.cc test/core/xds/xds_endpoint_resource_type_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_endpoint_resource_type_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_endpoint_resource_type_test PUBLIC cxx_std_14) target_include_directories(xds_endpoint_resource_type_test PRIVATE @@ -28243,6 +32983,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_fault_injection_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_fault_injection_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_fault_injection_end2end_test PRIVATE @@ -28366,6 +33116,16 @@ add_executable(xds_http_filters_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_http_filters_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_http_filters_test PUBLIC cxx_std_14) target_include_directories(xds_http_filters_test PRIVATE @@ -28474,6 +33234,16 @@ add_executable(xds_lb_policy_registry_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_lb_policy_registry_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_lb_policy_registry_test PUBLIC cxx_std_14) target_include_directories(xds_lb_policy_registry_test PRIVATE @@ -28606,6 +33376,16 @@ add_executable(xds_listener_resource_type_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_listener_resource_type_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_listener_resource_type_test PUBLIC cxx_std_14) target_include_directories(xds_listener_resource_type_test PRIVATE @@ -28779,6 +33559,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_outlier_detection_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_outlier_detection_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_outlier_detection_end2end_test PRIVATE @@ -28955,6 +33745,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_override_host_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_override_host_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_override_host_end2end_test PRIVATE @@ -28989,6 +33789,15 @@ if(gRPC_BUILD_TESTS) add_executable(xds_override_host_lb_config_parser_test test/core/client_channel/lb_policy/xds_override_host_lb_config_parser_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_override_host_lb_config_parser_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_override_host_lb_config_parser_test PUBLIC cxx_std_14) target_include_directories(xds_override_host_lb_config_parser_test PRIVATE @@ -29028,6 +33837,15 @@ add_executable(xds_override_host_test test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_override_host_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_override_host_test PUBLIC cxx_std_14) target_include_directories(xds_override_host_test PRIVATE @@ -29201,6 +34019,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_pick_first_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_pick_first_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_pick_first_end2end_test PRIVATE @@ -29370,6 +34198,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_ring_hash_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_ring_hash_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_ring_hash_end2end_test PRIVATE @@ -29543,6 +34381,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_rls_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_rls_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_rls_end2end_test PRIVATE @@ -29654,6 +34502,16 @@ add_executable(xds_route_config_resource_type_test test/cpp/util/proto_reflection_descriptor_database.cc test/cpp/util/service_describer.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_route_config_resource_type_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_route_config_resource_type_test PUBLIC cxx_std_14) target_include_directories(xds_route_config_resource_type_test PRIVATE @@ -29827,6 +34685,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_utils.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_routing_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_routing_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_routing_end2end_test PRIVATE @@ -29893,6 +34761,16 @@ add_executable(xds_stats_watcher_test test/cpp/interop/xds_stats_watcher.cc test/cpp/interop/xds_stats_watcher_test.cc ) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_stats_watcher_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() +endif() target_compile_features(xds_stats_watcher_test PUBLIC cxx_std_14) target_include_directories(xds_stats_watcher_test PRIVATE @@ -30067,6 +34945,16 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/cpp/end2end/xds/xds_wrr_end2end_test.cc test/cpp/util/tls_test_utils.cc ) + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_wrr_end2end_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + "GRPCXX_DLL_IMPORTS" + ) + endif() + endif() target_compile_features(xds_wrr_end2end_test PUBLIC cxx_std_14) target_include_directories(xds_wrr_end2end_test PRIVATE diff --git a/include/grpcpp/support/proto_buffer_reader.h b/include/grpcpp/support/proto_buffer_reader.h index dc0c29601ed..6f1d4806395 100644 --- a/include/grpcpp/support/proto_buffer_reader.h +++ b/include/grpcpp/support/proto_buffer_reader.h @@ -148,7 +148,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream { *slice(), GRPC_SLICE_LENGTH(*slice()) - backup_count(), GRPC_SLICE_LENGTH(*slice()) - backup_count() + count))); } - int64_t take = std::min(backup_count(), static_cast(count)); + int64_t take = (std::min)(backup_count(), static_cast(count)); set_backup_count(backup_count() - take); count -= take; if (count == 0) { diff --git a/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc b/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc index 7a8992404a6..673e3e29d25 100644 --- a/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +++ b/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc @@ -24,6 +24,7 @@ #include "absl/functional/any_invocable.h" #include "absl/status/status.h" +#include "absl/strings/str_format.h" #include diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 914fe3b7942..06a2fd6f890 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -29,6 +29,11 @@ third_party_proto_prefixes = {lib.proto_prefix for lib in external_proto_libraries} + gpr_libs = ['gpr'] + grpc_libs = ['grpc', 'grpc_unsecure'] + grpcxx_libs = ['grpc++', 'grpc++_unsecure'] + protoc_libs = ['benchmark_helpers', 'grpc++_reflection', 'grpcpp_channelz'] + def third_party_proto_import_path(path): """Removes third_party prefix to match ProtoBuf's relative import path.""" for prefix in third_party_proto_prefixes: @@ -158,7 +163,7 @@ return ' SHARED' # upb always compiles as a static library on Windows - elif lib_name in ['upb','upb_collections_lib','upb_json_lib','upb_textformat_lib']: + elif lib_name in ['upb','upb_collections_lib','upb_json_lib','upb_textformat_lib'] + protoc_libs: return ' ${_gRPC_STATIC_WIN32}' else: @@ -192,6 +197,19 @@ deps.append(d) return deps + def get_all_deps(target_dict, all_libs): + ret = set() + get_all_deps_recurse(target_dict, all_libs, ret) + return ret + + def get_all_deps_recurse(target_dict, all_libs, all_deps): + for d in target_dict.get('deps', []): + if not d in all_deps: + all_deps.add(d) + for other_lib in all_libs: + if other_lib.name == d: + get_all_deps_recurse(other_lib, all_libs, all_deps) + def is_generate_cmake_target(lib_or_target): """Returns True if a cmake target should be generated for given library/target.""" # TODO(jtattermusch): extract the metadata to a centralized location. @@ -250,12 +268,6 @@ return '\n'.join(lines) return _func - def add_dll_annotation_macros(lib, prefix): - return """set_target_properties(%s PROPERTIES DEFINE_SYMBOL "%s_DLL_EXPORTS") - if(BUILD_SHARED_LIBS) - target_compile_definitions(%s INTERFACE %s_DLL_IMPORTS) - endif()""" % (lib, prefix, lib, prefix) - %> <% # These files are added to a set so that they are not duplicated if multiple @@ -286,6 +298,10 @@ set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") project(<%text>${PACKAGE_NAME} LANGUAGES C CXX) + if(BUILD_SHARED_LIBS AND MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif() + set(gRPC_INSTALL_BINDIR "bin" CACHE STRING "Installation directory for executables") set(gRPC_INSTALL_LIBDIR "lib" CACHE STRING "Installation directory for libraries") set(gRPC_INSTALL_INCLUDEDIR "include" CACHE STRING "Installation directory for headers") @@ -410,6 +426,8 @@ set(_gRPC_C_CXX_FLAGS "<%text>${_gRPC_C_CXX_FLAGS} /wd4503") # Tell MSVC to build grpc using utf-8 set(_gRPC_C_CXX_FLAGS "<%text>${_gRPC_C_CXX_FLAGS} /utf-8") + # Inconsistent object sizes can cause stack corruption and should be treated as an error + set(_gRPC_C_CXX_FLAGS "<%text>${_gRPC_C_CXX_FLAGS} /we4789") endif() if (MINGW) add_definitions(-D_WIN32_WINNT=0x600) @@ -512,12 +530,12 @@ set(_gRPC_ALLTARGETS_LIBRARIES <%text>${_gRPC_ALLTARGETS_LIBRARIES} ws2_32 crypt32) set(_gRPC_STATIC_WIN32 STATIC) endif() - + if(BUILD_SHARED_LIBS AND WIN32) # Currently for shared lib on Windows (i.e. a DLL) certain bits of source code # are generated from protobuf definitions by upbc. This source code does not include - # annotations needed to export these functions from gprc.lib so we have to + # annotations needed to export these functions from grpc.lib so we have to # re-include a small subset of these. # # This is not an ideal situation because these functions will be unavailable @@ -530,9 +548,18 @@ src/core/ext/upb-gen/src/proto/grpc/health/v1/health.upb_minitable.c src/core/ext/upb-gen/src/proto/grpc/gcp/transport_security_common.upb_minitable.c ) + set(gRPC_ADDITIONAL_DLL_SRC src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc + src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc + src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc + ) + + set(gRPC_ADDITIONAL_DLL_CXX_SRC + src/cpp/common/tls_certificate_provider.cc + src/cpp/common/tls_certificate_verifier.cc + src/cpp/common/tls_credentials_options.cc ) endif() # BUILD_SHARED_LIBS AND WIN32 @@ -792,10 +819,13 @@ % endif % endfor % if lib.name in ['grpc++_alts', 'grpc++_unsecure', 'grpc++']: - ${'${gRPC_UPB_GEN_DUPL_SRC}'} + <%text>${gRPC_UPB_GEN_DUPL_SRC} % endif % if lib.name in ['grpc_unsecure']: - ${'${gRPC_ADDITIONAL_DLL_SRC}'} + <%text>${gRPC_ADDITIONAL_DLL_SRC} + % endif + % if lib.name in ['grpc++_unsecure']: + <%text>${gRPC_ADDITIONAL_DLL_CXX_SRC} % endif ) @@ -814,17 +844,30 @@ if(WIN32 AND MSVC) set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}" COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}" - ) - % if lib.name == 'gpr': - ${add_dll_annotation_macros(lib.name, 'GPR')} - % elif lib.name == 'grpc': - ${add_dll_annotation_macros(lib.name, 'GRPC')} - % elif lib.name == 'grpc_unsecure': - ${add_dll_annotation_macros(lib.name, 'GRPC')} - % elif lib.name == 'grpc++': - ${add_dll_annotation_macros(lib.name, 'GRPCXX')} - % elif lib.name == 'grpc++_unsecure': - ${add_dll_annotation_macros(lib.name, 'GRPCXX')} + )<% + dll_annotations = [] + if lib.name in gpr_libs: + dll_annotations.append("GPR_DLL_EXPORTS") + if lib.name in grpc_libs: + dll_annotations.append("GRPC_DLL_EXPORTS") + if lib.name in grpcxx_libs: + dll_annotations.append("GRPCXX_DLL_EXPORTS") + if set(gpr_libs) & set(get_all_deps(lib, libs)): + dll_annotations.append("GPR_DLL_IMPORTS") + if set(grpc_libs) & set(get_all_deps(lib, libs)): + dll_annotations.append("GRPC_DLL_IMPORTS") + if set(grpcxx_libs) & set(get_all_deps(lib, libs)): + dll_annotations.append("GRPCXX_DLL_IMPORTS") + %> + % if dll_annotations: + if(BUILD_SHARED_LIBS) + target_compile_definitions(${lib.name} + PRIVATE + % for definition in dll_annotations: + "${definition}" + % endfor + ) + endif() % endif if(gRPC_INSTALL) install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${lib.name}.pdb @@ -908,7 +951,27 @@ ${proto_replace_ext(src, '.grpc.pb.h')} % endif % endfor - ) + )<% + dll_annotations = [] + if set(gpr_libs) & set(get_all_deps(tgt, libs)): + dll_annotations.append("GPR_DLL_IMPORTS") + if set(grpc_libs) & set(get_all_deps(tgt, libs)): + dll_annotations.append("GRPC_DLL_IMPORTS") + if set(grpcxx_libs) & set(get_all_deps(tgt, libs)): + dll_annotations.append("GRPCXX_DLL_IMPORTS") + %> + % if dll_annotations: + if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(${tgt.name} + PRIVATE + % for definition in dll_annotations: + "${definition}" + % endfor + ) + endif() + endif() + % endif target_compile_features(${tgt.name} PUBLIC cxx_std_14) target_include_directories(${tgt.name} PRIVATE