Skip to content

Commit

Permalink
Build imgui_test_engine in cimgui-pack
Browse files Browse the repository at this point in the history
This is needed for linking.
  • Loading branch information
JamesWrigley committed Jun 11, 2024
1 parent 6a92748 commit 244c36c
Show file tree
Hide file tree
Showing 46 changed files with 6,029 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ imgui_log.txt
.vscode
*Manifest.toml
build
cimgui-pack/test_engine/ImGuiTestEngine
cimgui-pack/test_engine/*-report.txt
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "cimnodes"]
path = cimgui-pack/cimnodes
url = https://github.com/cimgui/cimnodes.git
[submodule "cimgui-pack/test_engine/imgui_test_engine"]
path = cimgui-pack/test_engine/imgui_test_engine
url = https://github.com/ocornut/imgui_test_engine.git
70 changes: 68 additions & 2 deletions cimgui-pack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(target cimgui)

add_library(${target} SHARED)

# cimgui and the backends
target_sources(${target} PRIVATE ./cimgui/imgui/imgui.cpp)
target_sources(${target} PRIVATE ./cimgui/imgui/imgui_demo.cpp)
target_sources(${target} PRIVATE ./cimgui/imgui/imgui_draw.cpp)
Expand All @@ -17,15 +18,71 @@ target_sources(${target} PRIVATE ./cimgui/imgui/backends/imgui_impl_glfw.cpp)
target_sources(${target} PRIVATE ./cimgui/imgui/backends/imgui_impl_opengl3.cpp)
target_sources(${target} PRIVATE ./cimgui/cimgui.cpp)

# imgui_test_engine
set(TE_DIR "test_engine/imgui_test_engine/imgui_test_engine")
set(WRAPPER_DIR "test_engine/src")
target_sources(${target} PRIVATE
# Wrapper sources
${WRAPPER_DIR}/JlGlobals.cxx
${WRAPPER_DIR}/JlImBuildInfo.cxx
${WRAPPER_DIR}/JlImGuiCaptureArgs.cxx
${WRAPPER_DIR}/JlImGuiCaptureContext.cxx
${WRAPPER_DIR}/JlImGuiCaptureToolUI.cxx
${WRAPPER_DIR}/JlImGuiCsvParser.cxx
${WRAPPER_DIR}/JlImGuiPerfTool.cxx
${WRAPPER_DIR}/JlImGuiPerfToolBatch.cxx
${WRAPPER_DIR}/JlImGuiPerfToolEntry.cxx
${WRAPPER_DIR}/JlImGuiTest.cxx
${WRAPPER_DIR}/JlImGuiTestActionFilter.cxx
${WRAPPER_DIR}/JlImGuiTestContext.cxx
${WRAPPER_DIR}/JlImGuiTestCoroutineInterface.cxx
${WRAPPER_DIR}/JlImGuiTestEngineIO.cxx
${WRAPPER_DIR}/JlImGuiTestFindByLabelTask.cxx
${WRAPPER_DIR}/JlImGuiTestGatherTask.cxx
${WRAPPER_DIR}/JlImGuiTestGenericItemStatus.cxx
${WRAPPER_DIR}/JlImGuiTestGenericVars.cxx
${WRAPPER_DIR}/JlImGuiTestInfoTask.cxx
${WRAPPER_DIR}/JlImGuiTestInput.cxx
${WRAPPER_DIR}/JlImGuiTestInputs.cxx
${WRAPPER_DIR}/JlImGuiTestItemInfo.cxx
${WRAPPER_DIR}/JlImGuiTestItemList.cxx
${WRAPPER_DIR}/JlImGuiTestLog.cxx
${WRAPPER_DIR}/JlImGuiTestLogLineInfo.cxx
${WRAPPER_DIR}/JlImGuiTestOutput.cxx
${WRAPPER_DIR}/JlImGuiTestRef.cxx
${WRAPPER_DIR}/JlImGuiTestRefDesc.cxx
${WRAPPER_DIR}/JlImGuiTestRunTask.cxx
${WRAPPER_DIR}/JlImMovingAverage.cxx
${WRAPPER_DIR}/JlImVec2.cxx
${WRAPPER_DIR}/JlImVec4.cxx
${WRAPPER_DIR}/JlStr.cxx
${WRAPPER_DIR}/jlImGuiTestEngine.cxx

# Test engine sources
${TE_DIR}/imgui_te_context.cpp
${TE_DIR}/imgui_te_coroutine.cpp
${TE_DIR}/imgui_te_engine.cpp
${TE_DIR}/imgui_te_perftool.cpp
${TE_DIR}/imgui_te_ui.cpp
${TE_DIR}/imgui_te_utils.cpp
${TE_DIR}/imgui_capture_tool.cpp
${TE_DIR}/imgui_te_exporters.cpp
)

# cimplot
target_sources(${target} PRIVATE ./cimplot/implot/implot.cpp)
target_sources(${target} PRIVATE ./cimplot/implot/implot_items.cpp)
target_sources(${target} PRIVATE ./cimplot/implot/implot_demo.cpp)
target_sources(${target} PRIVATE ./cimplot/cimplot.cpp)

# cimnodes
target_sources(${target} PRIVATE ./cimnodes/imnodes/imnodes.cpp)
target_sources(${target} PRIVATE ./cimnodes/cimnodes.cpp)

add_definitions(-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1 -DIMNODES_NAMESPACE=imnodes -DIMGUI_ENABLE_TEST_ENGINE)
target_compile_definitions(${target} PRIVATE
IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1
IMNODES_NAMESPACE=imnodes
IMGUI_ENABLE_TEST_ENGINE)

# Find GLFW
if (NOT DEFINED GLFW_LIBRARY)
Expand All @@ -35,19 +92,28 @@ endif()

if (WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
target_link_libraries(${target} imm32 opengl32 glfw)
target_link_libraries(${target} imm32 "${GLFW_LIBRARY}" opengl32)
else()
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
target_link_libraries(${target} "${GLFW_LIBRARY}" GL)
endif(WIN32)

# Linking for cxxwrap
find_package(JlCxx)
get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")
message(STATUS "Found JlCxx at ${JlCxx_location}")
target_link_libraries(${target} JlCxx::cxxwrap_julia)

target_include_directories(${target} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimgui>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimgui/imgui>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimplot>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimplot/implot>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimnodes>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cimnodes/imnodes>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test_engine/imgui_test_engine/imgui_test_engine>
$<INSTALL_INTERFACE:include>)

target_compile_features(${target} PRIVATE cxx_std_11)
Expand Down
2 changes: 2 additions & 0 deletions cimgui-pack/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[deps]
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
GLFW_jll = "0656b61e-2033-5cc2-a64a-77c0f6c09b89"
WrapIt = "962878d8-9763-11ee-8c14-fbf60c98afae"
19 changes: 18 additions & 1 deletion cimgui-pack/build.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import WrapIt: wrapit
import CxxWrap
import GLFW_jll

# Generate the imgui_test_engine wrappers
cd(joinpath(@__DIR__, "test_engine")) do
# We currently need a custom build of wrapit with these changes:
# - https://github.com/grasph/wrapit/pull/54
# - https://github.com/grasph/wrapit/pull/55
# - https://github.com/grasph/wrapit/pull/56
#
# TODO: when they're all merged and released, delete the generated sources
run(`/home/james/git/wrapit/build/wrapit config.toml --force`)
# wrapit("config.toml"; force=true, verbosity=0)
end

cd(@__DIR__) do
if !isdir("build")
mkdir("build")
end

cd("build") do
run(`cmake -DCMAKE_BUILD_TYPE=Release -DGLFW_LIBRARY=$(GLFW_jll.libglfw) ..`)
cxxwrap_prefix = CxxWrap.prefix_path()
run(`cmake -DCMAKE_BUILD_TYPE=Release
-DGLFW_LIBRARY=$(GLFW_jll.libglfw)
-DCMAKE_PREFIX_PATH=$(cxxwrap_prefix) ..`)
nprocs = Sys.CPU_THREADS
run(`cmake --build . -j$(nprocs)`)
end
Expand Down
13 changes: 13 additions & 0 deletions cimgui-pack/test_engine/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module_name = "ImGuiTestEngine"
uuid = "d6eb4cb6-1e07-14c4-5835-ae91bedf8555"
include_dirs = ["./imgui_test_engine/imgui_test_engine",
"../cimgui/imgui"]
input = ["imgui_te_engine.h", "imgui_te_internal.h", "imgui_te_context.h", "imgui_te_perftool.h", "imgui_te_ui.h", "imgui_te_utils.h", "imgui_te_exporters.h"]
cxx-std = "c++17"
out_cxx_dir = "src"

veto_list = "veto_list.txt"
extra_headers = ["imgui.h", "imgui_internal.h", "thirdparty/Str/Str.h"]
clang_opts = ["-DIMGUI_TEST_ENGINE_ENABLE_STD_FUNCTION=1", "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1"]
lib_basename = "$(@__DIR__)/../../../build/libcimgui"
export = "none"
1 change: 1 addition & 0 deletions cimgui-pack/test_engine/imgui_test_engine
Submodule imgui_test_engine added at c3a507

0 comments on commit 244c36c

Please sign in to comment.