From cc10a1ae4941e3359815003fd0294d14c5d0339c Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Mon, 9 Oct 2023 13:21:58 +0200 Subject: [PATCH] if python, add test_engine specific lib for python (imgui_test_engine_py) --- external/imgui_test_engine | 2 +- hello_imgui_cmake/hello_imgui_add_app.cmake | 4 ++++ .../hello_imgui_test_engine_cmake.cmake | 19 ++++++++++++++----- src/hello_imgui_tests/CMakeLists.txt | 3 +++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/external/imgui_test_engine b/external/imgui_test_engine index d3f01256..51947360 160000 --- a/external/imgui_test_engine +++ b/external/imgui_test_engine @@ -1 +1 @@ -Subproject commit d3f012566191685a4aa1c0d50bad902b0a178d79 +Subproject commit 51947360d7d2c229d8a702806a086404b085f182 diff --git a/hello_imgui_cmake/hello_imgui_add_app.cmake b/hello_imgui_cmake/hello_imgui_add_app.cmake index 41dd85ca..483f9f4b 100644 --- a/hello_imgui_cmake/hello_imgui_add_app.cmake +++ b/hello_imgui_cmake/hello_imgui_add_app.cmake @@ -51,6 +51,10 @@ function(hello_imgui_prepare_app app_name) hello_imgui_platform_customization(${app_name}) target_link_libraries(${app_name} PRIVATE hello_imgui) + if (HELLOIMGUI_WITH_TEST_ENGINE) + target_link_libraries(${app_name} PRIVATE imgui_test_engine) + endif() + if (ANDROID AND HELLOIMGUI_CREATE_ANDROID_STUDIO_PROJECT) set(apkCMake_applicationIdUrlPart ${HELLO_IMGUI_BUNDLE_IDENTIFIER_URL_PART}) set(apkCMake_applicationIdNamePart ${HELLO_IMGUI_BUNDLE_IDENTIFIER_NAME_PART}) diff --git a/src/hello_imgui_test_engine_integration/hello_imgui_test_engine_cmake.cmake b/src/hello_imgui_test_engine_integration/hello_imgui_test_engine_cmake.cmake index 31ab162e..7ace104e 100644 --- a/src/hello_imgui_test_engine_integration/hello_imgui_test_engine_cmake.cmake +++ b/src/hello_imgui_test_engine_integration/hello_imgui_test_engine_cmake.cmake @@ -9,6 +9,18 @@ function(_add_imgui_test_engine_lib) file(GLOB_RECURSE sources ${source_folder}/*.h ${source_folder}/*.cpp) add_library(imgui_test_engine ${sources}) target_include_directories(imgui_test_engine PUBLIC ${source_folder}/..) + target_link_libraries(imgui_test_engine PUBLIC imgui) + + if(HELLOIMGUI_BUILD_PYTHON) + # if building python bindings, build a duplicate imgui_test_engine_py lib... + add_library(imgui_test_engine_py ${sources}) + target_include_directories(imgui_test_engine_py PUBLIC ${source_folder}/..) + target_link_libraries(imgui_test_engine_py PUBLIC imgui) + # ... that will move the GIL between threads + target_compile_definitions(imgui_test_engine_py PUBLIC IMGUI_TEST_ENGINE_WITH_PYTHON_GIL) + # ... and needs to link with pybind + target_link_libraries(imgui_test_engine_py PUBLIC pybind11::pybind11 pybind11::module) + endif() endfunction() @@ -22,11 +34,7 @@ function(_configure_imgui_with_test_engine) IMGUI_TEST_ENGINE_ENABLE_COROUTINE_STDTHREAD_IMPL=1 ) # IMGUI_TEST_ENGINE_ENABLE_IMPLOT=0 - # Link imgui_test_engine with imgui - target_link_libraries(imgui_test_engine PUBLIC imgui) - # any App built with ImGui should now also link with imgui_test_engine - target_link_libraries(imgui PUBLIC imgui_test_engine) -endfunction() + endfunction() # Add integration into HelloImGui @@ -37,6 +45,7 @@ function(_add_hello_imgui_test_engine_integration) ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/test_engine_integration.h ) target_include_directories(hello_imgui PUBLIC ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/..) + target_include_directories(hello_imgui PRIVATE ${HELLOIMGUI_IMGUI_TEST_ENGINE_SOURCE_DIR}) endfunction() diff --git a/src/hello_imgui_tests/CMakeLists.txt b/src/hello_imgui_tests/CMakeLists.txt index c5a56aff..e5ce0c28 100644 --- a/src/hello_imgui_tests/CMakeLists.txt +++ b/src/hello_imgui_tests/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(hello_imgui_tests hello_imgui_ini_settings_test.cpp hello_imgui_tests_main.cpp) target_link_libraries(hello_imgui_tests PRIVATE hello_imgui) +if (HELLOIMGUI_WITH_TEST_ENGINE) + target_link_libraries(hello_imgui_tests PRIVATE imgui_test_engine) +endif()