Skip to content

Commit

Permalink
fix/simplify Python CMake arguments
Browse files Browse the repository at this point in the history
- Created a variable PYTHONLIBS_CMAKE_ARGS that contains all
settings to be used.

- No longer pass PYTHON_INCLUDE_DIR from ...DIRS, nor
PYTHON_LIBRARY from ..LIBRARIES, but from the variable
itself. This caused problems when
there are multiple files, and in particular debug and release
Python libraries present.

Fixes SyneRBI#472
  • Loading branch information
KrisThielemans committed Jan 15, 2021
1 parent 199921c commit 0c55892
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
19 changes: 15 additions & 4 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ else()
CONDA: do nothing")
set_property(CACHE PYTHON_STRATEGY PROPERTY STRINGS PYTHONPATH SETUP_PY CONDA)
endif()

# set PYTHONLIBS_CMAKE_ARGS to be used in the ExternalProject_add calls
# note: Find_package(PythonLibs) takes PYTHON_INCLUDE_DIR and PYTHON_LIBRARY as input
set (PYTHONLIBS_CMAKE_ARGS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE})
if (EXISTS ${PYTHON_INCLUDE_DIR})
set (PYTHONLIBS_CMAKE_ARGS ${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR})
endif()
if (EXISTS ${PYTHON_LIBRARY})
set (PYTHONLIBS_CMAKE_ARGS ${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY})
endif()


message(STATUS "PYTHONLIBS_CMAKE_ARGS= " "${PYTHONLIBS_CMAKE_ARGS}")
endif()

#### MATLAB support
Expand Down Expand Up @@ -313,12 +328,8 @@ message(STATUS "")
message(STATUS "Boost_CMAKE_ARGS= " "${Boost_CMAKE_ARGS}")
message(STATUS "ISMRMRD_DIR = " ${ISMRMRD_DIR})
message(STATUS "STIR_DIR = " ${STIR_DIR})
message(STATUS "HDF5_ROOT = " ${HDF5_ROOT})
message(STATUS "GTEST_ROOT = " ${GTEST_ROOT})
message(STATUS "Matlab_ROOT_DIR = " ${Matlab_ROOT_DIR})
message(STATUS "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
message(STATUS "PYTHON_LIBRARIES=${PYTHON_LIBRARIES}")
message(STATUS "PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}")

#Need to configure main project here.
#set(proj ${PRIMARY_PROJECT_NAME})
Expand Down
4 changes: 1 addition & 3 deletions SuperBuild/External_CCPi-Framework.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${${proj}_TAG}
${CMAKE_COMMAND} ${${proj}_SOURCE_DIR}
-DCMAKE_INSTALL_PREFIX:PATH=${${proj}_INSTALL_DIR}
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARIES}
${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_DEST_DIR:PATH=${PYTHON_DEST}
-DOPENMP_INCLUDES:PATH=${OPENMP_INCLUDES}
-DCIL_VERSION:STRING=${${proj}_TAG}
Expand Down
4 changes: 1 addition & 3 deletions SuperBuild/External_CCPi-Regularisation-Toolkit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_PYTHON_WRAPPER:BOOL=ON
-DBUILD_CUDA:BOOL=${${proj}_USE_CUDA} -DCONDA_BUILD:BOOL=OFF
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARIES}
${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_DEST_DIR:PATH=${PYTHON_DEST}

BUILD_COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${${proj}_TAG} ${CMAKE_COMMAND} --build .
Expand Down
4 changes: 1 addition & 3 deletions SuperBuild/External_Gadgetron.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DCMAKE_INCLUDE_PATH:PATH=${SUPERBUILD_INSTALL_DIR}/include
-DCMAKE_INSTALL_PREFIX:PATH=${Gadgetron_INSTALL_DIR}
${Boost_CMAKE_ARGS}
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARIES}
${PYTHONLIBS_CMAKE_ARGS}
-DGTEST_ROOT:PATH=${GTEST_ROOT}
${HDF5_CMAKE_ARGS}
${FFTW3_CMAKE_ARGS}
Expand Down
4 changes: 1 addition & 3 deletions SuperBuild/External_SIRF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DISMRMRD_DIR:PATH=${ISMRMRD_DIR}
-DSWIG_EXECUTABLE:FILEPATH=${SWIG_EXECUTABLE}
-DDISABLE_PYTHON:BOOL=${DISABLE_PYTHON}
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARIES}
${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_DEST_DIR:PATH=${PYTHON_DEST_DIR}
-DPYTHON_STRATEGY=${PYTHON_STRATEGY}
-DNIFTYREG_DIR:PATH=${NIFTYREG_DIR}
Expand Down
1 change: 1 addition & 0 deletions SuperBuild/External_STIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DBUILD_EXECUTABLES:BOOL=${STIR_BUILD_EXECUTABLES}
-DBUILD_SWIG_PYTHON:BOOL=${STIR_BUILD_SWIG_PYTHON}
-DPYTHON_DEST:PATH=${PYTHON_DEST}
${PYTHONLIBS_CMAKE_ARGS}
-DMatlab_ROOT_DIR:PATH=${Matlab_ROOT_DIR}
-DMATLAB_DEST:PATH=${MATLAB_DEST}
-DBUILD_TESTING:BOOL=${BUILD_TESTING_${proj}}
Expand Down
4 changes: 1 addition & 3 deletions SuperBuild/External_TomoPhantom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
-DINCLUDE_DIR:PATH=${${proj}_INSTALL_DIR}/include
-DCONDA_BUILD=OFF
-DBUILD_PYTHON_WRAPPER=ON
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIRS}
-DPYTHON_LIBRARY=${PYTHON_LIBRARIES}
${PYTHONLIBS_CMAKE_ARGS}
-DPYTHON_DEST_DIR:PATH=${PYTHON_DEST_DIR}
-DPYTHON_STRATEGY=${PYTHON_STRATEGY}
${${proj}_EXTRA_CMAKE_ARGS_LIST}
Expand Down

0 comments on commit 0c55892

Please sign in to comment.