🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
12 KiB

  1. #
  2. # EnTT
  3. #
  4. cmake_minimum_required(VERSION 3.12.4)
  5. #
  6. # Read project version
  7. #
  8. set(ENTT_VERSION_REGEX "#define ENTT_VERSION_.*[ \t]+(.+)")
  9. file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/entt/config/version.h" ENTT_VERSION REGEX ${ENTT_VERSION_REGEX})
  10. list(TRANSFORM ENTT_VERSION REPLACE ${ENTT_VERSION_REGEX} "\\1")
  11. string(JOIN "." ENTT_VERSION ${ENTT_VERSION})
  12. #
  13. # Project configuration
  14. #
  15. project(
  16. EnTT
  17. VERSION ${ENTT_VERSION}
  18. DESCRIPTION "Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more"
  19. HOMEPAGE_URL "https://github.com/skypjack/entt"
  20. LANGUAGES C CXX
  21. )
  22. if(NOT CMAKE_BUILD_TYPE)
  23. set(CMAKE_BUILD_TYPE Debug)
  24. endif()
  25. message(VERBOSE "*")
  26. message(VERBOSE "* ${PROJECT_NAME} v${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
  27. message(VERBOSE "* Copyright (c) 2017-2022 Michele Caini <michele.caini@gmail.com>")
  28. message(VERBOSE "*")
  29. #
  30. # Compiler stuff
  31. #
  32. option(ENTT_USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if available." OFF)
  33. option(ENTT_USE_SANITIZER "Enable sanitizers by adding -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined flags if available." OFF)
  34. if(ENTT_USE_LIBCPP)
  35. if(NOT WIN32)
  36. include(CheckCXXSourceCompiles)
  37. include(CMakePushCheckState)
  38. cmake_push_check_state()
  39. set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -stdlib=libc++")
  40. check_cxx_source_compiles("
  41. #include<type_traits>
  42. int main() { return std::is_same_v<int, char>; }
  43. " ENTT_HAS_LIBCPP)
  44. cmake_pop_check_state()
  45. endif()
  46. if(NOT ENTT_HAS_LIBCPP)
  47. message(VERBOSE "The option ENTT_USE_LIBCPP is set but libc++ is not available. The flag will not be added to the target.")
  48. endif()
  49. endif()
  50. if(ENTT_USE_SANITIZER)
  51. if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
  52. set(ENTT_HAS_SANITIZER TRUE CACHE BOOL "" FORCE)
  53. mark_as_advanced(ENTT_HAS_SANITIZER)
  54. endif()
  55. if(NOT ENTT_HAS_SANITIZER)
  56. message(VERBOSE "The option ENTT_USE_SANITIZER is set but sanitizer support is not available. The flags will not be added to the target.")
  57. endif()
  58. endif()
  59. #
  60. # Add EnTT target
  61. #
  62. option(ENTT_INCLUDE_HEADERS "Add all EnTT headers to the EnTT target." OFF)
  63. option(ENTT_INCLUDE_NATVIS "Add EnTT natvis files to the EnTT target." OFF)
  64. if(ENTT_INCLUDE_NATVIS)
  65. if(MSVC)
  66. set(ENTT_HAS_NATVIS TRUE CACHE BOOL "" FORCE)
  67. mark_as_advanced(ENTT_HAS_NATVIS)
  68. endif()
  69. if(NOT ENTT_HAS_NATVIS)
  70. message(VERBOSE "The option ENTT_INCLUDE_NATVIS is set but natvis files are not supported. They will not be added to the target.")
  71. endif()
  72. endif()
  73. include(GNUInstallDirs)
  74. add_library(EnTT INTERFACE)
  75. add_library(EnTT::EnTT ALIAS EnTT)
  76. target_include_directories(
  77. EnTT
  78. INTERFACE
  79. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src>
  80. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  81. )
  82. target_compile_features(EnTT INTERFACE cxx_std_17)
  83. if(ENTT_INCLUDE_HEADERS)
  84. target_sources(
  85. EnTT
  86. INTERFACE
  87. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/config/config.h>
  88. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/config/macro.h>
  89. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/config/version.h>
  90. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_map.hpp>
  91. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/dense_set.hpp>
  92. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/container/fwd.hpp>
  93. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/algorithm.hpp>
  94. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/any.hpp>
  95. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/attribute.h>
  96. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/compressed_pair.hpp>
  97. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/enum.hpp>
  98. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/family.hpp>
  99. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/fwd.hpp>
  100. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/hashed_string.hpp>
  101. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/ident.hpp>
  102. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/iterator.hpp>
  103. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/memory.hpp>
  104. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/monostate.hpp>
  105. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/tuple.hpp>
  106. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/type_info.hpp>
  107. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/type_traits.hpp>
  108. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/core/utility.hpp>
  109. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/component.hpp>
  110. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/entity.hpp>
  111. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/fwd.hpp>
  112. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/group.hpp>
  113. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/handle.hpp>
  114. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/helper.hpp>
  115. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/observer.hpp>
  116. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/organizer.hpp>
  117. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/registry.hpp>
  118. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/runtime_view.hpp>
  119. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/sigh_storage_mixin.hpp>
  120. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/snapshot.hpp>
  121. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/sparse_set.hpp>
  122. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/storage.hpp>
  123. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/utility.hpp>
  124. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entity/view.hpp>
  125. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/locator/locator.hpp>
  126. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/adl_pointer.hpp>
  127. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/container.hpp>
  128. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/ctx.hpp>
  129. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/factory.hpp>
  130. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/fwd.hpp>
  131. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/meta.hpp>
  132. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/node.hpp>
  133. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/pointer.hpp>
  134. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/policy.hpp>
  135. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/range.hpp>
  136. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/resolve.hpp>
  137. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/template.hpp>
  138. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/type_traits.hpp>
  139. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/meta/utility.hpp>
  140. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/platform/android-ndk-r17.hpp>
  141. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/poly/fwd.hpp>
  142. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/poly/poly.hpp>
  143. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/process/process.hpp>
  144. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/process/scheduler.hpp>
  145. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/resource/cache.hpp>
  146. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/resource/fwd.hpp>
  147. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/resource/loader.hpp>
  148. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/resource/resource.hpp>
  149. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/signal/delegate.hpp>
  150. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/signal/dispatcher.hpp>
  151. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/signal/emitter.hpp>
  152. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/signal/fwd.hpp>
  153. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/signal/sigh.hpp>
  154. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/entt.hpp>
  155. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/src/entt/fwd.hpp>
  156. )
  157. endif()
  158. if(ENTT_HAS_NATVIS)
  159. target_sources(
  160. EnTT
  161. INTERFACE
  162. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/config.natvis>
  163. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/container.natvis>
  164. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/core.natvis>
  165. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/entity.natvis>
  166. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/locator.natvis>
  167. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/meta.natvis>
  168. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/platform.natvis>
  169. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/poly.natvis>
  170. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/process.natvis>
  171. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/resource.natvis>
  172. $<BUILD_INTERFACE:${EnTT_SOURCE_DIR}/natvis/entt/signal.natvis>
  173. )
  174. endif()
  175. if(ENTT_HAS_SANITIZER)
  176. target_compile_options(EnTT INTERFACE $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined>)
  177. target_link_libraries(EnTT INTERFACE $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined>)
  178. endif()
  179. if(ENTT_HAS_LIBCPP)
  180. target_compile_options(EnTT BEFORE INTERFACE -stdlib=libc++)
  181. endif()
  182. #
  183. # Install pkg-config file
  184. #
  185. set(EnTT_PKGCONFIG ${CMAKE_CURRENT_BINARY_DIR}/entt.pc)
  186. configure_file(
  187. ${EnTT_SOURCE_DIR}/cmake/in/entt.pc.in
  188. ${EnTT_PKGCONFIG}
  189. @ONLY
  190. )
  191. install(
  192. FILES ${EnTT_PKGCONFIG}
  193. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
  194. )
  195. #
  196. # Install EnTT
  197. #
  198. include(CMakePackageConfigHelpers)
  199. install(
  200. TARGETS EnTT
  201. EXPORT EnTTTargets
  202. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  203. )
  204. write_basic_package_version_file(
  205. EnTTConfigVersion.cmake
  206. VERSION ${PROJECT_VERSION}
  207. COMPATIBILITY AnyNewerVersion
  208. )
  209. configure_package_config_file(
  210. ${EnTT_SOURCE_DIR}/cmake/in/EnTTConfig.cmake.in
  211. EnTTConfig.cmake
  212. INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/EnTT/cmake
  213. )
  214. export(
  215. EXPORT EnTTTargets
  216. FILE ${CMAKE_CURRENT_BINARY_DIR}/EnTTTargets.cmake
  217. NAMESPACE EnTT::
  218. )
  219. install(
  220. EXPORT EnTTTargets
  221. FILE EnTTTargets.cmake
  222. DESTINATION ${CMAKE_INSTALL_LIBDIR}/EnTT/cmake
  223. NAMESPACE EnTT::
  224. )
  225. install(
  226. FILES
  227. ${PROJECT_BINARY_DIR}/EnTTConfig.cmake
  228. ${PROJECT_BINARY_DIR}/EnTTConfigVersion.cmake
  229. DESTINATION ${CMAKE_INSTALL_LIBDIR}/EnTT/cmake
  230. )
  231. install(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  232. export(PACKAGE EnTT)
  233. #
  234. # Tests
  235. #
  236. option(ENTT_BUILD_TESTING "Enable building tests." OFF)
  237. if(ENTT_BUILD_TESTING)
  238. option(ENTT_FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
  239. option(ENTT_BUILD_BENCHMARK "Build benchmark." OFF)
  240. option(ENTT_BUILD_EXAMPLE "Build examples." OFF)
  241. option(ENTT_BUILD_LIB "Build lib tests." OFF)
  242. option(ENTT_BUILD_SNAPSHOT "Build snapshot test with Cereal." OFF)
  243. set(ENTT_ID_TYPE std::uint32_t CACHE STRING "Type of identifiers to use for the tests")
  244. set(ENTT_CXX_STD cxx_std_17 CACHE STRING "C++ standard revision to use for the tests")
  245. include(CTest)
  246. enable_testing()
  247. add_subdirectory(test)
  248. endif()
  249. #
  250. # Documentation
  251. #
  252. option(ENTT_BUILD_DOCS "Enable building with documentation." OFF)
  253. if(ENTT_BUILD_DOCS)
  254. find_package(Doxygen 1.8)
  255. if(DOXYGEN_FOUND)
  256. add_subdirectory(docs)
  257. endif()
  258. endif()
  259. #
  260. # AOB
  261. #
  262. add_custom_target(
  263. aob
  264. SOURCES
  265. .github/workflows/build.yml
  266. .github/workflows/coverage.yml
  267. .github/workflows/deploy.yml
  268. .github/workflows/sanitizer.yml
  269. .github/FUNDING.yml
  270. AUTHORS
  271. CONTRIBUTING.md
  272. LICENSE
  273. README.md
  274. TODO
  275. )