diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt index d1d70c69f26349..3c687295fb27c1 100644 --- a/recipes/imgui/all/test_package/CMakeLists.txt +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -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) + target_sources(${PROJECT_NAME}_objcxx PRIVATE test_package.mm) + target_link_libraries(${PROJECT_NAME}_objcxx PRIVATE imgui::imgui_all) + target_compile_features(${PROJECT_NAME}_objcxx PRIVATE cxx_std_11) +endif() diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index 75c7df8e6198ce..c450d7c3758a8b 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -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): @@ -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") diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp index 37a6bce806623f..26d62cfba7375f 100644 --- a/recipes/imgui/all/test_package/test_package.cpp +++ b/recipes/imgui/all/test_package/test_package.cpp @@ -28,18 +28,12 @@ #ifdef IMGUI_IMPL_GLUT #include #endif -#ifdef IMGUI_IMPL_METAL - #include -#endif #ifdef IMGUI_IMPL_OPENGL2 #include #endif #ifdef IMGUI_IMPL_OPENGL3 #include #endif -#ifdef IMGUI_IMPL_OSX - #include -#endif #ifdef IMGUI_IMPL_SDL2 #include #endif @@ -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 diff --git a/recipes/imgui/all/test_package/test_package.mm b/recipes/imgui/all/test_package/test_package.mm new file mode 100644 index 00000000000000..56feca5cbfd6c6 --- /dev/null +++ b/recipes/imgui/all/test_package/test_package.mm @@ -0,0 +1,33 @@ +#include + +#ifdef DOCKING + #include +#endif + +#ifdef IMGUI_IMPL_OSX + #include +#endif +#ifdef IMGUI_IMPL_METAL + #include +#endif + +#include + +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; +}