From 7f7449aff1631c8521951730bd800b172b56b103 Mon Sep 17 00:00:00 2001
From: Marina Ganeva <m.ganeva@fz-juelich.de>
Date: Wed, 11 Feb 2015 16:51:21 +0100
Subject: [PATCH] Minor changes to cmake files to fix the build with macports.

---
 Code/Mantid/Build/CMake/DarwinSetup.cmake | 24 ++++++++++++++++-------
 Code/Mantid/MantidPlot/CMakeLists.txt     |  5 ++++-
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Code/Mantid/Build/CMake/DarwinSetup.cmake b/Code/Mantid/Build/CMake/DarwinSetup.cmake
index c41894c747d..71bc1e55af9 100644
--- a/Code/Mantid/Build/CMake/DarwinSetup.cmake
+++ b/Code/Mantid/Build/CMake/DarwinSetup.cmake
@@ -131,20 +131,30 @@ else()
  set ( CMAKE_OSX_ARCHITECTURES x86_64 )
  set ( CMAKE_OSX_DEPLOYMENT_TARGET 10.8 )
  # Follow symlinks so cmake copies the file
- set ( PYQT4_PATH /usr/local/lib/python${PY_VER}/site-packages/PyQt4 )
+ # PYQT4_PATH, SITEPACKAGES_PATH, OPENSSL_ROOT_DIR may be defined externally (cmake -D)
+ # it would be good do not overwrite them (important for the compilation with macports)
+ if (NOT PYQT4_PATH)
+  set ( PYQT4_PATH /usr/local/lib/python${PY_VER}/site-packages/PyQt4 )
+ endif(NOT PYQT4_PATH)
  execute_process(COMMAND readlink ${PYQT4_PATH}/Qt.so OUTPUT_VARIABLE PYQT4_SYMLINK_Qtso)
- string(FIND ${PYQT4_SYMLINK_Qtso} "Qt.so" STOPPOS)
- string(SUBSTRING ${PYQT4_SYMLINK_Qtso} 0 ${STOPPOS} PYQT4_SYMLINK)
+ string(FIND "${PYQT4_SYMLINK_Qtso}" "Qt.so" STOPPOS)
+ string(SUBSTRING "${PYQT4_SYMLINK_Qtso}" 0 ${STOPPOS} PYQT4_SYMLINK)
  set  ( PYQT4_PYTHONPATH ${PYQT4_PATH}/${PYQT4_SYMLINK} )
+ string(REGEX REPLACE "/$" "" PYQT4_PYTHONPATH "${PYQT4_PYTHONPATH}")
 
- set ( SITEPACKAGES_PATH /usr/local/lib/python${PY_VER}/site-packages )
+ if (NOT SITEPACKAGES_PATH)
+   set ( SITEPACKAGES_PATH /usr/local/lib/python${PY_VER}/site-packages )
+ endif(NOT SITEPACKAGES_PATH)
  execute_process(COMMAND readlink ${SITEPACKAGES_PATH}/sip.so OUTPUT_VARIABLE SITEPACKAGES_SYMLINK_sipso)
- string(FIND ${SITEPACKAGES_SYMLINK_sipso} "sip.so" STOPPOS)
- string(SUBSTRING ${SITEPACKAGES_SYMLINK_sipso} 0 ${STOPPOS} SITEPACKAGES_SYMLINK)
+ string(FIND "${SITEPACKAGES_SYMLINK_sipso}" "sip.so" STOPPOS)
+ string(SUBSTRING "${SITEPACKAGES_SYMLINK_sipso}" 0 ${STOPPOS} SITEPACKAGES_SYMLINK)
  set  ( SITEPACKAGES ${SITEPACKAGES_PATH}/${SITEPACKAGES_SYMLINK} )
+ string(REGEX REPLACE "/$" "" SITEPACKAGES "${SITEPACKAGES}")
 
  # use homebrew OpenSSL package
- set ( OPENSSL_ROOT_DIR /usr/local/opt/openssl )
+ if (NOT OPENSSL_ROOT_DIR)
+   set ( OPENSSL_ROOT_DIR /usr/local/opt/openssl )
+ endif(NOT OPENSSL_ROOT_DIR)
 endif()
 
 # Python packages
diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt
index a82011bd456..68daaff89d6 100644
--- a/Code/Mantid/MantidPlot/CMakeLists.txt
+++ b/Code/Mantid/MantidPlot/CMakeLists.txt
@@ -1037,8 +1037,11 @@ foreach(PY_FILE ${IPY_FILES} )
 endforeach()
 install ( FILES ${CONFIG_RESET_SCRIPT} DESTINATION ${BIN_DIR} )
 
+# file make_package.rb contains hard-coded path to the libraries
+# this causes fail of the installation with macports
+# therefore MACPORTS option is introduced
 if ( APPLE )
-  if (OSX_VERSION VERSION_LESS 10.9)
+  if (OSX_VERSION VERSION_LESS 10.9 OR MACPORTS)
     configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/FixBundle.cmake.in
                    ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake
                    @ONLY )
-- 
GitLab