🛠️🐜 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.

262 lines
8.0 KiB

  1. #
  2. # Tests configuration
  3. #
  4. include(FetchContent)
  5. include(CheckCXXSourceCompiles)
  6. check_cxx_source_compiles("
  7. #include<version>
  8. int main() { return 0; }
  9. " ENTT_HAS_HEADER_VERSION)
  10. set(THREADS_PREFER_PTHREAD_FLAG ON)
  11. find_package(Threads REQUIRED)
  12. if(ENTT_FIND_GTEST_PACKAGE)
  13. find_package(GTest REQUIRED)
  14. else()
  15. FetchContent_Declare(
  16. googletest
  17. GIT_REPOSITORY https://github.com/google/googletest.git
  18. GIT_TAG main
  19. GIT_SHALLOW 1
  20. )
  21. FetchContent_GetProperties(googletest)
  22. if(NOT googletest_POPULATED)
  23. FetchContent_Populate(googletest)
  24. set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  25. add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
  26. endif()
  27. add_library(GTest::Main ALIAS gtest_main)
  28. target_compile_features(gtest PUBLIC cxx_std_17)
  29. target_compile_features(gtest_main PUBLIC cxx_std_17)
  30. target_compile_features(gmock PUBLIC cxx_std_17)
  31. target_compile_features(gmock_main PUBLIC cxx_std_17)
  32. endif()
  33. include_directories($<TARGET_PROPERTY:EnTT,INTERFACE_INCLUDE_DIRECTORIES>)
  34. add_compile_options($<TARGET_PROPERTY:EnTT,INTERFACE_COMPILE_OPTIONS>)
  35. function(SETUP_TARGET TARGET_NAME)
  36. set_target_properties(${TARGET_NAME} PROPERTIES CXX_EXTENSIONS OFF)
  37. target_compile_features(${TARGET_NAME} PRIVATE ${ENTT_CXX_STD})
  38. target_link_libraries(${TARGET_NAME} PRIVATE EnTT)
  39. if(MSVC)
  40. target_compile_options(
  41. ${TARGET_NAME}
  42. PRIVATE
  43. /EHsc /W1 /wd4996 /w14800
  44. $<$<CONFIG:Debug>:/Od>
  45. $<$<CONFIG:Release>:/O2>
  46. )
  47. else()
  48. target_compile_options(
  49. ${TARGET_NAME}
  50. PRIVATE
  51. -pedantic -fvisibility=hidden -Wall -Wshadow -Wno-deprecated-declarations
  52. $<$<CONFIG:Debug>:-O0 -g>
  53. $<$<CONFIG:Release>:-O2>
  54. )
  55. endif()
  56. target_compile_definitions(
  57. ${TARGET_NAME}
  58. PRIVATE
  59. ENTT_ID_TYPE=${ENTT_ID_TYPE}
  60. _ENABLE_EXTENDED_ALIGNED_STORAGE
  61. NOMINMAX
  62. ${ARGN}
  63. )
  64. if(ENTT_HAS_HEADER_VERSION)
  65. target_compile_definitions(
  66. ${TARGET_NAME}
  67. PRIVATE
  68. ENTT_HAS_HEADER_VERSION
  69. )
  70. endif()
  71. endfunction()
  72. add_library(odr OBJECT odr.cpp)
  73. SETUP_TARGET(odr)
  74. function(SETUP_BASIC_TEST TEST_NAME TEST_SOURCES)
  75. add_executable(${TEST_NAME} $<TARGET_OBJECTS:odr> ${TEST_SOURCES})
  76. target_link_libraries(${TEST_NAME} PRIVATE GTest::Main Threads::Threads)
  77. SETUP_TARGET(${TEST_NAME} ${ARGN})
  78. add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
  79. endfunction()
  80. function(SETUP_LIB_TEST TEST_NAME)
  81. add_library(_${TEST_NAME} SHARED $<TARGET_OBJECTS:odr> lib/${TEST_NAME}/lib.cpp)
  82. SETUP_TARGET(_${TEST_NAME} ENTT_API_EXPORT)
  83. SETUP_BASIC_TEST(lib_${TEST_NAME} lib/${TEST_NAME}/main.cpp ENTT_API_IMPORT)
  84. target_link_libraries(lib_${TEST_NAME} PRIVATE _${TEST_NAME})
  85. endfunction()
  86. function(SETUP_PLUGIN_TEST TEST_NAME)
  87. add_library(_${TEST_NAME} MODULE $<TARGET_OBJECTS:odr> lib/${TEST_NAME}/plugin.cpp)
  88. SETUP_TARGET(_${TEST_NAME} ${ARGVN})
  89. SETUP_BASIC_TEST(lib_${TEST_NAME} lib/${TEST_NAME}/main.cpp PLUGIN="$<TARGET_FILE:_${TEST_NAME}>" ${ARGVN})
  90. target_include_directories(_${TEST_NAME} PRIVATE ${cr_INCLUDE_DIR})
  91. target_include_directories(lib_${TEST_NAME} PRIVATE ${cr_INCLUDE_DIR})
  92. target_link_libraries(lib_${TEST_NAME} PRIVATE ${CMAKE_DL_LIBS})
  93. endfunction()
  94. # Test benchmark
  95. if(ENTT_BUILD_BENCHMARK)
  96. SETUP_BASIC_TEST(benchmark benchmark/benchmark.cpp)
  97. endif()
  98. # Test example
  99. if(ENTT_BUILD_EXAMPLE)
  100. SETUP_BASIC_TEST(custom_identifier example/custom_identifier.cpp)
  101. SETUP_BASIC_TEST(entity_copy example/entity_copy.cpp)
  102. SETUP_BASIC_TEST(signal_less example/signal_less.cpp)
  103. endif()
  104. # Test lib
  105. if(ENTT_BUILD_LIB)
  106. FetchContent_Declare(
  107. cr
  108. GIT_REPOSITORY https://github.com/fungos/cr.git
  109. GIT_TAG master
  110. GIT_SHALLOW 1
  111. )
  112. FetchContent_GetProperties(cr)
  113. if(NOT cr_POPULATED)
  114. FetchContent_Populate(cr)
  115. set(cr_INCLUDE_DIR ${cr_SOURCE_DIR})
  116. endif()
  117. SETUP_LIB_TEST(dispatcher)
  118. SETUP_LIB_TEST(emitter)
  119. SETUP_LIB_TEST(meta)
  120. SETUP_LIB_TEST(registry)
  121. SETUP_PLUGIN_TEST(dispatcher_plugin)
  122. SETUP_PLUGIN_TEST(emitter_plugin)
  123. SETUP_PLUGIN_TEST(meta_plugin)
  124. SETUP_PLUGIN_TEST(registry_plugin)
  125. SETUP_PLUGIN_TEST(meta_plugin_std ENTT_STANDARD_CPP)
  126. endif()
  127. # Test snapshot
  128. if(ENTT_BUILD_SNAPSHOT)
  129. FetchContent_Declare(
  130. cereal
  131. GIT_REPOSITORY https://github.com/USCiLab/cereal.git
  132. GIT_TAG v1.2.2
  133. GIT_SHALLOW 1
  134. )
  135. FetchContent_GetProperties(cereal)
  136. if(NOT cereal_POPULATED)
  137. FetchContent_Populate(cereal)
  138. set(cereal_INCLUDE_DIR ${cereal_SOURCE_DIR}/include)
  139. endif()
  140. SETUP_BASIC_TEST(cereal snapshot/snapshot.cpp)
  141. target_include_directories(cereal PRIVATE ${cereal_INCLUDE_DIR})
  142. endif()
  143. # Test config
  144. SETUP_BASIC_TEST(version entt/config/version.cpp)
  145. # Test container
  146. SETUP_BASIC_TEST(dense_map entt/container/dense_map.cpp)
  147. SETUP_BASIC_TEST(dense_set entt/container/dense_set.cpp)
  148. # Test core
  149. SETUP_BASIC_TEST(algorithm entt/core/algorithm.cpp)
  150. SETUP_BASIC_TEST(any entt/core/any.cpp)
  151. SETUP_BASIC_TEST(compressed_pair entt/core/compressed_pair.cpp)
  152. SETUP_BASIC_TEST(enum entt/core/enum.cpp)
  153. SETUP_BASIC_TEST(family entt/core/family.cpp)
  154. SETUP_BASIC_TEST(hashed_string entt/core/hashed_string.cpp)
  155. SETUP_BASIC_TEST(ident entt/core/ident.cpp)
  156. SETUP_BASIC_TEST(iterator entt/core/iterator.cpp)
  157. SETUP_BASIC_TEST(memory entt/core/memory.cpp)
  158. SETUP_BASIC_TEST(monostate entt/core/monostate.cpp)
  159. SETUP_BASIC_TEST(tuple entt/core/tuple.cpp)
  160. SETUP_BASIC_TEST(type_info entt/core/type_info.cpp)
  161. SETUP_BASIC_TEST(type_traits entt/core/type_traits.cpp)
  162. SETUP_BASIC_TEST(utility entt/core/utility.cpp)
  163. # Test entity
  164. SETUP_BASIC_TEST(component entt/entity/component.cpp)
  165. SETUP_BASIC_TEST(entity entt/entity/entity.cpp)
  166. SETUP_BASIC_TEST(group entt/entity/group.cpp)
  167. SETUP_BASIC_TEST(handle entt/entity/handle.cpp)
  168. SETUP_BASIC_TEST(helper entt/entity/helper.cpp)
  169. SETUP_BASIC_TEST(observer entt/entity/observer.cpp)
  170. SETUP_BASIC_TEST(organizer entt/entity/organizer.cpp)
  171. SETUP_BASIC_TEST(registry entt/entity/registry.cpp)
  172. SETUP_BASIC_TEST(runtime_view entt/entity/runtime_view.cpp)
  173. SETUP_BASIC_TEST(sigh_storage_mixin entt/entity/sigh_storage_mixin.cpp)
  174. SETUP_BASIC_TEST(snapshot entt/entity/snapshot.cpp)
  175. SETUP_BASIC_TEST(sparse_set entt/entity/sparse_set.cpp)
  176. SETUP_BASIC_TEST(storage entt/entity/storage.cpp)
  177. SETUP_BASIC_TEST(view entt/entity/view.cpp)
  178. # Test locator
  179. SETUP_BASIC_TEST(locator entt/locator/locator.cpp)
  180. # Test meta
  181. SETUP_BASIC_TEST(meta_any entt/meta/meta_any.cpp)
  182. SETUP_BASIC_TEST(meta_base entt/meta/meta_base.cpp)
  183. SETUP_BASIC_TEST(meta_container entt/meta/meta_container.cpp)
  184. SETUP_BASIC_TEST(meta_conv entt/meta/meta_conv.cpp)
  185. SETUP_BASIC_TEST(meta_ctor entt/meta/meta_ctor.cpp)
  186. SETUP_BASIC_TEST(meta_data entt/meta/meta_data.cpp)
  187. SETUP_BASIC_TEST(meta_dtor entt/meta/meta_dtor.cpp)
  188. SETUP_BASIC_TEST(meta_func entt/meta/meta_func.cpp)
  189. SETUP_BASIC_TEST(meta_handle entt/meta/meta_handle.cpp)
  190. SETUP_BASIC_TEST(meta_pointer entt/meta/meta_pointer.cpp)
  191. SETUP_BASIC_TEST(meta_prop entt/meta/meta_prop.cpp)
  192. SETUP_BASIC_TEST(meta_range entt/meta/meta_range.cpp)
  193. SETUP_BASIC_TEST(meta_template entt/meta/meta_template.cpp)
  194. SETUP_BASIC_TEST(meta_type entt/meta/meta_type.cpp)
  195. SETUP_BASIC_TEST(meta_utility entt/meta/meta_utility.cpp)
  196. # Test poly
  197. SETUP_BASIC_TEST(poly entt/poly/poly.cpp)
  198. # Test process
  199. SETUP_BASIC_TEST(process entt/process/process.cpp)
  200. SETUP_BASIC_TEST(scheduler entt/process/scheduler.cpp)
  201. # Test resource
  202. SETUP_BASIC_TEST(resource entt/resource/resource.cpp)
  203. SETUP_BASIC_TEST(resource_cache entt/resource/resource_cache.cpp)
  204. SETUP_BASIC_TEST(resource_loader entt/resource/resource_loader.cpp)
  205. # Test signal
  206. SETUP_BASIC_TEST(delegate entt/signal/delegate.cpp)
  207. SETUP_BASIC_TEST(dispatcher entt/signal/dispatcher.cpp)
  208. SETUP_BASIC_TEST(emitter entt/signal/emitter.cpp)
  209. SETUP_BASIC_TEST(sigh entt/signal/sigh.cpp)