Skip to content

Commit

Permalink
imgui: move Objective-C++ backends to a separate test
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Sep 23, 2024
1 parent f8fcc2e commit 57dc335
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
11 changes: 9 additions & 2 deletions recipes/imgui/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(imgui REQUIRED CONFIG)

add_compile_definitions("IMGUI_USER_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/my_imgui_config.h\"")
add_executable(${PROJECT_NAME} test_package.cpp)
# Using the aggregate target for easier testing.
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui_all)
target_compile_definitions(${PROJECT_NAME} PUBLIC "IMGUI_USER_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/my_imgui_config.h\"")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

if(APPLE)
enable_language(OBJCXX)
add_executable(${PROJECT_NAME}_objcxx test_package.mm)
target_link_libraries(${PROJECT_NAME}_objcxx PRIVATE imgui::imgui_all)
target_compile_features(${PROJECT_NAME}_objcxx PRIVATE cxx_std_11)
endif()
8 changes: 6 additions & 2 deletions recipes/imgui/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
import os
import re


class TestPackageConan(ConanFile):
Expand Down Expand Up @@ -56,5 +56,9 @@ def build(self):

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")

if is_apple_os(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package_objcxx")
self.run(bin_path, env="conanrun")
12 changes: 0 additions & 12 deletions recipes/imgui/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@
#ifdef IMGUI_IMPL_GLUT
#include <imgui_impl_glut.h>
#endif
#ifdef IMGUI_IMPL_METAL
#include <imgui_impl_metal.h>
#endif
#ifdef IMGUI_IMPL_OPENGL2
#include <imgui_impl_opengl2.h>
#endif
#ifdef IMGUI_IMPL_OPENGL3
#include <imgui_impl_opengl3.h>
#endif
#ifdef IMGUI_IMPL_OSX
#include <imgui_impl_osx.h>
#endif
#ifdef IMGUI_IMPL_SDL2
#include <imgui_impl_sdl2.h>
#endif
Expand Down Expand Up @@ -86,18 +80,12 @@ void test_backends() {
#ifdef IMGUI_IMPL_GLUT
ImGui_ImplGLUT_Shutdown();
#endif
#ifdef IMGUI_IMPL_METAL
ImGui_ImplMetal_Shutdown();
#endif
#ifdef IMGUI_IMPL_OPENGL2
ImGui_ImplOpenGL2_Shutdown();
#endif
#ifdef IMGUI_IMPL_OPENGL3
ImGui_ImplOpenGL3_Shutdown();
#endif
#ifdef IMGUI_IMPL_OSX
ImGui_ImplOSX_Shutdown();
#endif
#ifdef IMGUI_IMPL_SDL2
ImGui_ImplSDL2_Shutdown();
#endif
Expand Down
33 changes: 33 additions & 0 deletions recipes/imgui/all/test_package/test_package.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <imgui.h>

#ifdef DOCKING
#include <imgui_internal.h>
#endif

#ifdef IMGUI_IMPL_OSX
#include <imgui_impl_osx.h>
#endif
#ifdef IMGUI_IMPL_METAL
#include <imgui_impl_metal.h>
#endif

#include <cstdio>

void test_backends() {
#ifdef IMGUI_IMPL_OSX
ImGui_ImplOSX_Shutdown();
#endif
#ifdef IMGUI_IMPL_METAL
ImGui_ImplMetal_Shutdown();
#endif
}

int main() {
printf("IMGUI VERSION: %s\n", IMGUI_VERSION);
ImGui::CreateContext();
#ifdef DOCKING
printf(" with docking\n");
#endif
ImGui::DestroyContext();
return 0;
}

0 comments on commit 57dc335

Please sign in to comment.