From dce30c3ab212b8811b402bb718f65afdad284a9a Mon Sep 17 00:00:00 2001 From: Boris Batkin Date: Thu, 2 Jul 2026 01:51:06 -0700 Subject: [PATCH] one CMakeLists for both the standalone DLL and superbuild static-embed builds Both-worlds sweep (after dasVulkan #64 and dasImgui #218): - included from a daslang superbuild (ADD_MODULE_* defined): the module links statically into the host via ADD_MODULE_CPP + ADD_MODULE_LIB; dasImgui -- included earlier in the superbuild's alphabetical modules glob -- provides imgui_INCLUDE_DIR and the libDasModuleImgui target. Every daslib/*.das registers a boost path via a glob, so the glob IS the .das_module register_native_path list and the two can never drift. - configured directly (top-level project, DASLANG_DIR set): the standalone .shared_module flow, content unchanged (locate-dasImgui block and target block verbatim under the standalone branch). Validated: full-external-chain superbuild stub configure (dasImgui -> dasImguiImplot -> dasImguiNodeEditor -> dasVulkan in one include sequence, sibling-vars contract exercised) + standalone desktop configure and full Release build of the .shared_module from the new file. Co-Authored-By: Claude Fable 5 Also rename the four daslib files to carry their module names (implot_boost_v2.das -> imgui_implot_boost_v2.das etc.): the .das_module registered imgui_-prefixed names over unprefixed file stems, and native-path resolution in a superbuild maps name -> /.das strictly. Found by the fat-man smoke on its first run. --- .das_module | 8 +-- CMakeLists.txt | 72 +++++++++++++++++-- .../{implot_app.das => imgui_implot_app.das} | 0 ...mplot_boost.das => imgui_implot_boost.das} | 0 ...boost_v2.das => imgui_implot_boost_v2.das} | 0 ...wright.das => imgui_implot_playwright.das} | 0 6 files changed, 70 insertions(+), 10 deletions(-) rename daslib/{implot_app.das => imgui_implot_app.das} (100%) rename daslib/{implot_boost.das => imgui_implot_boost.das} (100%) rename daslib/{implot_boost_v2.das => imgui_implot_boost_v2.das} (100%) rename daslib/{implot_playwright.das => imgui_implot_playwright.das} (100%) diff --git a/.das_module b/.das_module index d63f58b..6d2765c 100644 --- a/.das_module +++ b/.das_module @@ -6,9 +6,9 @@ def initialize(project_path : string) { if (das_is_dll_build()) { register_dynamic_module("{project_path}/dasModuleImplot.shared_module", "Module_dasIMPLOT") } - register_native_path("imgui", "imgui_implot_boost", "{project_path}/daslib/implot_boost.das") - register_native_path("imgui", "imgui_implot_boost_v2", "{project_path}/daslib/implot_boost_v2.das") - register_native_path("imgui", "imgui_implot_app", "{project_path}/daslib/implot_app.das") - register_native_path("imgui", "imgui_implot_playwright", "{project_path}/daslib/implot_playwright.das") + register_native_path("imgui", "imgui_implot_boost", "{project_path}/daslib/imgui_implot_boost.das") + register_native_path("imgui", "imgui_implot_boost_v2", "{project_path}/daslib/imgui_implot_boost_v2.das") + register_native_path("imgui", "imgui_implot_app", "{project_path}/daslib/imgui_implot_app.das") + register_native_path("imgui", "imgui_implot_playwright", "{project_path}/daslib/imgui_implot_playwright.das") // theme wrapper module is registered here when added. } diff --git a/CMakeLists.txt b/CMakeLists.txt index 228f819..1a5e5d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,34 @@ -cmake_minimum_required(VERSION 3.16) -project(dasImguiImplot CXX C) +# dasImguiImplot builds two ways from a single CMakeLists: +# - included from a daslang superbuild (the ADD_MODULE_* macros exist): the module +# links statically into the host app via the convention path (dasImgui provides +# imgui headers + the libDasModuleImgui target) -- how an embedding app and the +# fat-man static-link example consume it. +# - configured directly (top-level project, DASLANG_DIR set): the standalone +# .shared_module build CI, the daspkg index, and -load_module consumers run on. +IF(NOT COMMAND ADD_MODULE_CPP) + cmake_minimum_required(VERSION 3.16) + project(dasImguiImplot CXX C) +ENDIF() -# DASLANG_DIR must point to the daslang SDK root -if(NOT DEFINED DASLANG_DIR) - message(FATAL_ERROR "DASLANG_DIR must be set to the daslang SDK root") -endif() +IF((NOT DAS_IMPLOT_INCLUDED) AND ((NOT ${DAS_IMPLOT_DISABLED}) OR (NOT DEFINED DAS_IMPLOT_DISABLED))) +SET(DAS_IMPLOT_INCLUDED TRUE) +MESSAGE(STATUS "dasImguiImplot module included.") SET(DAS_IMPLOT_DIR ${CMAKE_CURRENT_LIST_DIR}) +IF(COMMAND ADD_MODULE_CPP) + # superbuild: dasImgui's CMakeLists (included earlier -- the modules glob is + # alphabetical) already set imgui_INCLUDE_DIR and created libDasModuleImgui + IF(NOT DEFINED imgui_INCLUDE_DIR) + MESSAGE(FATAL_ERROR "dasImguiImplot superbuild: dasImgui must be included first (imgui_INCLUDE_DIR unset)") + ENDIF() + SET(DAS_IMGUI_DIR ${CMAKE_CURRENT_LIST_DIR}/../dasImgui) +ELSE() + # DASLANG_DIR must point to the daslang SDK root + if(NOT DEFINED DASLANG_DIR) + message(FATAL_ERROR "DASLANG_DIR must be set to the daslang SDK root") + endif() + # Locate dasImgui (sibling module under same modules/ parent) get_filename_component(MODULES_DIR "${DAS_IMPLOT_DIR}" DIRECTORY) SET(DAS_IMGUI_DIR "${MODULES_DIR}/dasImgui") @@ -29,6 +50,7 @@ if(WIN32) message(FATAL_ERROR "dasModuleImgui.lib not found at ${DAS_IMGUI_DIR}/. Build dasImgui first.") endif() endif() +ENDIF() # ImPlot v0.16 (vendored, patched for imgui 1.90.6 compatibility) SET(IMPLOT_INCLUDE_DIR ${DAS_IMPLOT_DIR}/implot) @@ -51,6 +73,41 @@ SET(DAS_IMPLOT_BIND_SRC ${DAS_IMPLOT_FUNC_SRC} ) + +IF(COMMAND ADD_MODULE_CPP) + # ===== daslang superbuild: static-embed ===== + # `require imgui/` -> modules/dasImguiImplot/daslib/.das; the glob IS the + # .das_module register_native_path list (file stem == module name throughout). + ADD_MODULE_CPP(dasIMPLOT) + FILE(GLOB _dasImguiImplot_das_files "${DAS_IMPLOT_DIR}/daslib/*.das") + FOREACH(_f ${_dasImguiImplot_das_files}) + GET_FILENAME_COMPONENT(_n "${_f}" NAME_WE) + ADD_MODULE_DAS(imgui daslib ${_n}) + ENDFOREACH() + + IF(EMSCRIPTEN) + ADD_DAS_STATIC_MODULE_LIB(libDasModuleImplot ${DAS_IMPLOT_BIND_SRC} ${DAS_IMPLOT_SRC}) + SET(_dasImguiImplot_targets libDasModuleImplot) + ELSE() + ADD_MODULE_LIB(libDasModuleImplot dasModuleImplot ${DAS_IMPLOT_BIND_SRC} ${DAS_IMPLOT_SRC}) + SET(_dasImguiImplot_targets libDasModuleImplot dasModuleImplot) + ENDIF() + FOREACH(_t ${_dasImguiImplot_targets}) + TARGET_INCLUDE_DIRECTORIES(${_t} PRIVATE + ${imgui_INCLUDE_DIR} + ${IMPLOT_INCLUDE_DIR} + ${DAS_IMGUI_DIR}/src + ${DAS_IMPLOT_DIR}/src + ) + TARGET_COMPILE_DEFINITIONS(${_t} PRIVATE IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) + SETUP_CPP11(${_t}) + ENDFOREACH() + # imgui core symbols come from dasImgui's libs + TARGET_LINK_LIBRARIES(libDasModuleImplot PUBLIC libDasModuleImgui) + IF(NOT EMSCRIPTEN) + TARGET_LINK_LIBRARIES(dasModuleImplot PUBLIC dasModuleImgui) + ENDIF() +ELSE() IF(WIN32) SET(IMGUI_IMPORT_ATTR "__declspec\(dllimport\)") ELSE() @@ -123,3 +180,6 @@ set_target_properties(dasModuleImplot PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${DAS_IMPLOT_DIR}" LIBRARY_OUTPUT_DIRECTORY "${DAS_IMPLOT_DIR}" ) +ENDIF() # superbuild / standalone + +ENDIF() # DAS_IMPLOT_INCLUDED guard diff --git a/daslib/implot_app.das b/daslib/imgui_implot_app.das similarity index 100% rename from daslib/implot_app.das rename to daslib/imgui_implot_app.das diff --git a/daslib/implot_boost.das b/daslib/imgui_implot_boost.das similarity index 100% rename from daslib/implot_boost.das rename to daslib/imgui_implot_boost.das diff --git a/daslib/implot_boost_v2.das b/daslib/imgui_implot_boost_v2.das similarity index 100% rename from daslib/implot_boost_v2.das rename to daslib/imgui_implot_boost_v2.das diff --git a/daslib/implot_playwright.das b/daslib/imgui_implot_playwright.das similarity index 100% rename from daslib/implot_playwright.das rename to daslib/imgui_implot_playwright.das