Skip to content

Commit 999bf3f

Browse files
authored
cleanup: better CMake transition library support (#13991)
1 parent 5628e96 commit 999bf3f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

cmake/GoogleCloudCppLibrary.cmake

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,22 @@ function (google_cloud_cpp_add_gapic_library library display_name)
253253

254254
add_library(${library_alias} ALIAS ${library_target})
255255

256+
unset(transition_target)
257+
if (_opt_TRANSITION)
258+
# Define an interface library to allow for a smoother transition from
259+
# `experimental-foo` -> `foo`.
260+
set(transition_target "google_cloud_cpp_experimental_${library}")
261+
set(transition_alias "google-cloud-cpp::experimental-${library}")
262+
add_library(${transition_target} INTERFACE)
263+
set_target_properties(${transition_target}
264+
PROPERTIES EXPORT_NAME ${transition_alias})
265+
target_link_libraries(
266+
${transition_target}
267+
PUBLIC
268+
INTERFACE ${library_alias})
269+
add_library(${transition_alias} ALIAS ${transition_target})
270+
endif ()
271+
256272
# Get the destination directories based on the GNU recommendations.
257273
include(GNUInstallDirs)
258274

@@ -266,7 +282,7 @@ function (google_cloud_cpp_add_gapic_library library display_name)
266282
# GNUInstallDirs
267283
install(
268284
TARGETS ${library_target} ${protos_target}
269-
${backwards_compat_proto_targets}
285+
${backwards_compat_proto_targets} ${transition_target}
270286
EXPORT ${library_target}-targets
271287
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
272288
COMPONENT google_cloud_cpp_runtime
@@ -296,14 +312,6 @@ function (google_cloud_cpp_add_gapic_library library display_name)
296312
endforeach ()
297313
string(JOIN "\n" GOOGLE_CLOUD_CPP_ADDITIONAL_FIND_DEPENDENCIES
298314
${find_dependencies})
299-
if (_opt_TRANSITION)
300-
set(cmake_config_transition_lines
301-
"if (NOT TARGET ${experimental_alias})"
302-
" add_library(${experimental_alias} ALIAS ${library_alias})"
303-
"endif ()")
304-
string(JOIN "\n" GOOGLE_CLOUD_CPP_CONFIG_TRANSITION_TARGETS
305-
${cmake_config_transition_lines})
306-
endif ()
307315
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/config.cmake.in"
308316
"${library_target}-config.cmake" @ONLY)
309317
write_basic_package_version_file(

cmake/templates/config.cmake.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ find_dependency(absl)
2121
@GOOGLE_CLOUD_CPP_ADDITIONAL_FIND_DEPENDENCIES@
2222

2323
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
24-
25-
@GOOGLE_CLOUD_CPP_CONFIG_TRANSITION_TARGETS@

0 commit comments

Comments
 (0)