CMakeLists.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #
  2. # Copyright 2009-2017 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. set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
  17. set(saf_public_header
  18. include/alibabacloud/saf/SafClient.h
  19. include/alibabacloud/saf/SafExport.h )
  20. set(saf_public_header_model
  21. include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h
  22. include/alibabacloud/saf/model/ExecuteExtendServiceResult.h
  23. include/alibabacloud/saf/model/ExecuteRequestRequest.h
  24. include/alibabacloud/saf/model/ExecuteRequestResult.h
  25. include/alibabacloud/saf/model/ExecuteRequestMLRequest.h
  26. include/alibabacloud/saf/model/ExecuteRequestMLResult.h
  27. include/alibabacloud/saf/model/ExecuteRequestSGRequest.h
  28. include/alibabacloud/saf/model/ExecuteRequestSGResult.h )
  29. set(saf_src
  30. src/SafClient.cc
  31. src/model/ExecuteExtendServiceRequest.cc
  32. src/model/ExecuteExtendServiceResult.cc
  33. src/model/ExecuteRequestRequest.cc
  34. src/model/ExecuteRequestResult.cc
  35. src/model/ExecuteRequestMLRequest.cc
  36. src/model/ExecuteRequestMLResult.cc
  37. src/model/ExecuteRequestSGRequest.cc
  38. src/model/ExecuteRequestSGResult.cc )
  39. add_library(saf ${LIB_TYPE}
  40. ${saf_public_header}
  41. ${saf_public_header_model}
  42. ${saf_src})
  43. set_target_properties(saf
  44. PROPERTIES
  45. LINKER_LANGUAGE CXX
  46. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
  47. LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
  48. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  49. OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}saf
  50. )
  51. if(${LIB_TYPE} STREQUAL "SHARED")
  52. set_target_properties(saf
  53. PROPERTIES
  54. DEFINE_SYMBOL ALIBABACLOUD_SAF_LIBRARY)
  55. endif()
  56. target_include_directories(saf
  57. PRIVATE include
  58. ${CMAKE_SOURCE_DIR}/core/include
  59. )
  60. target_link_libraries(saf
  61. core)
  62. if(CMAKE_HOST_WIN32)
  63. ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
  64. set(jsoncpp_install_dir ${INSTALL_DIR})
  65. add_dependencies(saf
  66. jsoncpp)
  67. target_include_directories(saf
  68. PRIVATE ${jsoncpp_install_dir}/include)
  69. target_link_libraries(saf
  70. ${jsoncpp_install_dir}/lib/jsoncpp.lib)
  71. set_target_properties(saf
  72. PROPERTIES
  73. COMPILE_OPTIONS "/bigobj")
  74. else()
  75. target_include_directories(saf
  76. PRIVATE /usr/include/jsoncpp)
  77. target_link_libraries(saf
  78. jsoncpp)
  79. endif()
  80. install(FILES ${saf_public_header}
  81. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/saf)
  82. install(FILES ${saf_public_header_model}
  83. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/saf/model)
  84. install(TARGETS saf
  85. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  86. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  87. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  88. )