diff --git a/CMakeLists.txt b/CMakeLists.txt index 23db3f26..16385371 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ # - musrfit --- DKS ----------------------------------------------------------- cmake_minimum_required(VERSION 3.17) -# cmake: use BoostConfig.cmake instead of FindBoost -if (CMAKE_VERSION GREATER_EQUAL "3.3") +# cmake: use BoostConfig.cmake instead of FindBoost. +# CMP0167 only exists since cmake 3.30, hence guard with 'if (POLICY ...)'. +# A version comparison must not be used here: 'CMAKE_VERSION GREATER_EQUAL 3.30' +# is a *numeric* comparison and would wrongly fire on e.g. cmake 3.20. +if (POLICY CMP0167) cmake_policy(SET CMP0167 NEW) -endif () +endif () project(musrfit VERSION 1.12.0 LANGUAGES C CXX) @@ -18,6 +21,10 @@ include(GNUInstallDirs) #--- musrfit specific options ------------------------------------------------- option(dks "build musrfit with DKS (GPU/MIC) support" ON) option(nexus "build optional NeXus support. Needed for ISIS" OFF) +#--- 'HAVE_HDF4' is the name the C++ sources (PNeXus, PRunDataHandler, +#--- dump_header, musrfit) and src/external/nexus/CMakeLists.txt already use, +#--- hence keep it for the option as well. +option(HAVE_HDF4 "in addition to HDF5, support the older HDF4 based NeXus files. Requires -Dnexus=1" OFF) option(ASlibs "build optional ASlibs" OFF) option(BMWlibs "build optional BMWlibs" OFF) option(BNMRlibs "build optional beta-NMR libs" OFF) @@ -42,8 +49,9 @@ endif () #--- perform some checks and generate the config.h ---------------------------- -#--- the next two lines are needed that the math functions are found ---------- -set(CMAKE_REQUIRED_INCLUDES math.h) +#--- the next line is needed that the math functions are found ---------------- +#--- (CMAKE_REQUIRED_INCLUDES expects *directories*, not header names, hence +#--- it must not be used here.) set(CMAKE_REQUIRED_LIBRARIES m) include(CheckTypeSize) @@ -72,6 +80,9 @@ if (${LONG_DOUBLE} GREATER ${DOUBLE}) set(HAVE_LONG_DOUBLE_WIDER 1) endif (${LONG_DOUBLE} GREATER ${DOUBLE}) +#--- do not leak the check settings into the find_package() calls below -------- +unset(CMAKE_REQUIRED_LIBRARIES) + #--- check for all the needed packages ---------------------------------------- #--- add path to my own find modules and other stuff @@ -84,11 +95,44 @@ find_package(PkgConfig REQUIRED) find_package(Git REQUIRED) #--- check for ROOT ----------------------------------------------------------- -find_package(ROOT 6.16 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser) -if (ROOT_mathmore_FOUND) - #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY) - include(${ROOT_USE_FILE}) -endif (ROOT_mathmore_FOUND) +#--- remember the compiler flags *before* ROOT's recommended flags are added, +#--- so that the Qt applications, which do not use ROOT at all, can go back to +#--- them (see src/musredit_qt6/CMakeLists.txt) -------------------------------- +set(MUSRFIT_CXX_FLAGS_NO_ROOT "${CMAKE_CXX_FLAGS}") + +find_package(ROOT 6.18 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser) + +#--- 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, +#--- - calls link_directories(), which is not needed since ROOT_LIBRARIES +#--- holds absolute library paths, and +#--- - adds ROOT's include dirs / flags / definitions to *every* target of +#--- the project, including the Qt applications. +#--- ROOT itself states that CMAKE_CXX_FLAGS should not be touched, the flags +#--- are only a recommendation. ROOTConfig.cmake already pulls in +#--- RootMacros.cmake, i.e. root_generate_dictionary() is available. The guard +#--- below is only there for ROOT versions which might not do so. +if (NOT COMMAND root_generate_dictionary) + include("${ROOT_CMAKE_DIR}/RootMacros.cmake") +endif () + +#--- ROOT headers have to be compiled with at least the C++ standard ROOT was +#--- built with, otherwise the ABI does not match. Raise ours if needed, but +#--- never silently lower it. -------------------------------------------------- +if (ROOT_CXX_STANDARD AND ROOT_CXX_STANDARD GREATER CMAKE_CXX_STANDARD) + message(STATUS "ROOT was built with C++${ROOT_CXX_STANDARD}, raising CMAKE_CXX_STANDARD accordingly.") + set(CMAKE_CXX_STANDARD ${ROOT_CXX_STANDARD}) +endif () + +#--- ROOT's recommended compiler flags. Some of them are ABI relevant when +#--- ROOT headers are used, e.g. -fsigned-char (char is unsigned by default on +#--- aarch64) and -fsized-deallocation, hence they are kept for everything that +#--- talks to ROOT. -------------------------------------------------------- +include_directories(SYSTEM ${ROOT_INCLUDE_DIRS}) +add_definitions(${ROOT_DEFINITIONS}) +string(APPEND CMAKE_CXX_FLAGS " ${ROOT_CXX_FLAGS}") +string(APPEND CMAKE_C_FLAGS " ${ROOT_C_FLAGS}") #--- the next check is need to set a flag, since root 6.24 (minuit2) breaks #--- the backwards compatibility. --------------------------------------------- @@ -195,9 +239,9 @@ if (qt_based_tools) endif (NOT Qt6Core_FOUND AND NOT Qt5Core_FOUND) # if Qt6, Qt5 and Qt4 is not found try Qt3. Hopefully you never reach this point - if (NOT Qt6Core_FOUND AND NOT Qt5Core_FOUND AND Qt4_FOUND) + if (NOT Qt6Core_FOUND AND NOT Qt5Core_FOUND AND NOT Qt4_FOUND) find_package(Qt3) - endif (NOT Qt6Core_FOUND AND NOT Qt5Core_FOUND AND Qt4_FOUND) + endif (NOT Qt6Core_FOUND AND NOT Qt5Core_FOUND AND NOT Qt4_FOUND) endif (qt_version STREQUAL AUTO) # check specifically for Qt6 @@ -246,6 +290,10 @@ if (qt_based_tools) endif (qt_based_tools) #--- if NeXus check also for HDF4 (optional), HDF5 ---------------------------- +if (HAVE_HDF4 AND NOT nexus) + message(WARNING "HAVE_HDF4 only has an effect together with -Dnexus=1, it will be ignored.") +endif () + if (nexus) find_package(HDF5 COMPONENTS CXX REQUIRED) if (HAVE_HDF4) @@ -329,10 +377,21 @@ list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR} if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") endif("${isSystemDir}" STREQUAL "-1") -if (UNIX) +if (UNIX AND NOT APPLE) set(rpath ${CMAKE_INSTALL_RPATH}) string(APPEND rpath ";/usr/local/lib") set(CMAKE_INSTALL_RPATH "${rpath}") +elseif (APPLE) + #--- on macOS the 3rd party libs typically come from Homebrew, which lives in + #--- /opt/homebrew (Apple silicon) or /usr/local (Intel) ------------------- + set(rpath ${CMAKE_INSTALL_RPATH}) + if (EXISTS "/opt/homebrew/lib") + string(APPEND rpath ";/opt/homebrew/lib") + endif () + if (EXISTS "/usr/local/lib") + string(APPEND rpath ";/usr/local/lib") + endif () + set(CMAKE_INSTALL_RPATH "${rpath}") endif () #--- propagate to the sub-directories ----------------------------------------- @@ -434,7 +493,11 @@ message(" PSI-BIN : yes") message(" PSI-MDU : yes") message(" WKM (deprecated) : yes") if (nexus) - message(" NeXus : yes") + if (HAVE_HDF4) + message(" NeXus : yes (HDF5 and HDF4)") + else (HAVE_HDF4) + message(" NeXus : yes (HDF5 only, -DHAVE_HDF4=1 adds HDF4)") + endif (HAVE_HDF4) else (nexus) message(" NeXus : no") endif (nexus) @@ -536,7 +599,9 @@ configure_file(${CMAKE_SOURCE_DIR}/cmake/CPackOptions.cmake.in ${CMAKE_CURRENT_B set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackOptions.cmake") #set (CPACK_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks #set (CPACK_SOURCE_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks -if (UNIX) +#--- APPLE is UNIX as well, hence it needs to be excluded explicitly here, +#--- otherwise cpack would try to build an RPM on macOS ------------------------ +if (UNIX AND NOT APPLE) set (CPACK_GENERATOR ${CPACK_GENERATOR};RPM) endif () # Include of CPack must always be last diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 850a370a..ff339a13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,6 @@ add_executable(addRun addRun.cpp) target_compile_options(addRun BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(addRun BEFORE PRIVATE - $ $ $ $ @@ -39,18 +38,16 @@ add_executable(any2many any2many.cpp) target_compile_options(any2many BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(any2many BEFORE PRIVATE - $ $ $ $ ) -target_link_libraries(any2many ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(any2many ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(dump_header dump_header.cpp) target_compile_options(dump_header BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(dump_header BEFORE PRIVATE - $ $ $ $ @@ -62,18 +59,17 @@ target_include_directories(dump_header $ $ ) -target_link_libraries(dump_header ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(dump_header ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(msr2data msr2data.cpp) target_compile_options(msr2data BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(msr2data BEFORE PRIVATE - $ $ $ $ ) -target_link_libraries(msr2data ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(msr2data ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(msr2msr msr2msr.cpp classes/PStringUtils.cpp) target_include_directories(msr2msr @@ -87,28 +83,25 @@ target_compile_options(musrfit BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_ target_include_directories(musrfit BEFORE PRIVATE $ - $ $ $ $ ) if (OpenMP_CXX_FOUND) - target_link_libraries(musrfit ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} OpenMP::OpenMP_CXX) + target_link_libraries(musrfit ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers OpenMP::OpenMP_CXX) else () - target_link_libraries(musrfit ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) + target_link_libraries(musrfit ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) endif (OpenMP_CXX_FOUND) add_executable(musrFT musrFT.cpp) target_compile_options(musrFT BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(musrFT BEFORE PRIVATE - $ - $ $ $ $ ) -target_link_libraries(musrFT FFTW3::FFTW3 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(musrFT FFTW3::FFTW3 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(musrRootValidation musrRootValidation.cpp) target_compile_options(musrRootValidation BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") @@ -117,33 +110,29 @@ target_include_directories(musrRootValidation $ $ $ - $ $ ) -target_link_libraries(musrRootValidation ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} LibXml2::LibXml2) +target_link_libraries(musrRootValidation ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} LibXml2::LibXml2 FFTW3::FFTW3) add_executable(musrt0 musrt0.cpp) target_compile_options(musrt0 BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(musrt0 BEFORE PRIVATE - $ $ $ $ ) -target_link_libraries(musrt0 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(musrt0 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(musrview musrview.cpp) target_compile_options(musrview BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(musrview BEFORE PRIVATE - $ - $ $ $ $ ) -target_link_libraries(musrview FFTW3::FFTW3 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}) +target_link_libraries(musrview FFTW3::FFTW3 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} Boost::headers) add_executable(write_musrRoot_runHeader write_musrRoot_runHeader.cpp) target_compile_options(write_musrRoot_runHeader BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") @@ -152,11 +141,10 @@ target_include_directories(write_musrRoot_runHeader $ $ $ - $ $ $ ) -target_link_libraries(write_musrRoot_runHeader ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} LibXml2::LibXml2) +target_link_libraries(write_musrRoot_runHeader ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} LibXml2::LibXml2 FFTW3::FFTW3) #--- ensure git-revision.h is regenerated before compiling -------------------- if (IS_GIT_REPO) diff --git a/src/classes/CMakeLists.txt b/src/classes/CMakeLists.txt index fab10bfd..260f2df8 100644 --- a/src/classes/CMakeLists.txt +++ b/src/classes/CMakeLists.txt @@ -6,7 +6,11 @@ set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) # Hence, target_include_directories cannot be used here because, targets are # setup only afterwards. include_directories(${MUSRFIT_INC}) -include_directories(SYSTEM ${FFTW3_INCLUDE}) +#--- note: FFTW3_INCLUDE is deliberately NOT added here. On a Homebrew based +#--- macOS it is /opt/homebrew/include, i.e. the complete 3rd party header tree, +#--- and a global include_directories() would put it in front of the headers of +#--- every target below. The dictionaries below get it via their OPTIONS, and +#--- everything else via the FFTW3::FFTW3 imported target. --------------------- root_generate_dictionary( PFourierCanvasDict @@ -132,8 +136,6 @@ add_library(PMusr SHARED target_include_directories( PMusr SYSTEM BEFORE PRIVATE $ - $ - $ $ $ $ @@ -182,7 +184,6 @@ target_include_directories( target_include_directories( PRgeHandler BEFORE PRIVATE - $ $ PUBLIC $ diff --git a/src/external/DepthProfile/src/CMakeLists.txt b/src/external/DepthProfile/src/CMakeLists.txt index 6c607bd1..3c53f67f 100644 --- a/src/external/DepthProfile/src/CMakeLists.txt +++ b/src/external/DepthProfile/src/CMakeLists.txt @@ -45,7 +45,6 @@ set_target_properties(PDepthProfile #--- make sure that the include directory is found ---------------------------- target_include_directories( PDepthProfile BEFORE PRIVATE - $ $ $ PUBLIC diff --git a/src/external/MagProximity/CMakeLists.txt b/src/external/MagProximity/CMakeLists.txt index 3d404411..9767e70e 100644 --- a/src/external/MagProximity/CMakeLists.txt +++ b/src/external/MagProximity/CMakeLists.txt @@ -44,7 +44,6 @@ add_library(PMagProximityFitter SHARED #--- make sure that the include directory is found ---------------------------- target_include_directories( PMagProximityFitter BEFORE PRIVATE - $ $ $ PUBLIC diff --git a/src/external/Nonlocal/CMakeLists.txt b/src/external/Nonlocal/CMakeLists.txt index a760367c..f4e6a3f2 100644 --- a/src/external/Nonlocal/CMakeLists.txt +++ b/src/external/Nonlocal/CMakeLists.txt @@ -52,7 +52,6 @@ add_library(PNL_PippardFitter SHARED #--- make sure that the include directory is found ---------------------------- target_include_directories( PNL_PippardFitter BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/Nonlocal/prog/CMakeLists.txt b/src/external/Nonlocal/prog/CMakeLists.txt index 446c8fdb..72515103 100644 --- a/src/external/Nonlocal/prog/CMakeLists.txt +++ b/src/external/Nonlocal/prog/CMakeLists.txt @@ -63,7 +63,6 @@ add_executable(dump_nonlocal_field dump_nonlocal_field.cpp) target_compile_options(dump_nonlocal_field BEFORE PRIVATE "-DHAVE_CONFIG_H" "-DHAVE_DNLF_CONFIG_H" "${HAVE_GIT_REV_H}") target_include_directories(dump_nonlocal_field BEFORE PRIVATE - $ $ $ $ @@ -72,7 +71,7 @@ target_include_directories(dump_nonlocal_field $ $ ) -target_link_libraries(dump_nonlocal_field ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} PNL_PippardFitter) +target_link_libraries(dump_nonlocal_field ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} PNL_PippardFitter Boost::headers) #--- installation info -------------------------------------------------------- install( diff --git a/src/external/libBNMR/libLineProfile/CMakeLists.txt b/src/external/libBNMR/libLineProfile/CMakeLists.txt index 17c8b11b..bbe0ad1c 100644 --- a/src/external/libBNMR/libLineProfile/CMakeLists.txt +++ b/src/external/libBNMR/libLineProfile/CMakeLists.txt @@ -26,7 +26,6 @@ add_library(LineProfile SHARED #--- make sure that the include directory is found ---------------------------- target_include_directories( LineProfile BEFORE PRIVATE - $ $ $ ) @@ -38,7 +37,7 @@ set_target_properties(LineProfile ) #--- add library dependencies ------------------------------------------------- -target_link_libraries(LineProfile ${ROOT_LIBRARIES} PUserFcnBase) +target_link_libraries(LineProfile ${ROOT_LIBRARIES} PUserFcnBase Boost::headers FFTW3::FFTW3) #--- install libLineProfile solib ---------------------------------------------------- install(TARGETS LineProfile EXPORT musrfitTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/external/libCalcMeanFieldsLEM/CMakeLists.txt b/src/external/libCalcMeanFieldsLEM/CMakeLists.txt index 386488a1..8afb26c0 100644 --- a/src/external/libCalcMeanFieldsLEM/CMakeLists.txt +++ b/src/external/libCalcMeanFieldsLEM/CMakeLists.txt @@ -48,7 +48,6 @@ set_target_properties(CalcMeanFieldsLEM #--- make sure that the include directory is found ---------------------------- target_include_directories( CalcMeanFieldsLEM BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/libFitPofB/classes/CMakeLists.txt b/src/external/libFitPofB/classes/CMakeLists.txt index 56260f63..4b423721 100644 --- a/src/external/libFitPofB/classes/CMakeLists.txt +++ b/src/external/libFitPofB/classes/CMakeLists.txt @@ -82,7 +82,6 @@ set_target_properties(FitPofB #--- make sure that the include directory is found ---------------------------- target_include_directories( FitPofB BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/libGapIntegrals/CMakeLists.txt b/src/external/libGapIntegrals/CMakeLists.txt index ba26dc33..edfa8b8b 100644 --- a/src/external/libGapIntegrals/CMakeLists.txt +++ b/src/external/libGapIntegrals/CMakeLists.txt @@ -47,7 +47,6 @@ set_target_properties(GapIntegrals #--- make sure that the include directory is found ---------------------------- target_include_directories( GapIntegrals BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/libGbGLF/CMakeLists.txt b/src/external/libGbGLF/CMakeLists.txt index c9075682..269ddf4c 100644 --- a/src/external/libGbGLF/CMakeLists.txt +++ b/src/external/libGbGLF/CMakeLists.txt @@ -31,7 +31,6 @@ add_library(PGbGLF SHARED #--- make sure that the include directory is found ---------------------------- target_include_directories( PGbGLF BEFORE PRIVATE - $ $ $ PUBLIC diff --git a/src/external/libLFRelaxation/CMakeLists.txt b/src/external/libLFRelaxation/CMakeLists.txt index 748369c5..fa2952ad 100644 --- a/src/external/libLFRelaxation/CMakeLists.txt +++ b/src/external/libLFRelaxation/CMakeLists.txt @@ -46,7 +46,6 @@ set_target_properties(LFRelaxation #--- make sure that the include directory is found ---------------------------- target_include_directories( LFRelaxation BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/libPhotoMeissner/classes/CMakeLists.txt b/src/external/libPhotoMeissner/classes/CMakeLists.txt index 91a529e5..6f54cbd0 100644 --- a/src/external/libPhotoMeissner/classes/CMakeLists.txt +++ b/src/external/libPhotoMeissner/classes/CMakeLists.txt @@ -46,7 +46,6 @@ set_target_properties(PPhotoMeissner #--- make sure that the include directory is found ---------------------------- target_include_directories( PPhotoMeissner BEFORE PRIVATE - $ $ $ $ diff --git a/src/external/libSpinValve/classes/CMakeLists.txt b/src/external/libSpinValve/classes/CMakeLists.txt index 79135a07..b6c3faa8 100644 --- a/src/external/libSpinValve/classes/CMakeLists.txt +++ b/src/external/libSpinValve/classes/CMakeLists.txt @@ -55,7 +55,6 @@ set_target_properties(PSpinValve #--- make sure that the include directory is found ---------------------------- target_include_directories( PSpinValve BEFORE PRIVATE - $ $ $ PUBLIC diff --git a/src/external/libZFRelaxation/CMakeLists.txt b/src/external/libZFRelaxation/CMakeLists.txt index bc27992d..43bb6ad4 100644 --- a/src/external/libZFRelaxation/CMakeLists.txt +++ b/src/external/libZFRelaxation/CMakeLists.txt @@ -46,7 +46,6 @@ set_target_properties(ZFRelaxation #--- make sure that the include directory is found ---------------------------- target_include_directories( ZFRelaxation BEFORE PRIVATE - $ $ $ $ diff --git a/src/musredit_qt5/CMakeLists.txt b/src/musredit_qt5/CMakeLists.txt index 1d5d38f6..ce1a886e 100644 --- a/src/musredit_qt5/CMakeLists.txt +++ b/src/musredit_qt5/CMakeLists.txt @@ -1,5 +1,13 @@ #--- musredit_qt5 for Qt > 5.0 ------------------------------------------------ +#--- The Qt applications do not use ROOT (with the exception of the mupp +#--- plotter, which pulls in what it needs itself). Drop ROOT's include dirs and +#--- recommended compiler flags for this part of the tree, so that they cannot +#--- interfere with the Qt build. Both settings are directory scoped and are +#--- inherited by the sub-directories added below, nothing outside is affected. +set(CMAKE_CXX_FLAGS "${MUSRFIT_CXX_FLAGS_NO_ROOT}") +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "") + #--- create musrfit-info.h ---------------------------------------------------- configure_file( ${CMAKE_SOURCE_DIR}/cmake/musrfit-info.h.in diff --git a/src/musredit_qt5/mupp/CMakeLists.txt b/src/musredit_qt5/mupp/CMakeLists.txt index f87092be..5d5d8475 100644 --- a/src/musredit_qt5/mupp/CMakeLists.txt +++ b/src/musredit_qt5/mupp/CMakeLists.txt @@ -67,12 +67,13 @@ else (IS_GIT_REPO) set(HAVE_GIT_REV_H "") endif (IS_GIT_REPO) -#--- compiler option to workaround a little cast problem for some -#--- boost/compiler combinations ---------------------------------------------- +#--- compiler option to workaround a little cast problem for some +#--- boost/compiler combinations. -fpermissive is a GCC option, clang/AppleClang +#--- silently ignore it, hence only hand it to GCC. ---------------------------- target_compile_options(mupp PRIVATE - "-fpermissive" - "${HAVE_GIT_REV_H}" + "$<$:-fpermissive>" + "${HAVE_GIT_REV_H}" ) #--- add the variable related sources ----------------------------------------- @@ -95,21 +96,28 @@ if (IS_GIT_REPO) endif (IS_GIT_REPO) #--- if macOS make an app rather than just a command line executable ---------- -set_target_properties(mupp PROPERTIES - VERSION ${mupp_VERSION} -) if (APPLE) + #--- do NOT set the VERSION property on a MACOSX_BUNDLE target: cmake would + #--- name the binary in Contents/MacOS 'mupp-' and only leave a + #--- symlink 'mupp' next to it, which contradicts CFBundleExecutable and does + #--- not survive zipping/codesigning. --------------------------------------- set_target_properties(mupp PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_BUNDLE_NAME "mupp" MACOSX_BUNDLE_INFO_STRING "mupp is used to plot parameters from musrfit collections." MACOSX_BUNDLE_ICON_FILE "mupp.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${mupp_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${mupp_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${mupp_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.mupp" MACOSX_FRAMEWORK_IDENTIFIER ch.psi.mupp MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE "${RESOURCE_FILES}" ) +else (APPLE) + set_target_properties(mupp PROPERTIES + VERSION ${mupp_VERSION} + ) endif (APPLE) #--- install ------------------------------------------------------------------ diff --git a/src/musredit_qt5/mupp/plotter/CMakeLists.txt b/src/musredit_qt5/mupp/plotter/CMakeLists.txt index 8e081ef8..2ba23944 100644 --- a/src/musredit_qt5/mupp/plotter/CMakeLists.txt +++ b/src/musredit_qt5/mupp/plotter/CMakeLists.txt @@ -1,6 +1,11 @@ #--- mupp_plotter ------------------------------------------------------------- message("-- Handle the plotter part of mupp") +#--- unlike the rest of musredit_qt5 the plotter *does* use ROOT, hence ROOT's +#--- include dirs and recommended compiler flags are needed again here --------- +include_directories(SYSTEM ${ROOT_INCLUDE_DIRS}) +string(APPEND CMAKE_CXX_FLAGS " ${ROOT_CXX_FLAGS}") + #--- instruct cmake NOT to run moc automatically when needed anymore ---------- set(CMAKE_AUTOMOC OFF) diff --git a/src/musredit_qt5/musrStep/CMakeLists.txt b/src/musredit_qt5/musrStep/CMakeLists.txt index d1e5d64a..31980e78 100644 --- a/src/musredit_qt5/musrStep/CMakeLists.txt +++ b/src/musredit_qt5/musrStep/CMakeLists.txt @@ -63,6 +63,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musrStep allows to reset/set the initial step size of a msr-files." MACOSX_BUNDLE_ICON_FILE "musrStep.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrStep" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/src/musredit_qt5/musrWiz/CMakeLists.txt b/src/musredit_qt5/musrWiz/CMakeLists.txt index f5be6c56..7d20d607 100644 --- a/src/musredit_qt5/musrWiz/CMakeLists.txt +++ b/src/musredit_qt5/musrWiz/CMakeLists.txt @@ -67,6 +67,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musrWiz allows to create input msr-files if no templates are available." MACOSX_BUNDLE_ICON_FILE "musrWiz.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrWiz" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/src/musredit_qt5/musredit/CMakeLists.txt b/src/musredit_qt5/musredit/CMakeLists.txt index 932803d9..77a8e46c 100644 --- a/src/musredit_qt5/musredit/CMakeLists.txt +++ b/src/musredit_qt5/musredit/CMakeLists.txt @@ -67,7 +67,7 @@ set(musredit_ui ) if (APPLE) - if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0") + if (${CMAKE_HOST_SYSTEM_VERSION} VERSION_GREATER_EQUAL "20.3.0") set(macosx_icon_name musredit-bigsur.icns) else() set(macosx_icon_name musredit.icns) @@ -117,6 +117,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musredit simplifies the handling of the msr-files for uSR fitting." MACOSX_BUNDLE_ICON_FILE "${macosx_icon_name}" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/src/musredit_qt6/CMakeLists.txt b/src/musredit_qt6/CMakeLists.txt index 0aad99a7..c74a21cc 100644 --- a/src/musredit_qt6/CMakeLists.txt +++ b/src/musredit_qt6/CMakeLists.txt @@ -1,5 +1,13 @@ #--- musredit_qt6 for Qt > 6.0 ------------------------------------------------ +#--- The Qt applications do not use ROOT (with the exception of the mupp +#--- plotter, which pulls in what it needs itself). Drop ROOT's include dirs and +#--- recommended compiler flags for this part of the tree, so that they cannot +#--- interfere with the Qt build. Both settings are directory scoped and are +#--- inherited by the sub-directories added below, nothing outside is affected. +set(CMAKE_CXX_FLAGS "${MUSRFIT_CXX_FLAGS_NO_ROOT}") +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "") + #--- create musrfit-info.h ---------------------------------------------------- configure_file( ${CMAKE_SOURCE_DIR}/cmake/musrfit-info.h.in diff --git a/src/musredit_qt6/mupp/CMakeLists.txt b/src/musredit_qt6/mupp/CMakeLists.txt index 883f14ef..05f9b55a 100644 --- a/src/musredit_qt6/mupp/CMakeLists.txt +++ b/src/musredit_qt6/mupp/CMakeLists.txt @@ -68,10 +68,11 @@ else (IS_GIT_REPO) endif (IS_GIT_REPO) #--- compiler option to workaround a little cast problem for some -#--- boost/compiler combinations ---------------------------------------------- +#--- boost/compiler combinations. -fpermissive is a GCC option, clang/AppleClang +#--- silently ignore it, hence only hand it to GCC. ---------------------------- target_compile_options(mupp PRIVATE - "-fpermissive" + "$<$:-fpermissive>" "${HAVE_GIT_REV_H}" ) @@ -106,22 +107,29 @@ if (IS_GIT_REPO) endif (IS_GIT_REPO) #--- if macOS make an app rather than just a command line executable ---------- -set_target_properties(mupp PROPERTIES - VERSION ${mupp_VERSION} -) if (APPLE) + #--- do NOT set the VERSION property on a MACOSX_BUNDLE target: cmake would + #--- name the binary in Contents/MacOS 'mupp-' and only leave a + #--- symlink 'mupp' next to it, which contradicts CFBundleExecutable and does + #--- not survive zipping/codesigning. --------------------------------------- set_target_properties(mupp PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_BUNDLE_NAME "mupp" MACOSX_BUNDLE_INFO_STRING "mupp is used to plot parameters from musrfit collections." MACOSX_BUNDLE_ICON_FILE "mupp.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${mupp_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${mupp_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${mupp_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.mupp" MACOSX_FRAMEWORK_IDENTIFIER ch.psi.mupp MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE "${RESOURCE_FILES}" INSTALL_RPATH "${Qt6_DIR}/../.." ) +else (APPLE) + set_target_properties(mupp PROPERTIES + VERSION ${mupp_VERSION} + ) endif (APPLE) #--- install ------------------------------------------------------------------ diff --git a/src/musredit_qt6/mupp/plotter/CMakeLists.txt b/src/musredit_qt6/mupp/plotter/CMakeLists.txt index 39d21838..b870936f 100644 --- a/src/musredit_qt6/mupp/plotter/CMakeLists.txt +++ b/src/musredit_qt6/mupp/plotter/CMakeLists.txt @@ -1,6 +1,11 @@ #--- mupp_plotter ------------------------------------------------------------- message("-- Handle the plotter part of mupp") +#--- unlike the rest of musredit_qt6 the plotter *does* use ROOT, hence ROOT's +#--- include dirs and recommended compiler flags are needed again here --------- +include_directories(SYSTEM ${ROOT_INCLUDE_DIRS}) +string(APPEND CMAKE_CXX_FLAGS " ${ROOT_CXX_FLAGS}") + #--- instruct cmake NOT to run moc automatically when needed anymore ---------- set(CMAKE_AUTOMOC OFF) diff --git a/src/musredit_qt6/musrStep/CMakeLists.txt b/src/musredit_qt6/musrStep/CMakeLists.txt index b0c699d9..91e8fc54 100644 --- a/src/musredit_qt6/musrStep/CMakeLists.txt +++ b/src/musredit_qt6/musrStep/CMakeLists.txt @@ -63,6 +63,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musrStep allows to reset/set the initial step size of a msr-files." MACOSX_BUNDLE_ICON_FILE "musrStep.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrStep" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/src/musredit_qt6/musrWiz/CMakeLists.txt b/src/musredit_qt6/musrWiz/CMakeLists.txt index 14d358ea..4964b3dc 100644 --- a/src/musredit_qt6/musrWiz/CMakeLists.txt +++ b/src/musredit_qt6/musrWiz/CMakeLists.txt @@ -67,6 +67,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musrWiz allows to create input msr-files if no templates are available." MACOSX_BUNDLE_ICON_FILE "musrWiz.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrWiz" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/src/musredit_qt6/musredit/CMakeLists.txt b/src/musredit_qt6/musredit/CMakeLists.txt index f2d20f89..ea03c908 100644 --- a/src/musredit_qt6/musredit/CMakeLists.txt +++ b/src/musredit_qt6/musredit/CMakeLists.txt @@ -68,7 +68,7 @@ set(musredit_ui ) if (APPLE) - if (${CMAKE_HOST_SYSTEM_VERSION} GREATER_EQUAL "20.3.0") + if (${CMAKE_HOST_SYSTEM_VERSION} VERSION_GREATER_EQUAL "20.3.0") set(macosx_icon_name musredit-bigsur.icns) else() set(macosx_icon_name musredit.icns) @@ -117,6 +117,8 @@ if (APPLE) MACOSX_BUNDLE_INFO_STRING "musrfit: musredit simplifies the handling of the msr-files for uSR fitting." MACOSX_BUNDLE_ICON_FILE "${macosx_icon_name}" MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" RESOURCE ${macosx_icon} diff --git a/tests/maxLH_check/CMakeLists.txt b/tests/maxLH_check/CMakeLists.txt index 2dd30737..65db686a 100644 --- a/tests/maxLH_check/CMakeLists.txt +++ b/tests/maxLH_check/CMakeLists.txt @@ -25,12 +25,23 @@ 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) -add_maxLH_test(test-histo-NeXus test-histo-NeXus.msr 3273.57) -add_maxLH_test(test-histo-NeXus2 test-histo-NeXus2.msr 4228.9) # 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-NeXus2 test-asy-NeXus2.msr 1159.8) 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) diff --git a/tests/musrview_check/CMakeLists.txt b/tests/musrview_check/CMakeLists.txt index 6f5fd460..a00fd370 100644 --- a/tests/musrview_check/CMakeLists.txt +++ b/tests/musrview_check/CMakeLists.txt @@ -48,14 +48,6 @@ add_musrview_test(musrview-histo-muMinus test-histo-muMinus.msr add_musrview_test(musrview-histo-muMinus-fourier test-histo-muMinus.msr -f) add_musrview_test(musrview-histo-muMinus-fourier-avg test-histo-muMinus.msr -f -a) -add_musrview_test(musrview-histo-NeXus test-histo-NeXus.msr) -add_musrview_test(musrview-histo-NeXus-fourier test-histo-NeXus.msr -f) -add_musrview_test(musrview-histo-NeXus-fourier-avg test-histo-NeXus.msr -f -a) - -add_musrview_test(musrview-histo-NeXus2 test-histo-NeXus2.msr) -add_musrview_test(musrview-histo-NeXus2-fourier test-histo-NeXus2.msr -f) -add_musrview_test(musrview-histo-NeXus2-fourier-avg test-histo-NeXus2.msr -f -a) - # asymmetry fits add_musrview_test(musrview-asy-PSI-BIN test-asy-PSI-BIN.msr) add_musrview_test(musrview-asy-PSI-BIN-fourier test-asy-PSI-BIN.msr -f) @@ -65,10 +57,6 @@ add_musrview_test(musrview-asy-MUD test-asy-MUD.msr) add_musrview_test(musrview-asy-MUD-fourier test-asy-MUD.msr -f) add_musrview_test(musrview-asy-MUD-fourier-avg test-asy-MUD.msr -f -a) -add_musrview_test(musrview-asy-NeXus2 test-asy-NeXus2.msr) -add_musrview_test(musrview-asy-NeXus2-fourier test-asy-NeXus2.msr -f) -add_musrview_test(musrview-asy-NeXus2-fourier-avg test-asy-NeXus2.msr -f -a) - add_musrview_test(musrview-asy-HAL9500-RRF test-asy-HAL9500-RRF.msr) add_musrview_test(musrview-asy-HAL9500-RRF-fourier test-asy-HAL9500-RRF.msr -f) add_musrview_test(musrview-asy-HAL9500-RRF-fourier-avg test-asy-HAL9500-RRF.msr -f -a) @@ -77,6 +65,27 @@ add_musrview_test(musrview-asy-LF-BaB6 test-asy-LF-BaB6.msr) add_musrview_test(musrview-asy-LF-BaB6-fourier test-asy-LF-BaB6.msr -f) add_musrview_test(musrview-asy-LF-BaB6-fourier-avg test-asy-LF-BaB6.msr -f -a) +#--- 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) + # the ISIS example data of this one is an HDF4 file, hence it additionally + # needs -DHAVE_HDF4=1 + if (HAVE_HDF4) + add_musrview_test(musrview-histo-NeXus test-histo-NeXus.msr) + add_musrview_test(musrview-histo-NeXus-fourier test-histo-NeXus.msr -f) + add_musrview_test(musrview-histo-NeXus-fourier-avg test-histo-NeXus.msr -f -a) + endif (HAVE_HDF4) + + # NeXus IDF V2 / HDF5 + add_musrview_test(musrview-histo-NeXus2 test-histo-NeXus2.msr) + add_musrview_test(musrview-histo-NeXus2-fourier test-histo-NeXus2.msr -f) + add_musrview_test(musrview-histo-NeXus2-fourier-avg test-histo-NeXus2.msr -f -a) + + add_musrview_test(musrview-asy-NeXus2 test-asy-NeXus2.msr) + add_musrview_test(musrview-asy-NeXus2-fourier test-asy-NeXus2.msr -f) + add_musrview_test(musrview-asy-NeXus2-fourier-avg test-asy-NeXus2.msr -f -a) +endif (nexus) + #--- doc/examples/ViewOpts tests ---------------------------------------------- add_musrview_test(musrview-asy-PSI-BIN-range ViewOpts/test-asy-PSI-BIN-range.msr)