1414# limitations under the License.
1515# ~~~
1616
17+ # The examples are more readable if we use exceptions for error handling. We had
18+ # to tradeoff readability vs. "making them compile everywhere".
19+ if (NOT GOOGLE_CLOUD_CPP_ENABLE_EXAMPLES)
20+ return ()
21+ endif ()
22+
1723# Pick the right MSVC runtime libraries.
1824include (SelectMSVCRuntime )
1925
20- add_executable (gcs2cbt gcs2cbt.cc )
21- target_link_libraries (gcs2cbt google-cloud-cpp::bigtable
22- google-cloud-cpp::storage google-cloud-cpp::grpc_utils )
23- google_cloud_cpp_add_common_options (gcs2cbt )
26+ if (bigtable IN_LIST GOOGLE_CLOUD_CPP_ENABLE AND storage IN_LIST
27+ GOOGLE_CLOUD_CPP_ENABLE)
28+ add_executable (gcs2cbt gcs2cbt.cc )
29+ target_link_libraries (
30+ gcs2cbt google-cloud-cpp::bigtable google-cloud-cpp::storage
31+ google-cloud-cpp::grpc_utils )
32+ google_cloud_cpp_add_common_options (gcs2cbt )
33+ endif ()
2434
25- if (BUILD_TESTING)
26- include (FindCurlWithTargets )
27- include (FindgRPC )
35+ include (FindCurlWithTargets )
36+ include (FindgRPC )
2837
38+ if (spanner IN_LIST GOOGLE_CLOUD_CPP_ENABLE AND iam IN_LIST
39+ GOOGLE_CLOUD_CPP_ENABLE)
2940 google_cloud_cpp_grpcpp_library (
3041 hello_world_protos "hello_world_grpc/hello_world.proto"
3142 PROTO_PATH_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} )
@@ -38,11 +49,19 @@ if (BUILD_TESTING)
3849 PRIVATE hello_world_protos google_cloud_cpp_testing
3950 google-cloud-cpp::iam google-cloud-cpp::spanner CURL::libcurl )
4051 google_cloud_cpp_add_common_options (grpc_credential_types )
52+ endif ()
4153
42- foreach (test gcs2cbt grpc_credential_types)
43- add_test (NAME ${test} COMMAND ${test} )
44- set_tests_properties (
45- ${test} PROPERTIES LABELS
46- "integration-test;integration-test-production" )
47- endforeach ()
54+ # Label all the binaries as "tests", so they run in our CI builds.
55+ if (NOT BUILD_TESTING)
56+ return ()
4857endif ()
58+
59+ foreach (test gcs2cbt grpc_credential_types)
60+ if (NOT TARGET "${test} " )
61+ continue ()
62+ endif ()
63+ add_test (NAME ${test} COMMAND ${test} )
64+ set_tests_properties (
65+ ${test} PROPERTIES LABELS
66+ "integration-test;integration-test-production" )
67+ endforeach ()
0 commit comments