Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose python strategy #109

Merged
merged 3 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## New in Release 1.0
# ChangeLog

## master

* Added PYTHON_DEST_DIR variable, which allows the user to select the install destination of the SIRF python modules. PYTHON_DEST_DIR is a cached variable which can be updated on the GUI. If PYTHON_DEST_DIR is not set, we will install in ${CMAKE_INSTALL_PREFIX}/python. Likewise for MATLAB_DEST_DIR.

## v1.0.0

- optionally build siemens_to_ismrmrd
- optionally build petmr_rd_tools
- major [restructuring](https://github.com/CCPPETMR/SIRF-SuperBuild/issues/16#issuecomment-360772097) of SuperBuild build directory
Expand Down
34 changes: 18 additions & 16 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#========================================================================
# Author: Benjamin A Thomas
# Author: Edoardo Pasca
# Author: Casper da Costa-Luis
# Copyright 2017 University College London
# Copyright 2017 Science Technology Facilities Council
#
Expand Down Expand Up @@ -178,48 +179,49 @@ set(CCPPETMR_INSTALL ${SUPERBUILD_INSTALL_DIR})
## in the env_ccppetmr scripts we perform a substitution of the whole block
## during the configure_file() command call below.

## Note that the MATLAB_DEST and PYTHON_DEST variables are currently set
## in External_SIRF.cmake. That's a bit confusing of course (TODO).
## Note that the (MATLAB|PYTHON)_DEST and PYTHON_STRATEGY variables are
## currently set in External_SIRF.cmake. That's a bit confusing of course (TODO).
set(ENV_PYTHON_BASH "##### Python not found #####")
set(ENV_PYTHON_CSH "##### Python not found #####")
if(PYTHONINTERP_FOUND)
if("${PYTHON_STRATEGY}" STREQUAL "PYTHONPATH")
set(COMMENT_OUT_PREFIX "")
else()
set(COMMENT_OUT_PREFIX "#")
endif()

set (ENV_PYTHON_CSH "\
if $?PYTHONPATH then \n\
setenv PYTHONPATH ${PYTHON_DEST}:$PYTHONPATH \n\
else \n\
setenv PYTHONPATH ${PYTHON_DEST} \n\
setenv SIRF_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}")
${COMMENT_OUT_PREFIX}if $?PYTHONPATH then \n\
${COMMENT_OUT_PREFIX} setenv PYTHONPATH ${PYTHON_DEST}:$PYTHONPATH \n\
${COMMENT_OUT_PREFIX}else \n\
${COMMENT_OUT_PREFIX} setenv PYTHONPATH ${PYTHON_DEST} \n\
setenv SIRF_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}")

set (ENV_PYTHON_BASH "\
PYTHONPATH=${PYTHON_DEST}:$PYTHONPATH \n\
export PYTHONPATH \n\
SIRF_PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} \n\
export SIRF_PYTHON_EXECUTABLE")

${COMMENT_OUT_PREFIX}export PYTHONPATH=\"${PYTHON_DEST}\${PYTHONPATH:+:\${PYTHONPATH}}\" \n\
export SIRF_PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
endif()

set(ENV_MATLAB_BASH "##### Matlab not found #####")
set(ENV_MATLAB_CSH "##### Matlab not found #####")
if (Matlab_FOUND)
set(ENV_MATLAB_BASH "\
MATLABPATH=${MATLAB_DEST}\n\
MATLABPATH=${MATLAB_DEST}\n\
export MATLABPATH\n\
SIRF_MATLAB_EXECUTABLE=${Matlab_MAIN_PROGRAM}\n\
export SIRF_MATLAB_EXECUTABLE")
set(ENV_MATLAB_CSH "\
if $?MATLABPATH then\n\
setenv MATLABPATH ${MATLAB_DEST}:$MATLABPATH\n\
setenv MATLABPATH ${MATLAB_DEST}:$MATLABPATH\n\
else\n\
setenv MATLABPATH ${MATLAB_DEST}\n\
setenv MATLABPATH ${MATLAB_DEST}\n\
endif\n\
setenv SIRF_MATLAB_EXECUTABLE ${Matlab_MAIN_PROGRAM}")
endif()

configure_file(env_ccppetmr.sh.in ${CCPPETMR_INSTALL}/bin/env_ccppetmr.sh)
configure_file(env_ccppetmr.csh.in ${CCPPETMR_INSTALL}/bin/env_ccppetmr.csh)


# add tests
enable_testing()
add_test(NAME SIRF_TESTS
Expand Down
31 changes: 26 additions & 5 deletions SuperBuild/External_SIRF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,36 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr

set (BUILD_PYTHON ${PYTHONLIBS_FOUND})
if (BUILD_PYTHON)
set(PYTHON_DEST "${SIRF_Install_Dir}/python" CACHE PATH "Destination for python modules")
set(PYTHON_DEST_DIR "" CACHE PATH "Directory of the SIRF Python modules")
if (PYTHON_DEST_DIR)
set(PYTHON_DEST "${PYTHON_DEST_DIR}")
else()
set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python")
endif()
message(STATUS "Python libraries found")
message(STATUS "SIRF Python modules will be installed in " ${PYTHON_DEST})

set(PYTHON_STRATEGY "PYTHONPATH" CACHE STRING "\
PYTHONPATH: prefix PYTHONPATH \n\
SETUP_PY: execute ${PYTHON_EXECUTABLE} setup.py install \n\
CONDA: do nothing")
set_property(CACHE PYTHON_STRATEGY PROPERTY STRINGS PYTHONPATH SETUP_PY CONDA)
endif()
set (BUILD_MATLAB ${Matlab_FOUND})
if (BUILD_MATLAB)
set(MATLAB_DEST "${SIRF_Install_Dir}/matlab" CACHE PATH "Destination for matlab modules")
set(MATLAB_DEST_DIR "" CACHE PATH "Directory of the SIRF Matlab libraries")
if (MATLAB_DEST_DIR)
set(MATLAB_DEST "${MATLAB_DEST_DIR}")
else()
set(MATLAB_DEST "${CMAKE_INSTALL_PREFIX}/matlab")
endif()
message(STATUS "Matlab libraries found")
message(STATUS "SIRF Matlab libraries will be installed in " ${MATLAB_DEST})
endif()

message(STATUS "HDF5_ROOT in External_SIRF: " ${HDF5_ROOT})
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${SUPERBUILD_INSTALL_DIR})

ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
GIT_REPOSITORY ${${proj}_URL}
Expand All @@ -78,7 +98,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DBOOST_ROOT=${BOOST_ROOT}
-DMatlab_ROOT_DIR=${Matlab_ROOT_DIR}
-DMATLAB_ROOT=${Matlab_ROOT_DIR} # pass this for compatibility with old SIRF
-DMATLAB_DEST=${MATLAB_DEST}
-DMATLAB_DEST_DIR=${MATLAB_DEST_DIR}
-DSTIR_DIR=${STIR_DIR}
-DHDF5_ROOT=${HDF5_ROOT}
-DHDF5_INCLUDE_DIRS=${HDF5_INCLUDE_DIRS}
Expand All @@ -87,7 +107,8 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY=${PYTHON_LIBRARIES}
-DPYTHON_DEST=${PYTHON_DEST}
-DPYTHON_DEST_DIR=${PYTHON_DEST_DIR}
-DPYTHON_STRATEGY=${PYTHON_STRATEGY}
INSTALL_DIR ${SIRF_Install_Dir}
DEPENDS
${${proj}_DEPENDENCIES}
Expand Down