Skip to content

Commit

Permalink
if python, add test_engine specific lib for python (imgui_test_engine…
Browse files Browse the repository at this point in the history
…_py)
  • Loading branch information
pthom committed Oct 9, 2023
1 parent 2a17f22 commit cc10a1a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions hello_imgui_cmake/hello_imgui_add_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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
Expand All @@ -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()


Expand Down
3 changes: 3 additions & 0 deletions src/hello_imgui_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit cc10a1a

Please sign in to comment.