CMakeLists.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ${CURL_INCLUDE_DIR}
  33. )
  34. #链接Qt库
  35. target_link_libraries(${execName1} PRIVATE
  36. Qt5::Widgets
  37. Qt5::Core
  38. Qt5::Network
  39. Qt5::Sql
  40. )
  41. #链接外部库
  42. target_link_libraries(${execName1} PRIVATE
  43. fmt::fmt
  44. spdlog::spdlog
  45. # CURL::libcurl
  46. ${SM_LIBRARY}
  47. hiredis::hiredis
  48. ${CURL_LIBRARY}
  49. )
  50. #连接stdc++fs库,如果编译器版本低于GCC9.0,则需要连接这个库
  51. #GCC9.0以上包含进了标准库
  52. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  53. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
  54. target_link_libraries(${execName1} PRIVATE stdc++fs)
  55. endif()
  56. endif()