CMakeLists.txt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/FmtLog
  23. ${CMAKE_SOURCE_DIR}/External/common/CurlFtp
  24. ${CMAKE_SOURCE_DIR}/External/common/Thread
  25. ${CMAKE_SOURCE_DIR}/External/common/CurlHttp
  26. ${CMAKE_SOURCE_DIR}/External/common/threadPool
  27. ${CMAKE_SOURCE_DIR}/External/common/RingQueue
  28. ${LHQLog_INCLUDE_DIRS}
  29. ${LHHTTPAPI_SOURCE_DIRS}
  30. ${SM_INCLUDE_DIR}
  31. )
  32. #链接Qt库
  33. target_link_libraries(${execName1} PRIVATE
  34. Qt5::Widgets
  35. Qt5::Core
  36. Qt5::Network
  37. Qt5::Sql
  38. )
  39. #链接外部库
  40. target_link_libraries(${execName1} PRIVATE
  41. fmt::fmt
  42. spdlog::spdlog
  43. CURL::libcurl
  44. ${SM_LIBRARY}
  45. hiredis::hiredis
  46. )
  47. #连接stdc++fs库,如果编译器版本低于GCC9.0,则需要连接这个库
  48. #GCC9.0以上包含进了标准库
  49. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  50. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
  51. target_link_libraries(${execName1} PRIVATE stdc++fs)
  52. endif()
  53. endif()