int32 Vgetname(int32 vkey, char *vgname)
to
int32 Vgetname(int32 vkey, char *vgname, size_t *buf_size)
(a fix for a buffer-overflow issue). Detect which one is present so
PNeXus.cpp can call the right form for both old and new HDF4 releases.
Fixes found while reviewing the cmake setup, with a focus on macOS. All
changes are either platform neutral or guarded by if (APPLE).
Portability / correctness:
* CMP0167 was guarded by 'CMAKE_VERSION GREATER_EQUAL 3.3', a *numeric*
comparison which is true on e.g. cmake 3.22. Since the policy only exists
since cmake 3.30, configuring aborted on RHEL 9 / Ubuntu 22.04, although
cmake_minimum_required allows them. Use 'if (POLICY CMP0167)'.
* CMAKE_REQUIRED_INCLUDES expects directories, not header names. Setting it
to 'math.h' injected a bogus -I<scratch>/math.h into every check_*() and
leaked into the find_package() calls. Dropped, and CMAKE_REQUIRED_LIBRARIES
is now unset after the checks. config.h is unchanged.
* The Qt3 fallback tested 'AND Qt4_FOUND' instead of 'AND NOT Qt4_FOUND'.
* NeXus regression tests were registered unconditionally and therefore failed
in a default build. They are gated on 'nexus' now, and the HDF4 based ones
additionally on HAVE_HDF4.
* HAVE_HDF4 was queried but never defined, i.e. there was no way to switch on
the HDF4 support that PNeXus/PRunDataHandler/dump_header/musrfit implement.
Added option(HAVE_HDF4), to be used together with -Dnexus=1. This is not
academic: the ISIS example data are HDF4 files and test-histo-NeXus only
passes with -DHAVE_HDF4=1.
Do not use ${ROOT_USE_FILE}:
It overwrote CMAKE_CXX_STANDARD with ROOT's value and added ROOT's include
dirs, definitions and recommended compiler flags to *every* target,
including the Qt applications which do not use ROOT at all. Replaced by an
explicit equivalent; the C++ standard is now only raised, never silently
changed. The Qt sub-trees reset flags and include dirs again, mupp/plotter
puts them back since it does use ROOT. ROOT's flags are kept wherever ROOT
headers are used, -fsigned-char and -fsized-deallocation are ABI relevant
there. Verified: the compile flags of all ROOT consuming targets are
byte-identical to before.
Homebrew header shadowing:
Boost_INCLUDE_DIRS and FFTW3_INCLUDE are both /opt/homebrew/include on a
Homebrew system, i.e. the whole 3rd party header tree, and they were passed
to target_include_directories() with BEFORE - ahead of musrfit's own
src/include. They now come from the Boost::headers and FFTW3::FFTW3
imported targets, which contribute them as SYSTEM includes after the
project's own directories.
macOS:
* mupp: do not set the VERSION property on a MACOSX_BUNDLE target. cmake then
names the binary Contents/MacOS/mupp-1.1.0 and only leaves a symlink 'mupp'
beside it, contradicting CFBundleExecutable and not surviving
zipping/codesigning. This is the reason the symlink had to be created by
hand so far. VERSION is still set for the non-APPLE build.
* All four app bundles had an empty CFBundleShortVersionString and
CFBundleVersion; set MACOSX_BUNDLE_SHORT_VERSION_STRING / _BUNDLE_VERSION.
* APPLE is UNIX, so the RPM generator was also active on macOS -> restrict to
'UNIX AND NOT APPLE'. Likewise the /usr/local/lib rpath, which on Apple
silicon should be /opt/homebrew/lib; macOS gets its own branch now.
* mupp: -fpermissive is a GCC option, hand it to GCC only.
* musredit: use VERSION_GREATER_EQUAL for the Darwin version icon switch.
Verified on macOS 26 / arm64 with ROOT 6.40.03, Qt 6.11, cmake 4.4: full
build clean in the default configuration, with -DASlibs -DBMWlibs -DBNMRlibs
-DDummyUserFcn (identical list of 55 targets), and with -Dnexus / -DHAVE_HDF4.
ctest shows no regression at any step; no maxLH test fails in any of the three
NeXus configurations.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
macOS 26 (Darwin 25.5.0) introduced stricter Clang module map rules in
DarwinFoundation1.modulemap: the '_c_standard_library_obsolete' module
now requires the 'found_incompatible_headers__check_search_paths' feature,
which CLING's runtime interpreter does not set. When fftw3.h (from
/opt/homebrew/include) was parsed by CLING via the inlined PStartupHandler
dictionary payload, it triggered this module map error, causing all
PStartupHandler signal/slot connections to fail.
Two fixes:
- PMusr.h: guard '#include "fftw3.h"' with '#ifndef __CLING__'. No fftw
types appear in PMusr.h class definitions, so CLING does not need it
for reflection. This is the primary runtime fix.
- CMakeLists.txt (src/classes and all src/external libs): replace
'-I${FFTW3_INCLUDE}', '-I${Boost_INCLUDE_DIRS}', '-I${GSL_INCLUDE_DIRS}',
and '-I${ROOT_INCLUDE_DIRS}' with '-isystem' in all root_generate_dictionary
OPTIONS blocks, and change 'include_directories(${FFTW3_INCLUDE})' to
'include_directories(SYSTEM ...)'. Internal project paths (MUSRFIT_INC,
BMW_TOOLS_INC, NONLOCAL_INC, CMAKE_CURRENT_SOURCE_DIR, etc.) keep '-I'.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GCC's -Wstringop-overflow flagged the memcpy in SobolIni() with a bound
of (size_t)(-4): on the (in practice unreachable) path where the Sobol
generator polynomial 'powers' is 0, the bit-count loop leaves inibits at
its initial -1, so inibits*sizeof underflows. The generator-polynomial
table always has a non-zero first column, so this never happens at run
time, but the compiler cannot prove it.
Guard the copy with 'if (inibits > 0)', which silences the false-positive
warning and hardens the edge case without changing behaviour for valid
input.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>