Prechádzať zdrojové kódy

build: testbed initial setup

Michele Caini 11 mesiacov pred
rodič
commit
0e323954e4
3 zmenil súbory, kde vykonal 50 pridanie a 9 odobranie
  1. 6 5
      CMakeLists.txt
  2. 1 1
      TODO
  3. 43 3
      testbed/CMakeLists.txt

+ 6 - 5
CMakeLists.txt

@@ -312,13 +312,18 @@ endif()
 
 # Tests and testbed
 
-option(ENTT_BUILD_TESTING "Enable building tests." OFF)
 option(ENTT_BUILD_TESTBED "Enable building testbed." OFF)
+option(ENTT_BUILD_TESTING "Enable building tests." OFF)
 
 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")
 
+    # Testbed goes first because otherwise SDL gets confused with EnTT tests
+    if(ENTT_BUILD_TESTBED)
+        add_subdirectory(testbed)
+    endif()
+
     if(ENTT_BUILD_TESTING)
         option(ENTT_FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
 
@@ -331,10 +336,6 @@ if(ENTT_BUILD_TESTING OR ENTT_BUILD_TESTBED)
         enable_testing()
         add_subdirectory(test)
     endif()
-
-    if(ENTT_BUILD_TESTBED)
-        add_subdirectory(testbed)
-    endif()
 endif()
 
 # Documentation

+ 1 - 1
TODO

@@ -35,4 +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
+* setup testbed workflow on the CI and review build process for testbed (i.e. tests first due to SDL)

+ 43 - 3
testbed/CMakeLists.txt

@@ -1,11 +1,42 @@
 # Testbed configuration
 
-add_executable(testbed)
+include(FetchContent)
+
+# Fetch SDL3
+
+FetchContent_Declare(
+    SDL3
+    GIT_REPOSITORY https://github.com/libsdl-org/SDL
+    GIT_TAG release-3.2.8
+    GIT_SHALLOW 1
+)
+
+FetchContent_MakeAvailable(SDL3)
+
+# Fetch ImGui
+
+FetchContent_Declare(
+    imgui
+    GIT_REPOSITORY https://github.com/ocornut/imgui
+    GIT_TAG v1.91.9
+    GIT_SHALLOW 1
+)
+
+FetchContent_GetProperties(imgui)
+
+if(NOT imgui_POPULATED)
+    FetchContent_Populate(imgui)
+    set(imgui_INCLUDE_DIR ${imgui_SOURCE_DIR})
+endif()
+
+# Testbed executable
 
 set(ENTT_TESTBED_EXECUTABLE testbed)
 
-set_target_properties(testbed PROPERTIES CXX_EXTENSIONS OFF)
-target_compile_features(testbed PUBLIC ${ENTT_CXX_STD})
+add_executable(${ENTT_TESTBED_EXECUTABLE})
+
+set_target_properties(${ENTT_TESTBED_EXECUTABLE} PROPERTIES CXX_EXTENSIONS OFF)
+target_compile_features(${ENTT_TESTBED_EXECUTABLE} PUBLIC ${ENTT_CXX_STD})
 
 target_compile_definitions(
     ${ENTT_TESTBED_EXECUTABLE}
@@ -18,16 +49,25 @@ target_sources(
 	${ENTT_TESTBED_EXECUTABLE}
 	PRIVATE
 		testbed.cpp
+        ${imgui_SOURCE_DIR}/imgui.cpp
+        ${imgui_SOURCE_DIR}/imgui_demo.cpp
+        ${imgui_SOURCE_DIR}/imgui_draw.cpp
+        ${imgui_SOURCE_DIR}/imgui_tables.cpp
+        ${imgui_SOURCE_DIR}/imgui_widgets.cpp
+        ${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
+        ${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
 )
 
 target_link_libraries(
     ${ENTT_TESTBED_EXECUTABLE}
     PRIVATE
         EnTT::EnTT
+        SDL3::SDL3
 )
 
 target_include_directories(
     ${ENTT_TESTBED_EXECUTABLE}
     PRIVATE
         ${testbed_SOURCE_DIR}
+        ${imgui_SOURCE_DIR}
 )