Skip to content
Snippets Groups Projects
Commit b5ce5d2d authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

CMake: refactoring in CPack/Apple

parent a1364e3a
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ option(BORNAGAIN_APP "Build test application" OFF)
option(BORNAGAIN_GUI "Build a graphical user interface" OFF)
option(BORNAGAIN_MAN "Build a user manual" OFF)
option(BUILD_DEBIAN "Build a debian package" OFF)
option(CREATE_BUNDLE "Create a Mac OS X bundle" OFF)
option(BORNAGAIN_APPLE_BUNDLE "Create a Mac OS X bundle" OFF)
option(ROOT_SUPPORT "Build with dependencies from ROOT" ON)
option(BORNAGAIN_OPENMPI "Build with OpenMPI support" OFF)
option(BORNAGAIN_RELEASE "Special option for making release" OFF)
......
......@@ -149,22 +149,40 @@ else()
DESTINATION ${destination_libexec})
# creating bin directory for links
install(CODE "
FILE(MAKE_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
" COMPONENT Runtime)
# making links
install(CODE "
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
" COMPONENT Runtime)
install(CODE "
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
\"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
" COMPONENT Runtime)
# install(CODE "
# FILE(MAKE_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
# " COMPONENT Runtime)
# # making links
# install(CODE "
# execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
# \"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
# WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
# " COMPONENT Runtime)
# install(CODE "
# execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
# \"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
# WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
# " COMPONENT Runtime)
# install(CODE "
# FILE(MAKE_DIRECTORY \"${destination_bin}\")
# " COMPONENT Runtime)
# # making links
# install(CODE "
# execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
# \"../libexec/${destination_suffix}/frombin_setup_paths.sh\" \"thisbornagain.sh\"
# WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
# " COMPONENT Runtime)
# install(CODE "
# execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
# \"../libexec/${destination_suffix}/frombin_setup_paths.csh\" \"thisbornagain.csh\"
# WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${destination_bin}\")
# " COMPONENT Runtime)
endif()
......@@ -129,7 +129,7 @@ target_link_libraries(${library_name}
${ManhattanStyle_LIBRARY}
${qcustomplot_LIBRARY}
${qtpropertybrowser_LIBRARY}
${PYTHON_LIBRARY}
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
${BornAgainCore_LIBRARY}
${BornAgainFit_LIBRARY}
......
......@@ -59,7 +59,7 @@ target_link_libraries(${executable_name}
${ManhattanStyle_LIBRARY}
${qcustomplot_LIBRARY}
${qtpropertybrowser_LIBRARY}
${PYTHON_LIBRARY}
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
${BornAgainCore_LIBRARY}
${BornAgainFit_LIBRARY}
......@@ -94,21 +94,17 @@ elseif(APPLE)
MACOSX_BUNDLE_INFO_PLIST ${destination_runtime_configs}/Info.plist
)
#install ( FILES ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns
# DESTINATION ${INBUNDLE}/Contents/Resources/
#)
##set ( CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_SOURCE_DIR}/Images/osx-bundle-background.png )
##set ( CPACK_DMG_DS_STORE ${CMAKE_SOURCE_DIR}/Installers/MacInstaller/osx_DS_Store)
#set ( MACOSX_BUNDLE_ICON_FILE BornAgain.icns )
#SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(link_flags "-Wl,-rpath,@loader_path/../")
set_target_properties(${executable_name}
PROPERTIES
LINK_FLAGS ${link_flags}
)
endif()
# --- installation ---------
#install (TARGETS ${executable_name} DESTINATION ${destination_gui} COMPONENT Applications)
install (TARGETS ${executable_name} BUNDLE DESTINATION . RUNTIME DESTINATION ${destination_gui} COMPONENT Applications)
install (TARGETS ${executable_name} BUNDLE DESTINATION . COMPONENT Applications)
# install (TARGETS ${executable_name}
# BUNDLE DESTINATION . COMPONENT Applications
......@@ -119,13 +115,26 @@ set(image_files ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.ico ${CMAKE_SOURCE_DIR}/G
install (FILES ${image_files} DESTINATION ${destination_images} COMPONENT Applications)
# --- system dependent installation ---------
if(WIN32)
elseif(APPLE)
elseif(APPLE AND BORNAGAIN_APPLE_BUNDLE)
install( FILES ${CMAKE_SOURCE_DIR}/GUI/main/BornAgain.icns
DESTINATION ${destination_bundle}/Contents/Resources/
)
set(plugin_dest_dir ${destination_bundle}/Contents/PlugIns)
install(DIRECTORY "$ENV{QTDIR}/plugins/platforms" DESTINATION ${plugin_dest_dir} COMPONENT Runtime)
set(fixup_path @rpath)
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/FixAppleBundle.cmake.in ${destination_runtime_configs}/FixAppleBundle.cmake @ONLY)
install(SCRIPT ${destination_runtime_configs}/FixAppleBundle.cmake COMPONENT Runtime)
# get_filename_component(PYTHON_REAL_LIBRARY "${PYTHON_LIBRARY}" REALPATH)
# add_library(Python SHARED IMPORTED)
# set_property(TARGET Python PROPERTY IMPORTED_LOCATION ${PYTHON_LIBRARY})
# message("XXXXXX PYTHON_LIBRARY:${PYTHON_LIBRARY} PYTHON_REAL_LIBRARY:${PYTHON_REAL_LIBRARY} PYTHON_LIBRARIES:${PYTHON_LIBRARIES}")
endif()
......
# this script is a trick to print the message at the end of installation
if(NOT WIN32 AND NOT CREATE_BUNDLE)
if(NOT WIN32 AND NOT BORNAGAIN_APPLE_BUNDLE)
set(after_install_text "
Installation done. Please read below.
-------------------------------------------------------------------------------
......
set ( bundle ${CMAKE_INSTALL_PREFIX}/BornAgain.app )
set(bundle ${CMAKE_INSTALL_PREFIX}/BornAgain.app )
set(bornagain_libs ${CMAKE_INSTALL_PREFIX}/@destination_lib@)
set(thirdparty_libs ${CMAKE_INSTALL_PREFIX}/@destination_lib@)
#set(GP_RPATH_DIR ${bundle}/Contents)
set(BU_CHMOD_BUNDLE_ITEMS True)
......@@ -28,17 +31,13 @@ function(gp_resolved_file_type_override resolved_file type_var)
set(${type_var} embedded PARENT_SCOPE)
elseif(item MATCHES "PlugIns/platforms")
message("XXX resolving file as _embedded : ${file}")
message("XXX3 resolving file as _embedded : ${file}")
set(${type_var} embedded PARENT_SCOPE)
elseif(file MATCHES "Python.framework/Resources")
message("XXX resolving file as _embedded : ${file}")
elseif(file MATCHES "Python.framework")
message("XXX resolving file as system : ${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)
......@@ -163,6 +162,7 @@ message("QQQQ QTPLUGINS ${QTPLUGINS} dirs ${dirs}")
fixup_bundle ( "${bundle}" "${other_libs}" "${dirs}" ) # This will fix up the dependencies for the hard dependencies: MantidKernel etc
####################################################
# Functions to change the dependency references
####################################################
......@@ -174,3 +174,30 @@ function( change_bundle_dep old_dep new_dep sharedlib )
execute_process(COMMAND install_name_tool -change ${old_dep} ${new_dep} ${sharedlib})
endfunction()
function(fix_python_framework items_to_fix)
foreach(item ${items_to_fix})
message("XXXXXXXX -> fixing item ${item}")
get_prerequisites(${item} prereqs 0 0 "" "")
foreach(pr ${prereqs})
if(pr MATCHES "Python.framework")
message("XXXXXXXX ${pr}")
change_bundle_dep( ${pr} "@rpath/lib/ThirdParty/libpython2.7.dylib" ${item})
endif()
endforeach()
endforeach()
endfunction()
set(items_to_fix "${bundle}/Contents/MacOs/BornAgain")
file (GLOB items ${bornagain_libs}/*.so)
list(APPEND items_to_fix ${items})
file (GLOB items ${bundle}/Contents/lib/ThirdParty/*.dylib)
list(APPEND items_to_fix ${items})
message("AAA ${items_to_fix}")
fix_python_framework("${items_to_fix}")
message("Copying library @PYTHON_LIBRARIES@")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "@PYTHON_LIBRARIES@" "${bundle}/Contents/lib/ThirdParty/libpython2.7.dylib")
message(STATUS "aaaa @INBUNDLE@")
set(BU_CHMOD_BUNDLE_ITEMS True)
set(BU_COPY_FULL_FRAMEWORK_CONTENTS False)
set(plugin_dest_dir @INBUNDLE@/Contents/PlugIns)
set(qtconf_dest_dir @INBUNDLE@/Contents/Resources)
set(APPS @CMAKE_INSTALL_PREFIX@/@INBUNDLE@)
file(GLOB_RECURSE QTPLUGINS "@CMAKE_INSTALL_PREFIX@/${plugin_dest_dir}/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
message("AAAAA QTPLUGINS ${QTPLUGINS}")
message("AAAAA QTPLUGINS ${QTPLUGINS}")
include(BundleUtilities)
fixup_bundle(${APPS} "${QTPLUGINS}" "@DIRS@")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment