CMakeLists.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. #
  2. # Copyright 1999-2019 Alibaba Cloud All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. # coverage option
  17. OPTION (ENABLE_COVERAGE "Use gcov" OFF)
  18. MESSAGE(STATUS ENABLE_COVERAGE=${ENABLE_COVERAGE})
  19. IF(ENABLE_COVERAGE)
  20. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  21. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
  22. # SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
  23. ENDIF()
  24. configure_file(src/Config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/alibabacloud/core/Config.h @ONLY)
  25. set(core_public_header
  26. include/alibabacloud/core/AlibabaCloud.h
  27. include/alibabacloud/core/AsyncCallerContext.h
  28. include/alibabacloud/core/ClientConfiguration.h
  29. include/alibabacloud/core/CommonClient.h
  30. include/alibabacloud/core/CommonRequest.h
  31. include/alibabacloud/core/CommonResponse.h
  32. include/alibabacloud/core/Config.h
  33. include/alibabacloud/core/CoreClient.h
  34. include/alibabacloud/core/CoreExport.h
  35. include/alibabacloud/core/Credentials.h
  36. include/alibabacloud/core/CredentialsProvider.h
  37. include/alibabacloud/core/EndpointProvider.h
  38. include/alibabacloud/core/Error.h
  39. include/alibabacloud/core/Global.h
  40. include/alibabacloud/core/HmacSha1Signer.h
  41. include/alibabacloud/core/HttpClient.h
  42. include/alibabacloud/core/HttpMessage.h
  43. include/alibabacloud/core/HttpResponse.h
  44. include/alibabacloud/core/HttpRequest.h
  45. include/alibabacloud/core/InstanceProfileCredentialsProvider.h
  46. include/alibabacloud/core/NetworkProxy.h
  47. include/alibabacloud/core/Outcome.h
  48. include/alibabacloud/core/Runnable.h
  49. include/alibabacloud/core/RoaServiceClient.h
  50. include/alibabacloud/core/RoaServiceRequest.h
  51. include/alibabacloud/core/RpcServiceClient.h
  52. include/alibabacloud/core/RpcServiceRequest.h
  53. include/alibabacloud/core/ServiceRequest.h
  54. include/alibabacloud/core/ServiceResult.h
  55. include/alibabacloud/core/Signer.h
  56. include/alibabacloud/core/SimpleCredentialsProvider.h
  57. include/alibabacloud/core/StsAssumeRoleCredentialsProvider.h
  58. include/alibabacloud/core/Url.h
  59. include/alibabacloud/core/Utils.h
  60. )
  61. set(core_public_header_location
  62. include/alibabacloud/core/location/LocationClient.h
  63. include/alibabacloud/core/location/LocationRequest.h
  64. )
  65. set(core_public_header_location_model
  66. include/alibabacloud/core/location/model/DescribeEndpointsRequest.h
  67. include/alibabacloud/core/location/model/DescribeEndpointsResult.h
  68. )
  69. set(core_public_header_sts
  70. include/alibabacloud/core/sts/StsClient.h
  71. include/alibabacloud/core/sts/StsRequest.h
  72. )
  73. set(core_public_header_sts_model
  74. include/alibabacloud/core/sts/model/AssumeRoleRequest.h
  75. include/alibabacloud/core/sts/model/AssumeRoleResult.h
  76. include/alibabacloud/core/sts/model/GetCallerIdentityRequest.h
  77. include/alibabacloud/core/sts/model/GetCallerIdentityResult.h
  78. )
  79. set(core_src
  80. src/AlibabaCloud.cc
  81. src/AsyncCallerContext.cc
  82. src/ClientConfiguration.cc
  83. src/CommonClient.cc
  84. src/CommonRequest.cc
  85. src/CommonResponse.cc
  86. src/CoreClient.cc
  87. src/Credentials.cc
  88. src/CredentialsProvider.cc
  89. src/CurlHttpClient.h
  90. src/CurlHttpClient.cc
  91. src/EcsMetadataFetcher.cc
  92. src/EcsMetadataFetcher.h
  93. src/EndpointProvider.cc
  94. src/Error.cc
  95. src/Executor.cc
  96. src/Executor.h
  97. src/HmacSha1Signer.cc
  98. src/HttpClient.cc
  99. src/HttpMessage.cc
  100. src/HttpResponse.cc
  101. src/HttpRequest.cc
  102. src/InstanceProfileCredentialsProvider.cc
  103. src/NetworkProxy.cc
  104. src/Outcome.cc
  105. src/Runnable.cc
  106. src/RoaServiceClient.cc
  107. src/RoaServiceRequest.cc
  108. src/RpcServiceClient.cc
  109. src/RpcServiceRequest.cc
  110. src/ServiceRequest.cc
  111. src/ServiceResult.cc
  112. src/Signer.cc
  113. src/SimpleCredentialsProvider.cc
  114. src/StsAssumeRoleCredentialsProvider.cc
  115. src/Url.cc
  116. src/Utils.cc
  117. src/location/LocationClient.cc
  118. src/location/LocationRequest.cc
  119. src/location/model/DescribeEndpointsRequest.cc
  120. src/location/model/DescribeEndpointsResult.cc
  121. src/sts/StsClient.cc
  122. src/sts/StsRequest.cc
  123. src/sts/model/AssumeRoleRequest.cc
  124. src/sts/model/AssumeRoleResult.cc
  125. src/sts/model/GetCallerIdentityRequest.cc
  126. src/sts/model/GetCallerIdentityResult.cc
  127. )
  128. add_library(core ${LIB_TYPE}
  129. ${core_public_header}
  130. ${core_public_header_location}
  131. ${core_public_header_location_model}
  132. ${core_public_header_sts}
  133. ${core_public_header_sts_model}
  134. ${core_src})
  135. set_target_properties(core
  136. PROPERTIES
  137. LINKER_LANGUAGE CXX
  138. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
  139. LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
  140. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  141. OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}core
  142. )
  143. if(${LIB_TYPE} STREQUAL "SHARED")
  144. set_target_properties(core
  145. PROPERTIES
  146. DEFINE_SYMBOL ALIBABACLOUD_CORE_LIBRARY)
  147. endif()
  148. target_include_directories(core
  149. PRIVATE include )
  150. if(CMAKE_HOST_WIN32)
  151. ExternalProject_Get_Property(curl INSTALL_DIR)
  152. set(curl_install_dir ${INSTALL_DIR})
  153. ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
  154. set(jsoncpp_install_dir ${INSTALL_DIR})
  155. add_dependencies(core
  156. curl
  157. jsoncpp )
  158. target_include_directories(core
  159. PRIVATE ${curl_install_dir}/include
  160. ${jsoncpp_install_dir}/include
  161. ${tinyxml2_install_dir}/include)
  162. target_link_libraries(core
  163. Crypt32
  164. Rpcrt4
  165. Ws2_32
  166. ${jsoncpp_install_dir}/lib/jsoncpp.lib
  167. debug ${curl_install_dir}/lib/libcurl-d.lib
  168. optimized ${curl_install_dir}/lib/libcurl.lib
  169. )
  170. target_compile_definitions(core
  171. PRIVATE CURL_STATICLIB
  172. _CRT_SECURE_NO_WARNINGS)
  173. else()
  174. target_include_directories(core
  175. PRIVATE /usr/include/jsoncpp)
  176. target_link_libraries(core
  177. crypto
  178. curl
  179. jsoncpp
  180. uuid )
  181. endif()
  182. install(FILES ${core_public_header}
  183. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/core)
  184. install(FILES ${core_public_header_location}
  185. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/core/location)
  186. install(FILES ${core_public_header_location_model}
  187. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/core/location/model)
  188. install(FILES ${core_public_header_sts}
  189. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/core/sts)
  190. install(FILES ${core_public_header_sts_model}
  191. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/core/sts/model)
  192. install(TARGETS core
  193. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  194. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  195. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  196. )