eliasdaler

FetchContent

Aug 21st, 2018
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.73 KB | None | 0 0
  1. include(FetchContent)
  2.  
  3. #=====================================
  4. # Helper functions and macros
  5. #=====================================
  6.  
  7. # Supresses all messages
  8. function(message)
  9.   if (NOT MESSAGE_QUIET)
  10.     _message(${ARGN})
  11.   endif()
  12. endfunction()
  13.  
  14. # Adds external dependency into a project
  15. # If FETCHCONTENT_QUIET is true, does it quietly (e.g. without telling that X feature is found)
  16. function(add_external_dependency dependency)
  17.   if (FETCHCONTENT_QUIET)
  18.     set(MESSAGE_QUIET ON)
  19.   endif()
  20.  
  21.   add_subdirectory(${${dependency}_SOURCE_DIR} ${${dependency}_BINARY_DIR})
  22.  
  23.   if (FETCHCONTENT_QUIET)
  24.     set(MESSAGE_QUIET OFF)
  25.   endif()
  26. endfunction()
  27.  
  28. #=====================================
  29. # Options and initial settings
  30. #=====================================
  31.  
  32. message(STATUS "Fetching third party libraries")
  33. option(USE_SYSTEM_DEPS CACHE ON)
  34. option(LINK_DEPS_STATIC CACHE ON)
  35.  
  36. if (NOT LINK_DEPS_STATIC)
  37.   set(BUILD_SHARED_LIBS ON)
  38. endif()
  39.  
  40. #=====================================
  41. # Versions of external libs
  42. #=====================================
  43.  
  44. set(NLOHMANN_JSON_VERSION 3.1.2)
  45. set(SFML_VERSION 2.5.0)
  46. set(FMT_VERSION 5.1.0)
  47. set(SOL2_VERSION 2.20.4)
  48. set(IMGUI_VERSION 1.62)
  49. set(IMGUI_SFML_VERSION 1.0)
  50. set(LUA_VERSION 5.2.4)
  51.  
  52. #=====================================
  53. # FetchContent declarations
  54. #=====================================
  55.  
  56. FetchContent_Declare(
  57.   nlohmann_json
  58.   URL "https://github.com/nlohmann/json/releases/download/v${NLOHMANN_JSON_VERSION}/include.zip"
  59. )
  60.  
  61. FetchContent_Declare(
  62.   SFML
  63.   URL "https://github.com/SFML/SFML/archive/${SFML_VERSION}.zip"
  64. )
  65.  
  66. FetchContent_Declare(
  67.   fmt
  68.   URL "https://github.com/fmtlib/fmt/releases/download/${FMT_VERSION}/fmt-${FMT_VERSION}.zip"
  69. )
  70.  
  71. FetchContent_Declare(
  72.   sol2
  73.   URL "https://github.com/ThePhD/sol2/archive/v${SOL2_VERSION}.zip"
  74. )
  75.  
  76. FetchContent_Declare(
  77.   imgui
  78.   URL "https://github.com/ocornut/imgui/archive/v${IMGUI_VERSION}.zip"
  79. )
  80.  
  81. FetchContent_Declare(
  82.   imgui-sfml
  83.   GIT_REPOSITORY https://github.com/eliasdaler/imgui-sfml.git
  84.   GIT_TAG        modern-cmake
  85. )
  86.  
  87. FetchContent_Declare(
  88.   metastuff
  89.   GIT_REPOSITORY https://github.com/eliasdaler/MetaStuff
  90.   GIT_TAG        cmake
  91. )
  92.  
  93. FetchContent_Declare(
  94.   googletest
  95.   GIT_REPOSITORY https://github.com/google/googletest
  96.   GIT_TAG        735bd75f69f8a1c6240c95915edfa091bfa976ac
  97. )
  98.  
  99. #=====================================
  100.  
  101. add_subdirectory(googletest)
  102.  
  103. add_subdirectory(sfml)
  104. add_subdirectory(imgui)
  105. add_subdirectory(imgui-sfml)
  106.  
  107. add_subdirectory(lua)
  108. add_subdirectory(sol2)
  109.  
  110. # header only libs
  111. add_subdirectory(fmt)
  112. add_subdirectory(metastuff)
  113. add_subdirectory(nlohmann_json)
  114.  
  115. #=====================================
  116.  
  117. message(STATUS "Fetching thirdparty libraries done")
Advertisement
Add Comment
Please, Sign In to add comment