improvement dealing with rpath on macOS.

This commit is contained in:
suter_a 2022-06-20 15:53:57 +02:00
parent 1b190830e9
commit 3f2e96303a
5 changed files with 42 additions and 40 deletions

View File

@ -1,4 +1,4 @@
# - musrfit # - musrfit
cmake_minimum_required(VERSION 3.9) cmake_minimum_required(VERSION 3.9)
if (CMAKE_VERSION GREATER_EQUAL 3.12) if (CMAKE_VERSION GREATER_EQUAL 3.12)
@ -21,7 +21,7 @@ set_property(CACHE qt_version PROPERTY STRINGS AUTO 3 4 5 6)
#--- set a default build type if none was specified --------------------------- #--- set a default build type if none was specified ---------------------------
set(default_build_type "Release") set(default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.") message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
@ -35,7 +35,7 @@ endif ()
#--- the next two lines are needed that the math functions are found ---------- #--- the next two lines are needed that the math functions are found ----------
set(CMAKE_REQUIRED_INCLUDES math.h) set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m)
include(CheckTypeSize) include(CheckTypeSize)
include(CheckIncludeFiles) include(CheckIncludeFiles)
@ -84,17 +84,17 @@ if (ROOT_mathmore_FOUND)
endif (ROOT_mathmore_FOUND) endif (ROOT_mathmore_FOUND)
#--- the next check is need to set a flag, since root 6.24 (minuit2) breaks #--- the next check is need to set a flag, since root 6.24 (minuit2) breaks
#--- the backwards compatibility. --------------------------------------------- #--- the backwards compatibility. ---------------------------------------------
if (ROOT_VERSION VERSION_LESS "6.23") if (ROOT_VERSION VERSION_LESS "6.23")
set(ROOT_GRTEQ_24 0) set(ROOT_GRTEQ_24 0)
else () else ()
set(ROOT_GRTEQ_24 1) set(ROOT_GRTEQ_24 1)
endif () endif ()
set(ROOT_GRTEQ_24 ${ROOT_GRTEQ_24} CACHE INTERNAL "ROOT Version check") set(ROOT_GRTEQ_24 ${ROOT_GRTEQ_24} CACHE INTERNAL "ROOT Version check")
#--- check for boost ---------------------------------------------------------- #--- check for boost ----------------------------------------------------------
find_package(Boost REQUIRED find_package(Boost REQUIRED
COMPONENTS COMPONENTS
system system
filesystem filesystem
) )
@ -135,7 +135,7 @@ if (qt_based_tools)
find_package(Qt6Xml CONFIG REQUIRED) find_package(Qt6Xml CONFIG REQUIRED)
find_package(Qt6Network CONFIG REQUIRED) find_package(Qt6Network CONFIG REQUIRED)
find_package(Qt6Svg CONFIG REQUIRED) find_package(Qt6Svg CONFIG REQUIRED)
find_package(Qt6PrintSupport CONFIG REQUIRED) find_package(Qt6PrintSupport CONFIG REQUIRED)
endif (Qt6Core_FOUND) endif (Qt6Core_FOUND)
# try Qt5 # try Qt5
if (NOT Qt6Core_FOUND) if (NOT Qt6Core_FOUND)
@ -232,7 +232,7 @@ endif ()
#--- propagate to the sub-directories ----------------------------------------- #--- propagate to the sub-directories -----------------------------------------
add_subdirectory(src) add_subdirectory(src)
#--- write summary of the installation #--- write summary of the installation
message("") message("")
message("|-----------------------------------------------------------------------|") message("|-----------------------------------------------------------------------|")
message("| |") message("| |")
@ -264,14 +264,14 @@ endif (OpenMP_FOUND)
if (nexus) if (nexus)
message("") message("")
message(" HDF4 found in ${HDF4_INCLUDE_DIRS}") message(" HDF4 found in ${HDF4_INCLUDE_DIRS}")
message(" HDF5 found in ${HDF5_INCLUDE_DIRS}") message(" HDF5 found in ${HDF5_INCLUDE_DIRS}")
message(" NeXus found in ${NEXUS_INCLUDE_DIR}") message(" NeXus found in ${NEXUS_INCLUDE_DIR}")
endif (nexus) endif (nexus)
message("") message("")
if (qt_based_tools) if (qt_based_tools)
if (Qt6Core_FOUND) if (Qt6Core_FOUND)
message(" Qt found in ${Qt6Core_INCLUDE_DIRS} (Version: ${Qt6Core_VERSION})") message(" Qt found in ${Qt6Core_INCLUDE_DIRS} (Version: ${Qt6Core_VERSION})")
else (Qt6Core_FOUND) else (Qt6Core_FOUND)
if (Qt5Core_FOUND) if (Qt5Core_FOUND)
@ -363,8 +363,8 @@ message("-----------------------------------------------------------------------
message("") message("")
#--- cpack specific info ...................................................... #--- cpack specific info ......................................................
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} PROJECT_SOURCE_DIR_NATIVE) file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} PROJECT_SOURCE_DIR_NATIVE)
file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} PROJECT_BINARY_DIR_NATIVE) file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} PROJECT_BINARY_DIR_NATIVE)
string(REPLACE "\\" "\\\\" PROJECT_SOURCE_DIR_NATIVE_D ${PROJECT_SOURCE_DIR_NATIVE}) string(REPLACE "\\" "\\\\" PROJECT_SOURCE_DIR_NATIVE_D ${PROJECT_SOURCE_DIR_NATIVE})
string(REPLACE "\\" "\\\\" PROJECT_BINARY_DIR_NATIVE_D ${PROJECT_BINARY_DIR_NATIVE}) string(REPLACE "\\" "\\\\" PROJECT_BINARY_DIR_NATIVE_D ${PROJECT_BINARY_DIR_NATIVE})

View File

@ -42,18 +42,18 @@ set(GENERATED_HEADER_FILES
set_property(SOURCE mupp_version.h PROPERTY SKIP_AUTOMOC ON) # needed for cmake 3.x set_property(SOURCE mupp_version.h PROPERTY SKIP_AUTOMOC ON) # needed for cmake 3.x
set(MUPP_SOURCE_FILES set(MUPP_SOURCE_FILES
mupp.cpp mupp.cpp
PmuppAdmin.cpp PmuppAdmin.cpp
Pmupp.cpp Pmupp.cpp
PmuppScript.cpp PmuppScript.cpp
PmuppGui.cpp PmuppGui.cpp
PVarDialog.cpp PVarDialog.cpp
) )
if (APPLE) if (APPLE)
set(RESOURCE_FILES icons/mupp.icns) set(RESOURCE_FILES icons/mupp.icns)
add_executable(mupp add_executable(mupp
MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} MACOSX_BUNDLE ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES}
mupp.qrc ${RESOURCE_FILES} mupp.qrc ${RESOURCE_FILES}
) )
else (APPLE) else (APPLE)
@ -62,24 +62,24 @@ endif (APPLE)
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H") set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO) else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- compiler option to workaround a little cast problem for some #--- compiler option to workaround a little cast problem for some
#--- boost/compiler combinations ---------------------------------------------- #--- boost/compiler combinations ----------------------------------------------
target_compile_options(mupp target_compile_options(mupp
PRIVATE PRIVATE
"-fpermissive" "-fpermissive"
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
#--- add the variable related sources ----------------------------------------- #--- add the variable related sources -----------------------------------------
add_subdirectory(var) add_subdirectory(var)
#--- add the necessary header includes ---------------------------------------- #--- add the necessary header includes ----------------------------------------
target_include_directories(mupp target_include_directories(mupp
BEFORE PRIVATE BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}> $<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..>
@ -104,6 +104,7 @@ if (APPLE)
MACOSX_FRAMEWORK_IDENTIFIER ch.psi.mupp MACOSX_FRAMEWORK_IDENTIFIER ch.psi.mupp
MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
RESOURCE "${RESOURCE_FILES}" RESOURCE "${RESOURCE_FILES}"
INSTALL_RPATH "${Qt6_DIR}/../.."
) )
endif (APPLE) endif (APPLE)

View File

@ -2,9 +2,9 @@
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H") set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO) else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ---------------------- #--- instruct CMake to run moc automatically when needed ----------------------
@ -29,7 +29,7 @@ if (APPLE)
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrStep add_executable(musrStep
${musrStep_src} ${musrStep_src}
musrStep.qrc musrStep.qrc
) )
@ -46,7 +46,7 @@ target_include_directories(musrStep
target_compile_options(musrStep target_compile_options(musrStep
PRIVATE PRIVATE
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrStep PRIVATE ${qt_libs}) target_link_libraries(musrStep PRIVATE ${qt_libs})
@ -62,6 +62,7 @@ if (APPLE)
MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrStep" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrStep"
MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
RESOURCE ${macosx_icon} RESOURCE ${macosx_icon}
INSTALL_RPATH "${Qt6_DIR}/../.."
) )
endif (APPLE) endif (APPLE)
@ -74,4 +75,3 @@ else (APPLE)
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
) )
endif (APPLE) endif (APPLE)

View File

@ -2,9 +2,9 @@
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H") set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO) else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ---------------------- #--- instruct CMake to run moc automatically when needed ----------------------
@ -30,10 +30,10 @@ if (APPLE)
add_executable(musrWiz MACOSX_BUNDLE add_executable(musrWiz MACOSX_BUNDLE
${musrWiz_src} ${musrWiz_src}
musrWiz.qrc musrWiz.qrc
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musrWiz add_executable(musrWiz
${musrWiz_src} ${musrWiz_src}
musrWiz.qrc musrWiz.qrc
) )
@ -50,7 +50,7 @@ target_include_directories(musrWiz
target_compile_options(musrWiz target_compile_options(musrWiz
PRIVATE PRIVATE
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musrWiz PRIVATE ${qt_libs}) target_link_libraries(musrWiz PRIVATE ${qt_libs})
@ -66,6 +66,7 @@ if (APPLE)
MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrWiz" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musrWiz"
MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
RESOURCE ${macosx_icon} RESOURCE ${macosx_icon}
INSTALL_RPATH "${Qt6_DIR}/../.."
) )
endif (APPLE) endif (APPLE)

View File

@ -2,9 +2,9 @@
#--- check if project source is repo ------------------------------------------ #--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO) if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H") set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO) else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "") set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO) endif (IS_GIT_REPO)
#--- instruct CMake to run moc automatically when needed ---------------------- #--- instruct CMake to run moc automatically when needed ----------------------
@ -63,7 +63,7 @@ set(musredit_ui
forms/PGetFourierBlockDialog.ui forms/PGetFourierBlockDialog.ui
forms/PGetPlotBlockDialog.ui forms/PGetPlotBlockDialog.ui
forms/PMsr2DataDialog.ui forms/PMsr2DataDialog.ui
forms/PChangeDefaultPathsDialog.ui forms/PChangeDefaultPathsDialog.ui
) )
if (APPLE) if (APPLE)
@ -72,7 +72,7 @@ if (APPLE)
else() else()
set(macosx_icon_name musredit.icns) set(macosx_icon_name musredit.icns)
endif() endif()
set(macosx_icon "icons/${macosx_icon_name}") set(macosx_icon "icons/${macosx_icon_name}")
add_executable(musredit MACOSX_BUNDLE add_executable(musredit MACOSX_BUNDLE
${musredit_src} ${musredit_src}
${musredit_ui} ${musredit_ui}
@ -80,7 +80,7 @@ if (APPLE)
${macosx_icon} ${macosx_icon}
) )
else (APPLE) else (APPLE)
add_executable(musredit add_executable(musredit
${musredit_src} ${musredit_src}
${musredit_ui} ${musredit_ui}
musredit.qrc musredit.qrc
@ -99,7 +99,7 @@ target_include_directories(musredit
target_compile_options(musredit target_compile_options(musredit
PRIVATE PRIVATE
"${HAVE_GIT_REV_H}" "${HAVE_GIT_REV_H}"
) )
target_link_libraries(musredit PRIVATE ${qt_libs}) target_link_libraries(musredit PRIVATE ${qt_libs})
@ -115,6 +115,7 @@ if (APPLE)
MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit" MACOSX_BUNDLE_GUI_IDENTIFIER "ch.psi.lmu.musredit"
MACOSX_BUNDLE_COPYRIGHT "Andreas Suter" MACOSX_BUNDLE_COPYRIGHT "Andreas Suter"
RESOURCE ${macosx_icon} RESOURCE ${macosx_icon}
INSTALL_RPATH "${Qt6_DIR}/../.."
) )
endif (APPLE) endif (APPLE)
@ -138,4 +139,3 @@ install(
${CMAKE_INSTALL_PREFIX}/share/doc/musrfit ${CMAKE_INSTALL_PREFIX}/share/doc/musrfit
MESSAGE_NEVER MESSAGE_NEVER
) )