在 google-api-cpp-client 中构建专门的服务 API
Building specialized service APIs in google-api-cpp-client
我正在尝试构建专门的 Youtube API, which is included in the standard distribution of the google-api-cpp-client 库。文档指出:
If you download the C++ libraries and unzip them into the service_apis
directory at the root of the source installation for this SDK then the default build scripts will automatically build them.
但是,构建脚本没有。构建包含在分布中的样本非常清楚地揭示了这一点。
Linking CXX executable ../../bin/calendar_sample
ld: library not found for -lgoogle_calendar_api
根CMakeLists.txt
的尾部内容如下:
add_subdirectory(src)
if (googleapis_build_samples)
set(googleapis_build_service_apis true) # force on
endif()
if (googleapis_build_service_apis)
add_subdirectory(service_apis)
endif()
# Build samples after the service apis
# but keep them under src
if (googleapis_build_samples)
add_subdirectory(src/samples)
endif()
这最终导致这个 CMakeLists.txt(在 service_apis 目录的根目录中):
file(GLOB all_valid_subdirs RELATIVE
${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt")
foreach(dir ${all_valid_subdirs})
message(STATUS "path = ${dir}")
if(${dir} MATCHES "^([^/]*)//CMakeLists.txt")
string(REGEX REPLACE
"^([^/]*)//CMakeLists.txt" "\1" dir_trimmed ${dir})
add_subdirectory(${dir_trimmed})
endif()
endforeach(dir)
我在 if 语句中放置了一个 message
输出。似乎 add_subdirectory
呼叫从未到达。 foreach
确实遍历了所有子目录。
为什么正则表达式比较失败?
其实我在做完这道题的时候发现了错误。正则表达式比较包含一个额外的正斜杠。以下正则表达式将成功包含库。
^([^/]*)/CMakeLists.txt
我会向开发者提出错误。
我正在尝试构建专门的 Youtube API, which is included in the standard distribution of the google-api-cpp-client 库。文档指出:
If you download the C++ libraries and unzip them into the
service_apis
directory at the root of the source installation for this SDK then the default build scripts will automatically build them.
但是,构建脚本没有。构建包含在分布中的样本非常清楚地揭示了这一点。
Linking CXX executable ../../bin/calendar_sample
ld: library not found for -lgoogle_calendar_api
根CMakeLists.txt
的尾部内容如下:
add_subdirectory(src)
if (googleapis_build_samples)
set(googleapis_build_service_apis true) # force on
endif()
if (googleapis_build_service_apis)
add_subdirectory(service_apis)
endif()
# Build samples after the service apis
# but keep them under src
if (googleapis_build_samples)
add_subdirectory(src/samples)
endif()
这最终导致这个 CMakeLists.txt(在 service_apis 目录的根目录中):
file(GLOB all_valid_subdirs RELATIVE
${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt")
foreach(dir ${all_valid_subdirs})
message(STATUS "path = ${dir}")
if(${dir} MATCHES "^([^/]*)//CMakeLists.txt")
string(REGEX REPLACE
"^([^/]*)//CMakeLists.txt" "\1" dir_trimmed ${dir})
add_subdirectory(${dir_trimmed})
endif()
endforeach(dir)
我在 if 语句中放置了一个 message
输出。似乎 add_subdirectory
呼叫从未到达。 foreach
确实遍历了所有子目录。
为什么正则表达式比较失败?
其实我在做完这道题的时候发现了错误。正则表达式比较包含一个额外的正斜杠。以下正则表达式将成功包含库。
^([^/]*)/CMakeLists.txt
我会向开发者提出错误。