CMakeLists.txt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cmake_minimum_required(VERSION 3.12)
  2. #包含源文件
  3. file(GLOB LOCAL_SRC
  4. ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
  5. ${CMAKE_CURRENT_SOURCE_DIR}/common/LHLog/*.cpp
  6. ${CMAKE_CURRENT_SOURCE_DIR}/communication/*.cpp
  7. ${CMAKE_SOURCE_DIR}/External/common/CurlFtp/*.cpp
  8. ${CMAKE_SOURCE_DIR}/External/common/Thread/*.cpp
  9. ${CMAKE_SOURCE_DIR}/External/common/CurlHttp/*.cpp
  10. ${CMAKE_SOURCE_DIR}/External/common/ThreadPool/*.cpp
  11. ${LHQLog_SOURCE_DIRS}/*.cpp
  12. ${LHHTTPAPI_SOURCE_DIRS}/*.cpp
  13. ${SM_SOURCE_DIR}/*.cpp
  14. )
  15. #生成可执行程序
  16. add_executable(${execName1} ${LOCAL_SRC})
  17. #添加头文件
  18. target_include_directories(${execName1} PRIVATE
  19. ${CMAKE_CURRENT_SOURCE_DIR}
  20. ${CMAKE_CURRENT_SOURCE_DIR}/common/LHLog
  21. ${CMAKE_CURRENT_SOURCE_DIR}/communication
  22. ${CMAKE_SOURCE_DIR}/External/common
  23. ${CMAKE_SOURCE_DIR}/External/common/FmtLog
  24. ${CMAKE_SOURCE_DIR}/External/common/CurlFtp
  25. ${CMAKE_SOURCE_DIR}/External/common/Thread
  26. ${CMAKE_SOURCE_DIR}/External/common/CurlHttp
  27. ${CMAKE_SOURCE_DIR}/External/common/RingQueue
  28. ${CMAKE_SOURCE_DIR}/External/common/ThreadPool
  29. ${LHQLog_INCLUDE_DIRS}
  30. ${LHHTTPAPI_SOURCE_DIRS}
  31. ${SM_INCLUDE_DIR}
  32. )
  33. #链接Qt库
  34. target_link_libraries(${execName1} PRIVATE
  35. Qt5::Widgets
  36. Qt5::Core
  37. Qt5::Network
  38. Qt5::Sql
  39. )
  40. #链接外部库
  41. target_link_libraries(${execName1} PRIVATE
  42. fmt::fmt
  43. spdlog::spdlog
  44. CURL::libcurl
  45. ${SM_LIBRARY}
  46. hiredis::hiredis
  47. )
  48. #连接stdc++fs库,如果编译器版本低于GCC9.0,则需要连接这个库
  49. #GCC9.0以上包含进了标准库
  50. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  51. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
  52. target_link_libraries(${execName1} PRIVATE stdc++fs)
  53. endif()
  54. endif()