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>
48 lines
2.0 KiB
CMake
48 lines
2.0 KiB
CMake
#--- maxLH_check test (Python) ------------------------------------------------
|
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
|
|
|
#--- helper macro -------------------------------------------------------------
|
|
macro(add_maxLH_test test_name msr_file expected_value)
|
|
add_test(
|
|
NAME ${test_name}
|
|
COMMAND Python3::Interpreter
|
|
${CMAKE_CURRENT_SOURCE_DIR}/maxLH_check.py
|
|
$<TARGET_FILE:musrfit>
|
|
${CMAKE_SOURCE_DIR}/doc/examples/${msr_file}
|
|
${expected_value}
|
|
1e-4
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc/examples
|
|
)
|
|
endmacro()
|
|
|
|
#--- register ctest(s) -------------------------------------------------------
|
|
|
|
# single histogram fits (maxLH)
|
|
add_maxLH_test(test-histo-MusrRoot test-histo-MusrRoot.msr 3971.7)
|
|
add_maxLH_test(test-histo-PSI-BIN test-histo-PSI-BIN.msr 663.89)
|
|
add_maxLH_test(test-histo-ROOT-NPP test-histo-ROOT-NPP.msr 249.12)
|
|
add_maxLH_test(test-histo-HAL9500 test-histo-HAL9500.msr 1286509.8)
|
|
add_maxLH_test(test-histo-HAL9500-RRF test-histo-HAL9500-RRF.msr 22187.4)
|
|
add_maxLH_test(test-histo-muMinus test-histo-muMinus.msr 238962.6)
|
|
|
|
# asymmetry fits (chisq)
|
|
add_maxLH_test(test-asy-PSI-BIN test-asy-PSI-BIN.msr 566.76)
|
|
add_maxLH_test(test-asy-MUD test-asy-MUD.msr 133.96)
|
|
add_maxLH_test(test-asy-HAL9500-RRF test-asy-HAL9500-RRF.msr 7402.28)
|
|
add_maxLH_test(test-asy-LF-BaB6 test-asy-LF-BaB6.msr 1911.88)
|
|
|
|
#--- NeXus based tests. These can only work if musrfit was built with
|
|
#--- -Dnexus=1, otherwise the msr-files cannot be read at all -----------------
|
|
if (nexus)
|
|
# NeXus IDF V2 / HDF5
|
|
add_maxLH_test(test-histo-NeXus2 test-histo-NeXus2.msr 4228.9)
|
|
add_maxLH_test(test-asy-NeXus2 test-asy-NeXus2.msr 1159.8)
|
|
|
|
# the ISIS example data of this one is an HDF4 file, hence it additionally
|
|
# needs -DHAVE_HDF4=1
|
|
if (HAVE_HDF4)
|
|
add_maxLH_test(test-histo-NeXus test-histo-NeXus.msr 3273.57)
|
|
endif (HAVE_HDF4)
|
|
endif (nexus)
|