فهرست منبع

build: prepare testbed executable

Michele Caini 11 ماه پیش
والد
کامیت
e80d20a740
4فایلهای تغییر یافته به همراه58 افزوده شده و 19 حذف شده
  1. 18 19
      CMakeLists.txt
  2. 1 0
      TODO
  3. 33 0
      testbed/CMakeLists.txt
  4. 6 0
      testbed/testbed.cpp

+ 18 - 19
CMakeLists.txt

@@ -310,32 +310,31 @@ if(ENTT_INSTALL)
     export(PACKAGE EnTT)
 endif()
 
-# Tests
+# Tests and testbed
 
 option(ENTT_BUILD_TESTING "Enable building tests." OFF)
+option(ENTT_BUILD_TESTBED "Enable building testbed." OFF)
 
-if(ENTT_BUILD_TESTING)
-    option(ENTT_FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
-
-    option(ENTT_BUILD_BENCHMARK "Build benchmark." OFF)
-    option(ENTT_BUILD_EXAMPLE "Build examples." OFF)
-    option(ENTT_BUILD_LIB "Build lib tests." OFF)
-    option(ENTT_BUILD_SNAPSHOT "Build snapshot test with Cereal." OFF)
-
-    set(ENTT_ID_TYPE std::uint32_t CACHE STRING "Type of identifiers to use for the tests")
-    set(ENTT_CXX_STD cxx_std_17 CACHE STRING "C++ standard revision to use for the tests")
+if(ENTT_BUILD_TESTING OR ENTT_BUILD_TESTBED)
+    set(ENTT_ID_TYPE std::uint32_t CACHE STRING "Type of identifiers to use for tests and testbed")
+    set(ENTT_CXX_STD cxx_std_17 CACHE STRING "C++ standard revision to use for tests and testbed")
 
-    include(CTest)
-    enable_testing()
-    add_subdirectory(test)
-endif()
+    if(ENTT_BUILD_TESTING)
+        option(ENTT_FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
 
-# Testbed
+        option(ENTT_BUILD_BENCHMARK "Build benchmark." OFF)
+        option(ENTT_BUILD_EXAMPLE "Build examples." OFF)
+        option(ENTT_BUILD_LIB "Build lib tests." OFF)
+        option(ENTT_BUILD_SNAPSHOT "Build snapshot test with Cereal." OFF)
 
-option(ENTT_BUILD_TESTBED "Enable building testbed." OFF)
+        include(CTest)
+        enable_testing()
+        add_subdirectory(test)
+    endif()
 
-if(ENTT_BUILD_TESTBED)
-    add_subdirectory(testbed)
+    if(ENTT_BUILD_TESTBED)
+        add_subdirectory(testbed)
+    endif()
 endif()
 
 # Documentation

+ 1 - 0
TODO

@@ -35,3 +35,4 @@ TODO:
 * meta non-const allow_cast overloads: (const int &) to (int &) is not allowed, but (const int &) to (double &) is allowed (support only for convertibles)
 * improve non-const allow cast with in-place switch
 * meta fixed_size could return the size directly if present
+* setup testbed workflow on the CI

+ 33 - 0
testbed/CMakeLists.txt

@@ -0,0 +1,33 @@
+# Testbed configuration
+
+add_executable(testbed)
+
+set(ENTT_TESTBED_EXECUTABLE testbed)
+
+set_target_properties(testbed PROPERTIES CXX_EXTENSIONS OFF)
+target_compile_features(testbed PUBLIC ${ENTT_CXX_STD})
+
+target_compile_definitions(
+    ${ENTT_TESTBED_EXECUTABLE}
+    PRIVATE
+        ENTT_ID_TYPE=${ENTT_ID_TYPE}
+        NOMINMAX
+)
+
+target_sources(
+	${ENTT_TESTBED_EXECUTABLE}
+	PRIVATE
+		testbed.cpp
+)
+
+target_link_libraries(
+    ${ENTT_TESTBED_EXECUTABLE}
+    PRIVATE
+        EnTT::EnTT
+)
+
+target_include_directories(
+    ${ENTT_TESTBED_EXECUTABLE}
+    PRIVATE
+        ${testbed_SOURCE_DIR}
+)

+ 6 - 0
testbed/testbed.cpp

@@ -0,0 +1,6 @@
+#include <entt/entt.hpp>
+
+int main() {
+    [[maybe_unused]] entt::registry registry;
+    return 0;
+}