diff --git a/CMakeLists.txt b/CMakeLists.txt index 27c07ac1b5ee139f38f0d86c3c9ed5ece367d5b7..1786e4b14cc14618b755b3c74952b04638e6c04a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if(BORNAGAIN_MAN) add_subdirectory(Doc/UserManual) endif() -set(CMAKE_MACOSX_RPATH 1) +#set(CMAKE_MACOSX_RPATH 0) add_subdirectory(Core) add_subdirectory(ThirdParty/gtest) diff --git a/GUI/main/CMakeLists.txt b/GUI/main/CMakeLists.txt index 6c600d8c0669fd0b867db1209b60d80fe8116239..5681406803809c08ead7bb2c5e47f0f10eed4b7b 100644 --- a/GUI/main/CMakeLists.txt +++ b/GUI/main/CMakeLists.txt @@ -23,16 +23,7 @@ set(source_files set(include_files) -# MH: disabled crashhandler -#if(BORNAGAIN_CRASHHADLER) -# list(APPEND source_files crashhandlersetup.cpp stacktracesetup.cpp) -# list(APPEND include_files crashhandlersetup.h stacktracesetup.h) -# list(APPEND source_files stacktracesetup.cpp) -# list(APPEND include_files stacktracesetup.h) -#endif() - # Application icon - if(WIN32) set(RC_FILE bornagain.rc) if ( CONSOLE ) @@ -44,6 +35,7 @@ endif() if(APPLE AND CREATE_BUNDLE) +# set(CMAKE_MACOSX_RPATH 0) add_executable(${executable_name} MACOSX_BUNDLE ${source_files} ${include_files}) # get_filename_component(PYTHON_REAL_LIBRARY "${PYTHON_LIBRARY}" REALPATH) # add_library(Python SHARED IMPORTED) @@ -97,6 +89,17 @@ endif( WIN32 ) # --- Installation --- IF(APPLE AND CREATE_BUNDLE) + + set(link_flags "-Wl,-rpath,@loader_path/../") + set_target_properties(${executable_name} + PROPERTIES +# INSTALL_RPATH "@loader_path/.." + LINK_FLAGS ${link_flags} + ) + +# set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) +# set(CMAKE_INSTALL_RPATH "@loader_path/..") + set(plugin_dest_dir ${INBUNDLE}/Contents/PlugIns) set(qtconf_dest_dir ${INBUNDLE}/Contents/Resources) set(APPS "\${CMAKE_INSTALL_PREFIX}/${INBUNDLE}") @@ -130,8 +133,9 @@ IF(APPLE AND CREATE_BUNDLE) BUNDLE DESTINATION . COMPONENT Applications RUNTIME DESTINATION ${destination_bin} COMPONENT Runtime) +# set_target_properties(${executable_name} PROPERTIES INSTALL_RPATH "@loader_path/../" MACOSX_RPATH 1) -# install(DIRECTORY "$ENV{QTDIR}/plugins/platforms" DESTINATION ${plugin_dest_dir} COMPONENT Runtime) + install(DIRECTORY "$ENV{QTDIR}/plugins/platforms" DESTINATION ${plugin_dest_dir} COMPONENT Runtime) # set(qtconf_text " #[Paths] @@ -158,8 +162,6 @@ IF(APPLE AND CREATE_BUNDLE) configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/FixBundle.cmake.in ${CMAKE_BINARY_DIR}/FixBundle.cmake @ONLY) install(SCRIPT ${CMAKE_BINARY_DIR}/FixBundle.cmake COMPONENT Runtime) -# include(BundleUtilities) -# fixup_bundle(${CMAKE_INSTALL_PREFIX}/BornAgain.app "" "") else() install (TARGETS ${executable_name} DESTINATION ${destination_bin} COMPONENT Applications) diff --git a/cmake/modules/DarwinSetup.cmake b/cmake/modules/DarwinSetup.cmake index f7478f5695327944bedabbf3f6793435589b487f..b26b17ab5307ccf89739714672941e1d0bdc0a98 100644 --- a/cmake/modules/DarwinSetup.cmake +++ b/cmake/modules/DarwinSetup.cmake @@ -7,7 +7,7 @@ set ( INBUNDLE BornAgain.app ) set(destination_bin ${INBUNDLE}/Contents/MacOs) -set(destination_lib ${INBUNDLE}/Contents/MacOs) +set(destination_lib ${INBUNDLE}/Contents/lib/BornAgain-${BornAgain_VERSION_MAJOR}.${BornAgain_VERSION_MINOR}) set(destination_include ${INBUNDLE}/Contents/Resources/Headers) set(destination_examples ${INBUNDLE}/Contents/SharedSupport/Examples) diff --git a/cmake/modules/FixBundle.cmake.in b/cmake/modules/FixBundle.cmake.in index 340394f4e5a33342fcc4d16d71eaa22b18fa73f8..649de2ec24f2787c2f5e9dc28b7a535707550bb5 100644 --- a/cmake/modules/FixBundle.cmake.in +++ b/cmake/modules/FixBundle.cmake.in @@ -1,7 +1,15 @@ set ( bundle ${CMAKE_INSTALL_PREFIX}/BornAgain.app ) -message("AAAAA @CMAKE_SOURCE_DIR@") +#set(GP_RPATH_DIR ${bundle}/Contents) +set(BU_CHMOD_BUNDLE_ITEMS True) +set(BU_COPY_FULL_FRAMEWORK_CONTENTS False) + +#set(GP_RPATH_DIR "@loader_path/../") +#include (BundleUtilities) +include (@CMAKE_SOURCE_DIR@/cmake/modules/BundleUtilitiesWithRPath.cmake) + +#message("AAAAA @CMAKE_SOURCE_DIR@ ${GP_RPATH_DIR}") file ( GLOB pyqt_libs ${bundle}/Contents/MacOS/PyQt4/*.so ) file ( GLOB mantid_plugins ${bundle}/plugins/*.dylib ) @@ -18,9 +26,35 @@ function(gp_resolved_file_type_override resolved_file type_var) if(file MATCHES "Qt") message("XXX resolving file as _embedded : ${file}") set(${type_var} embedded PARENT_SCOPE) - elseif(file MATCHES "Python.framework") + + elseif(item MATCHES "PlugIns/platforms") message("XXX resolving file as _embedded : ${file}") set(${type_var} embedded PARENT_SCOPE) + + elseif(file MATCHES "Python.framework/Resources") + message("XXX resolving file as _embedded : ${file}") + set(${type_var} system PARENT_SCOPE) + + elseif(file MATCHES "Python.framework/Versions") + message("XXX resolving file as _embedded : ${file}") + set(${type_var} embedded PARENT_SCOPE) + + elseif(file MATCHES "/opt") + message("XXX resolving file as _embedded : ${file}") + set(${type_var} embedded PARENT_SCOPE) + + elseif(file MATCHES "libBornAgain") + message("XXX resolving file as _embedded : ${file}") + set(${type_var} embedded PARENT_SCOPE) + + elseif(file MATCHES "libManhattanStyle") + message("XXX resolving file as _embedded : ${file}") + set(${type_var} embedded PARENT_SCOPE) + +# elseif(file MATCHES "Python.framework") +# message("XXX resolving file as _embedded : ${file}") +# set(${type_var} embedded PARENT_SCOPE) + else() message("XXX resolving file as _system : ${file}") set(${type_var} system PARENT_SCOPE) @@ -58,8 +92,20 @@ function(gp_item_default_embedded_path_override item default_embedded_path_var) if(item MATCHES "[^/]+\\.framework/") set(path "@fixup_path@/Frameworks") - endif() + elseif(item MATCHES "PlugIns/platforms") + set(path "@fixup_path@/PlugIns/platforms") + + elseif(item MATCHES "libBornAgain") + set(path "@fixup_path@/lib/BornAgain-@BornAgain_VERSION_MAJOR@.@BornAgain_VERSION_MINOR@") + + elseif(item MATCHES "libManhattanStyle") + set(path "@fixup_path@/lib/BornAgain-@BornAgain_VERSION_MAJOR@.@BornAgain_VERSION_MINOR@") + + elseif(item MATCHES "\\.(dylib|so)$") + set(path "@fixup_path@/lib/ThirdParty") + + endif() # if(item MATCHES "Python.framework") ## set( path "@rpath" ) @@ -76,12 +122,6 @@ function(gp_item_default_embedded_path_override item default_embedded_path_var) endfunction(gp_item_default_embedded_path_override) -set(BU_CHMOD_BUNDLE_ITEMS True) -set(BU_COPY_FULL_FRAMEWORK_CONTENTS False) - -#include (BundleUtilities) -include (@CMAKE_SOURCE_DIR@/cmake/modules/BundleUtilitiesWithRPath.cmake) - #set ( mantidpydir ${bundle}/Contents/MacOS/mantid ) #set ( mantidpylibs ${mantidpydir}/kernel/_kernel.so # ${mantidpydir}/geometry/_geometry.so @@ -94,6 +134,33 @@ include (@CMAKE_SOURCE_DIR@/cmake/modules/BundleUtilitiesWithRPath.cmake) #set ( dirs "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" "@CMAKE_LIBRARY_PATH@" /Library/Frameworks /opt/intel/lib ) + +file(GLOB_RECURSE QTPLUGINS + "@CMAKE_INSTALL_PREFIX@/@plugin_dest_dir@/*@CMAKE_SHARED_LIBRARY_SUFFIX@") + +message("QQQQ QTPLUGINS ${QTPLUGINS}") + + set(qtconf_text " +[Paths] +Plugins = PlugIns + ") + +file(WRITE "@CMAKE_INSTALL_PREFIX@/@qtconf_dest_dir@/qt.conf" "${qtconf_text}") + + + set(dirs + "@CMAKE_BINARY_DIR@/lib" + "$ENV{QTDIR}" + "$ENV{QTDIR}/plugins" + ) + +set(other_libs +${QTPLUGINS} +) + +message("QQQQ QTPLUGINS ${QTPLUGINS} dirs ${dirs}") + + fixup_bundle ( "${bundle}" "${other_libs}" "${dirs}" ) # This will fix up the dependencies for the hard dependencies: MantidKernel etc ####################################################