diff --git a/CEP/Calibration/BBSControl/CMakeLists.txt b/CEP/Calibration/BBSControl/CMakeLists.txt index 242cd8f453ce9d230c63658541019788995d13d5..3fc6ca9275a7897d0f620b07f3ac62104609346e 100644 --- a/CEP/Calibration/BBSControl/CMakeLists.txt +++ b/CEP/Calibration/BBSControl/CMakeLists.txt @@ -7,7 +7,6 @@ include(LofarFindPackage) lofar_find_package(Boost REQUIRED) lofar_find_package(Casacore REQUIRED COMPONENTS casa) lofar_find_package(PQXX REQUIRED) -lofar_find_package(Python REQUIRED) add_subdirectory(include/BBSControl) add_subdirectory(src) diff --git a/CMake/FindPython.cmake b/CMake/FindPython.cmake index d5f0ea77ad03687e18275f74f7af4fc6b7c75bd1..eb3772163a879f58e5fb57ff05e09ec5cede8675 100644 --- a/CMake/FindPython.cmake +++ b/CMake/FindPython.cmake @@ -36,37 +36,16 @@ if(Python_FIND_REQUIRED) set(_options REQUIRED) endif(Python_FIND_REQUIRED) -# Search for the Python interpreter +# Search for the Python interpreter. find_package(PythonInterp ${_options}) -# Search for the Python header files and libraries +# Search for the Python header files and libraries. find_package(PythonLibs ${_options}) -# Derive the Python site-packages installation directory and build directory -if(NOT PYTHON_FOUND) - if(PYTHON_EXECUTABLE) - set(_cmd - "from distutils.sysconfig import get_python_lib" - "print get_python_lib(plat_specific=True, prefix='')") - execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" - OUTPUT_VARIABLE _pydir - ERROR_VARIABLE _err - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(_err) - message(FATAL_ERROR "Python command failed:\n${_err}") - endif(_err) - set(PYTHON_BUILD_DIR "${CMAKE_BINARY_DIR}/${_pydir}" CACHE PATH - "Build directory for Python extensions") - set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_pydir}" CACHE PATH - "Installation directory for Python extensions") - endif(PYTHON_EXECUTABLE) -endif(NOT PYTHON_FOUND) - # Set PYTHON_INCLUDE_DIRS variable, because FindPythonLibs does not do it. set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}") -# Set PYTHON_FOUND to TRUE if both Python interpreter and libraries are found +# Set PYTHON_FOUND to TRUE if both Python interpreter and libraries are found. set(PYTHON_FOUND FALSE) if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND) set(PYTHON_FOUND TRUE) diff --git a/CMake/PythonInstall.cmake b/CMake/PythonInstall.cmake index ff489d67b80bdf934ff50900177070cb29394567..b88633db1b2e12365536274ca094c94698f290a3 100644 --- a/CMake/PythonInstall.cmake +++ b/CMake/PythonInstall.cmake @@ -25,14 +25,35 @@ # # $Id$ -macro(python_install) +# Search for the Python interpreter +find_package(PythonInterp) + +# Derive the Python site-packages installation directory and build directory +if(PYTHON_EXECUTABLE) + set(_cmd + "from distutils.sysconfig import get_python_lib" + "print get_python_lib(plat_specific=True, prefix='')") + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" + OUTPUT_VARIABLE _pydir + ERROR_VARIABLE _pyerr + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_pyerr) + message(FATAL_ERROR "Python command failed:\n${_pyerr}") + endif(_pyerr) + set(PYTHON_BUILD_DIR "${CMAKE_BINARY_DIR}/${_pydir}" CACHE PATH + "Build directory for Python extensions") + set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_pydir}" CACHE PATH + "Installation directory for Python extensions") +endif(PYTHON_EXECUTABLE) + - # Precondition checks. - if(NOT DEFINED PYTHON_INSTALL_DIR) - message(FATAL_ERROR "python_install: PYTHON_INSTALL_DIR is undefined." - "\nMaybe you forgot to do a `find_package(Python)'?") - endif(NOT DEFINED PYTHON_INSTALL_DIR) +# +# macro python_install +# +macro(python_install) + # Precondition check. if(NOT PYTHON_EXECUTABLE) message(FATAL_ERROR "python_install: Python interpreter not available") endif(NOT PYTHON_EXECUTABLE) @@ -49,7 +70,7 @@ macro(python_install) message(FATAL_ERROR "python_install: destination directory invalid") endif(_dest_dir MATCHES "^$" OR _dest_dir MATCHES ";") - # Set python package install directory. + # Set python package build/install directory. set(_inst_dir "${PYTHON_INSTALL_DIR}/${_dest_dir}") set(_build_dir "${PYTHON_BUILD_DIR}/${_dest_dir}")