CMakeLists.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(space_lib)
  3. add_compile_options(-std=c++11)
  4. set (CMAKE_BUILD_TYPE Release)
  5. find_package(Boost REQUIRED COMPONENTS system thread)
  6. include_directories(
  7. include
  8. /usr/include
  9. /usr/local/include
  10. ${Boost_INCLUDE_DIRS}
  11. )
  12. link_directories(
  13. # lib/glog
  14. # lib/gflags
  15. lib/uuid
  16. /usr/lib/
  17. /usr/local/lib/
  18. /usr/local/libstatic/
  19. )
  20. # 源文件
  21. SET(SPACE_LIB_SRC
  22. # algorithm
  23. src/algorithm/bezier.cpp
  24. src/algorithm/fold.cpp
  25. # comm
  26. src/comm/ctcp/ctcp.cpp
  27. src/comm/serial/serial.cpp
  28. src/comm/tcp/tcp.cpp
  29. src/comm/udp/udp.cpp
  30. src/comm/websocket/websocket.cpp
  31. # common
  32. src/common/directory.cpp
  33. src/common/home.cpp
  34. src/common/time.cpp
  35. src/common/uuid.cpp
  36. src/common/lookup_table.cpp
  37. # config
  38. src/config/config.cpp
  39. # error
  40. src/error/error.cpp
  41. # json
  42. src/json/json_reader.cpp
  43. src/json/json_value.cpp
  44. src/json/json_writer.cpp
  45. src/json/json.cpp
  46. # log
  47. src/log/log.cpp
  48. # string
  49. src/string/string_to.cpp
  50. src/string/to_string.cpp
  51. )
  52. # 库文件
  53. SET(SPACE_LIB_LIB
  54. # glog gflags
  55. # libglog.a
  56. # libgflags.a
  57. # uuid
  58. libuuid.a
  59. )
  60. # 添加动态库
  61. add_library(space_lib SHARED
  62. ${SPACE_LIB_SRC}
  63. )
  64. # 动态库连接库
  65. target_link_libraries(space_lib
  66. ${Boost_LIBRARIES}
  67. ${SPACE_LIB_LIB}
  68. glog
  69. )
  70. # 生成动态库的版本号
  71. SET_TARGET_PROPERTIES(space_lib PROPERTIES VERSION 1.0.5)
  72. # 添加静态库
  73. add_library(space_lib_static STATIC
  74. ${SPACE_LIB_SRC}
  75. )
  76. # 静态库连接库
  77. target_link_libraries(space_lib_static
  78. ${Boost_LIBRARIES}
  79. ${SPACE_LIB_LIB}
  80. glog
  81. )
  82. # 静态库重新命
  83. SET_TARGET_PROPERTIES(space_lib_static PROPERTIES OUTPUT_NAME "space_lib")
  84. # 安装库
  85. INSTALL(TARGETS space_lib space_lib_static
  86. RUNTIME DESTINATION bin
  87. LIBRARY DESTINATION lib
  88. ARCHIVE DESTINATION libstatic
  89. )
  90. # 安装头文件
  91. INSTALL(DIRECTORY include/space_lib
  92. DESTINATION include
  93. )
  94. # 安装头文件
  95. INSTALL(DIRECTORY include/websocketpp
  96. DESTINATION include
  97. )