diff --git a/CLAUDE.md b/CLAUDE.md index b3c61246..c4871cd9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -115,9 +115,13 @@ The central data model and control flow (all in `src/classes/` with headers in ` need no browser. - The web assets are installed to `/share/musrfit/musrview`; set `MUSRFIT_WEB_DIR` to run from the source tree, and `MUSRVIEW_DEBUG=1` to trace the websocket traffic. - - musrview needs a ROOT built with `-Droot7=ON -Dwebgui=ON`, plus `-Dqt6web=ON` for the embedded - window (`--embedded`, the default). `--browser` uses the system browser, `--browser=server` - only prints the URL. + - musrview needs a ROOT built with `-Droot7=ON -Dwebgui=ON -Dhttp=ON`, plus `-Dqt6web=ON` for + the embedded window (`--embedded`, the default). `--browser` uses the system browser, + `--browser=server` only prints the URL. All of that (build options, `ROOT::ROOTWebDisplay`/ + `ROOT::RHTTP`, the ROOT7 headers, the `ROOT::RWebWindow` API itself via a compile check, + JSROOT and its import map) is verified at config time by `cmake/MusrfitCheckROOT7.cmake`, + which also sets `MUSRVIEW_HAS_QT6WEB` / `MUSRVIEW_HAS_IMAGE_EXPORT` (the latter gates the + `musrview_check` tests, since they compare rendered PNGs and thus need ROOT's libASImage). - **`PFourier`** / **`PFourierCanvas`** / **`PPrepFourier`** handle the Fourier transform and its (still TCanvas based) display, used by `musrview`/`musrFT`. - **`PMsr2Data`** implements `msr2data`'s logic for generating follow-up/global msr files from a diff --git a/CMakeLists.txt b/CMakeLists.txt index 5371a90d..6a3a017f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,16 +101,6 @@ set(MUSRFIT_CXX_FLAGS_NO_ROOT "${CMAKE_CXX_FLAGS}") find_package(ROOT 6.18 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser) -#--- musrview is based on the ROOT7 web graphics, which needs a ROOT built -#--- with -Dwebgui=ON (and -Droot7=ON). Without it there is no RWebWindow and -#--- musrview cannot be built. ------------------------------------------------ -if (NOT TARGET ROOT::ROOTWebDisplay) - message(FATAL_ERROR - "musrview needs the ROOT web display (RWebWindow), which this ROOT " - "installation does not provide. Please rebuild ROOT with " - "-Droot7=ON -Dwebgui=ON (and -Dqt6web=ON for the embedded window).") -endif () - #--- Deliberately NOT 'include(${ROOT_USE_FILE})' here. That file #--- - overwrites CMAKE_CXX_STANDARD with ROOT's value, silently discarding #--- the setting made at the top of this file, @@ -143,6 +133,13 @@ add_definitions(${ROOT_DEFINITIONS}) string(APPEND CMAKE_CXX_FLAGS " ${ROOT_CXX_FLAGS}") string(APPEND CMAKE_C_FLAGS " ${ROOT_C_FLAGS}") +#--- musrview is built on the ROOT7 web graphics, which needs a ROOT providing +#--- quite a bit more than the plain 'find_package(ROOT)' above checks for +#--- (root7, webgui, http, RWebWindow, JSROOT, ...). All of that is verified +#--- here, at config time. Done *after* the flags/standard above, so that the +#--- compile checks in there see exactly the same setup as the real build. ---- +include(MusrfitCheckROOT7) + #--- the next check is need to set a flag, since root 6.24 (minuit2) breaks #--- the backwards compatibility. --------------------------------------------- if (ROOT_VERSION VERSION_LESS "6.23") @@ -548,6 +545,20 @@ if (DummyUserFcn) message(" PDummyUserFcn : yes") endif (DummyUserFcn) +message("") +message(" musrview (ROOT7 web graphics):") +if (MUSRVIEW_HAS_QT6WEB) + message(" embedded window (ROOT qt6web) : yes") +else () + message(" embedded window (ROOT qt6web) : no, will use the standard browser") +endif () +if (MUSRVIEW_HAS_IMAGE_EXPORT) + message(" graphics export png/gif/jpg : yes") +else () + message(" graphics export png/gif/jpg : no, ROOT has no libASImage") +endif () +message(" JSROOT : ${MUSRVIEW_JSROOT_DIR}") + if (qt_based_tools) if (Qt6Core_FOUND) message("") diff --git a/cmake/MusrfitCheckROOT7.cmake b/cmake/MusrfitCheckROOT7.cmake new file mode 100644 index 00000000..620ec5ae --- /dev/null +++ b/cmake/MusrfitCheckROOT7.cmake @@ -0,0 +1,304 @@ +#--- MusrfitCheckROOT7.cmake -------------------------------------------------- +# +# Config time checks for everything musrview needs from ROOT. +# +# Since musrfit 1.13 musrview is built on the ROOT7 web graphics: the C++ side +# only holds the data and pushes it as JSON through an ROOT::RWebWindow +# websocket to a JSROOT page which does the rendering. This requires quite a +# few ROOT build options to be enabled (root7, webgui, http, ...) which are +# *not* all on by default in every ROOT installation. Without them musrview +# either does not compile at all or, worse, compiles and then fails at run time +# with a blank window. Hence check all of it here, at config time, and tell the +# user precisely what is missing and how to fix it. +# +# Expects find_package(ROOT ...) to have been called already. +# +# Sets (cached, for the config summary and for the sources): +# MUSRVIEW_JSROOT_DIR - the JSROOT directory of the ROOT installation +# MUSRVIEW_HAS_QT6WEB - ROOT provides the embedded Qt6 web display +# MUSRVIEW_HAS_IMAGE_EXPORT- ROOT provides libASImage (png/gif/jpg export) +# +#------------------------------------------------------------------------------ + +include(CheckCXXSourceCompiles) + +if (NOT ROOT_FOUND) + message(FATAL_ERROR "MusrfitCheckROOT7: find_package(ROOT) has to be called first.") +endif () + +#--- collect all problems first, so that the user gets the complete list with +#--- a single cmake run instead of one error per run -------------------------- +set(_musrview_missing "") + +#--- ROOT_BINDIR is set by ROOTConfig.cmake, but be defensive about it since it +#--- is only used for the messages and for locating the JSROOT directory ------ +if (NOT ROOT_BINDIR) + list(GET ROOT_INCLUDE_DIRS 0 _root_incdir) + get_filename_component(ROOT_BINDIR "${_root_incdir}/../bin" REALPATH) +endif () + +#--- cmake does not re-wrap indented lines, hence the texts handed to +#--- musrview_missing() are wrapped by hand below ---------------------------- +macro(musrview_missing msg) + string(APPEND _musrview_missing " * ${msg}\n") +endmacro() + +#------------------------------------------------------------------------------ +# 1) the ROOT build options musrview relies on +# +# ROOTConfig.cmake exports every enabled ROOT build option as +# ROOT_