From 5376127a9774307cd37d802cc2bfe45c87961a03 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Mon, 20 Oct 2008 07:25:08 +0000 Subject: Moved here svn path=/trunk/KDE/kdelibs/; revision=873794 --- modules/FindPythonLibrary.cmake | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 modules/FindPythonLibrary.cmake (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake new file mode 100644 index 00000000..99fefdc2 --- /dev/null +++ b/modules/FindPythonLibrary.cmake @@ -0,0 +1,83 @@ +# Find Python +# ~~~~~~~~~~~ +# Copyright (c) 2007, Simon Edwards +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +# Find the Python interpreter and related Python directories. +# +# This file defines the following variables: +# +# PYTHON_EXECUTABLE - The path and filename of the Python interpreter. +# +# PYTHON_SHORT_VERSION - The version of the Python interpreter found, +# excluding the patch version number. (e.g. 2.5 and not 2.5.1)) +# +# PYTHON_LONG_VERSION - The version of the Python interpreter found as a human +# readable string. +# +# PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory. +# +# PYTHON_INCLUDE_PATH - Directory holding the python.h include file. +# +# PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library. + +INCLUDE(CMakeFindFrameworks) + +IF(EXISTS PYTHON_LIBRARY) + # Already in cache, be silent + SET(PYTHONLIBRARY_FOUND TRUE) +ELSE(EXISTS PYTHON_LIBRARY) + + FIND_PACKAGE(PythonInterp REQUIRED) + + FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) + + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) + IF(python_config) + STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) + STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) + STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) + set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) + if(WIN32) + STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) + endif(WIN32) + FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) + SET(PYTHONLIBRARY_FOUND TRUE) + ENDIF(python_config) + + # adapted from cmake's builtin FindPythonLibs + if(APPLE) + CMAKE_FIND_FRAMEWORKS(Python) + SET(PYTHON_FRAMEWORK_INCLUDES) + IF(Python_FRAMEWORKS) + # If a framework has been selected for the include path, + # make sure "-framework" is used to link it. + IF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + SET(PYTHON_LIBRARY "") + SET(PYTHON_DEBUG_LIBRARY "") + ENDIF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + IF(NOT PYTHON_LIBRARY) + SET (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE) + ENDIF(NOT PYTHON_LIBRARY) + SET(PYTHONLIBRARY_FOUND TRUE) + ENDIF(Python_FRAMEWORKS) + ENDIF(APPLE) + + IF(PYTHONLIBRARY_FOUND) + SET(PYTHON_LIBRARIES ${PYTHON_LIBRARY}) + IF(NOT PYTHONLIBRARY_FIND_QUIETLY) + MESSAGE(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}") + MESSAGE(STATUS "Found Python version: ${PYTHON_LONG_VERSION}") + MESSAGE(STATUS "Found Python library: ${PYTHON_LIBRARY}") + ENDIF(NOT PYTHONLIBRARY_FIND_QUIETLY) + ELSE(PYTHONLIBRARY_FOUND) + IF(PYTHONLIBRARY_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Python") + ENDIF(PYTHONLIBRARY_FIND_REQUIRED) + ENDIF(PYTHONLIBRARY_FOUND) + +ENDIF (EXISTS PYTHON_LIBRARY) -- cgit v1.2.1 From 3d39f82870e8a1d4eea0c4c02473686a73a4890f Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 5 Nov 2008 00:32:24 +0000 Subject: make optional detection of python work if python is not installed svn path=/trunk/KDE/kdelibs/; revision=880249 --- modules/FindPythonLibrary.cmake | 105 +++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 51 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index 99fefdc2..dd33ab37 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -24,60 +24,63 @@ INCLUDE(CMakeFindFrameworks) -IF(EXISTS PYTHON_LIBRARY) - # Already in cache, be silent - SET(PYTHONLIBRARY_FOUND TRUE) -ELSE(EXISTS PYTHON_LIBRARY) +if(EXISTS PYTHON_LIBRARY) + # Already in cache, be silent + set(PYTHONLIBRARY_FOUND TRUE) +else(EXISTS PYTHON_LIBRARY) - FIND_PACKAGE(PythonInterp REQUIRED) + FIND_PACKAGE(PythonInterp) - FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) + if(PYTHONINTERP_FOUND) - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) - IF(python_config) - STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) - STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) - STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) - STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) - STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) - STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) - set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) - if(WIN32) - STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) - endif(WIN32) - FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) - SET(PYTHONLIBRARY_FOUND TRUE) - ENDIF(python_config) + FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) - # adapted from cmake's builtin FindPythonLibs - if(APPLE) - CMAKE_FIND_FRAMEWORKS(Python) - SET(PYTHON_FRAMEWORK_INCLUDES) - IF(Python_FRAMEWORKS) - # If a framework has been selected for the include path, - # make sure "-framework" is used to link it. - IF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") - SET(PYTHON_LIBRARY "") - SET(PYTHON_DEBUG_LIBRARY "") - ENDIF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") - IF(NOT PYTHON_LIBRARY) - SET (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE) - ENDIF(NOT PYTHON_LIBRARY) - SET(PYTHONLIBRARY_FOUND TRUE) - ENDIF(Python_FRAMEWORKS) - ENDIF(APPLE) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) + if(python_config) + STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) + STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) + STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) + set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) + if(WIN32) + STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) + endif(WIN32) + FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) + set(PYTHONLIBRARY_FOUND TRUE) + endif(python_config) - IF(PYTHONLIBRARY_FOUND) - SET(PYTHON_LIBRARIES ${PYTHON_LIBRARY}) - IF(NOT PYTHONLIBRARY_FIND_QUIETLY) - MESSAGE(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}") - MESSAGE(STATUS "Found Python version: ${PYTHON_LONG_VERSION}") - MESSAGE(STATUS "Found Python library: ${PYTHON_LIBRARY}") - ENDIF(NOT PYTHONLIBRARY_FIND_QUIETLY) - ELSE(PYTHONLIBRARY_FOUND) - IF(PYTHONLIBRARY_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find Python") - ENDIF(PYTHONLIBRARY_FIND_REQUIRED) - ENDIF(PYTHONLIBRARY_FOUND) + # adapted from cmake's builtin FindPythonLibs + if(APPLE) + CMAKE_FIND_FRAMEWORKS(Python) + set(PYTHON_FRAMEWORK_INCLUDES) + if(Python_FRAMEWORKS) + # If a framework has been selected for the include path, + # make sure "-framework" is used to link it. + if("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + set(PYTHON_LIBRARY "") + set(PYTHON_DEBUG_LIBRARY "") + endif("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + if(NOT PYTHON_LIBRARY) + set (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE) + endif(NOT PYTHON_LIBRARY) + set(PYTHONLIBRARY_FOUND TRUE) + endif(Python_FRAMEWORKS) + endif(APPLE) + endif(PYTHONINTERP_FOUND) -ENDIF (EXISTS PYTHON_LIBRARY) + if(PYTHONLIBRARY_FOUND) + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY}) + if(NOT PYTHONLIBRARY_FIND_QUIETLY) + message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}") + message(STATUS "Found Python version: ${PYTHON_LONG_VERSION}") + message(STATUS "Found Python library: ${PYTHON_LIBRARY}") + endif(NOT PYTHONLIBRARY_FIND_QUIETLY) + else(PYTHONLIBRARY_FOUND) + if(PYTHONLIBRARY_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Python") + endif(PYTHONLIBRARY_FIND_REQUIRED) + endif(PYTHONLIBRARY_FOUND) + +endif (EXISTS PYTHON_LIBRARY) -- cgit v1.2.1 From 87c903a8e853eec433860818a01040da8d1c5f1a Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 4 Jan 2009 15:39:53 +0000 Subject: -add missing copyright notices, I hope I got it right -also a few empty lines here and there to make it look nicer Alex svn path=/trunk/KDE/kdelibs/; revision=905547 --- modules/FindPythonLibrary.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index dd33ab37..80f3f4ab 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -1,9 +1,5 @@ # Find Python # ~~~~~~~~~~~ -# Copyright (c) 2007, Simon Edwards -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# # Find the Python interpreter and related Python directories. # # This file defines the following variables: @@ -22,6 +18,12 @@ # # PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library. +# Copyright (c) 2007, Simon Edwards +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + + INCLUDE(CMakeFindFrameworks) if(EXISTS PYTHON_LIBRARY) -- cgit v1.2.1 From 424619adfbeaf79a0b4c1e4c3011aa45d2967901 Mon Sep 17 00:00:00 2001 From: Marcos David Dione Date: Sat, 9 May 2009 16:37:59 +0000 Subject: this patch honors -DPYTHON_SITE_PACKAGES_DIR. if not set, then checks for -DPYTHON_LIBS_WITH_KDE_LIBS. if set, it installs python modules in kde's lib dir; if not, it installs them in python's dir, which is the default. svn path=/trunk/KDE/kdelibs/; revision=965738 --- modules/FindPythonLibrary.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index 80f3f4ab..d98cb621 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -3,12 +3,12 @@ # Find the Python interpreter and related Python directories. # # This file defines the following variables: -# +# # PYTHON_EXECUTABLE - The path and filename of the Python interpreter. # # PYTHON_SHORT_VERSION - The version of the Python interpreter found, # excluding the patch version number. (e.g. 2.5 and not 2.5.1)) -# +# # PYTHON_LONG_VERSION - The version of the Python interpreter found as a human # readable string. # @@ -43,7 +43,13 @@ else(EXISTS PYTHON_LIBRARY) STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) - STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + if(NOT PYTHON_SITE_PACKAGES_DIR) + if(NOT PYTHON_LIBS_WITH_KDE_LIBS) + STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + else(NOT PYTHON_LIBS_WITH_KDE_LIBS) + set(PYTHON_SITE_PACKAGES_DIR ${KDE4_LIB_INSTALL_DIR}/python${PYTHON_SHORT_VERSION}/site-packages) + endif(NOT PYTHON_LIBS_WITH_KDE_LIBS) + endif(NOT PYTHON_SITE_PACKAGES_DIR) STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) if(WIN32) -- cgit v1.2.1 From e018549380e071f80dc01171446ff4bf9364292d Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 22 Jun 2010 20:03:50 +0000 Subject: -consistenly use lowercasing in this file Alex svn path=/trunk/KDE/kdelibs/; revision=1141452 --- modules/FindPythonLibrary.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index d98cb621..e96d63e6 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -24,44 +24,44 @@ -INCLUDE(CMakeFindFrameworks) +include(CMakeFindFrameworks) if(EXISTS PYTHON_LIBRARY) # Already in cache, be silent set(PYTHONLIBRARY_FOUND TRUE) else(EXISTS PYTHON_LIBRARY) - FIND_PACKAGE(PythonInterp) + find_package(PythonInterp) if(PYTHONINTERP_FOUND) - FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) + find_file(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) + execute_process(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) if(python_config) - STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) - STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) - STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) - STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) + string(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) + string(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) + string(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) + string(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) if(NOT PYTHON_SITE_PACKAGES_DIR) if(NOT PYTHON_LIBS_WITH_KDE_LIBS) - STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + string(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) else(NOT PYTHON_LIBS_WITH_KDE_LIBS) set(PYTHON_SITE_PACKAGES_DIR ${KDE4_LIB_INSTALL_DIR}/python${PYTHON_SHORT_VERSION}/site-packages) endif(NOT PYTHON_LIBS_WITH_KDE_LIBS) endif(NOT PYTHON_SITE_PACKAGES_DIR) - STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) + string(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) if(WIN32) - STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) + string(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) endif(WIN32) - FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) + find_library(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) set(PYTHONLIBRARY_FOUND TRUE) endif(python_config) # adapted from cmake's builtin FindPythonLibs if(APPLE) - CMAKE_FIND_FRAMEWORKS(Python) + cmake_find_frameworks(Python) set(PYTHON_FRAMEWORK_INCLUDES) if(Python_FRAMEWORKS) # If a framework has been selected for the include path, -- cgit v1.2.1 From dce1cd0521e1e308910390d67a2b38856d5b42f4 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 22 Jun 2010 20:39:03 +0000 Subject: -call FindLibPy.py directly from the same directory, no need to use find_file() here Alex svn path=/trunk/KDE/kdelibs/; revision=1141467 --- modules/FindPythonLibrary.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index e96d63e6..4fe427d0 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -35,9 +35,13 @@ else(EXISTS PYTHON_LIBRARY) if(PYTHONINTERP_FOUND) - find_file(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) + # get the directory of the current file, used later on in the file + get_filename_component( _py_cmake_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH) + if(NOT EXISTS "${_py_cmake_module_dir}/FindLibPython.py") + message(FATAL_ERROR "The file FindLibPython.py does not exist in ${_py_cmake_module_dir} (the directory where FindPythonLibrary.cmake is located). Check your installation.") + endif(NOT EXISTS "${_py_cmake_module_dir}/FindLibPython.py") - execute_process(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) + execute_process(COMMAND ${PYTHON_EXECUTABLE} "${_py_cmake_module_dir}/FindLibPython.py" OUTPUT_VARIABLE python_config) if(python_config) string(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) string(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) -- cgit v1.2.1 From ae8fa5c09c8d92d87a32ec910cddd33c46f753fa Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 23 Jun 2010 20:51:06 +0000 Subject: -add cache variable PYTHON_SITE_PACKAGES_INSTALL_DIR, this can be used as install destination for python modules, PYTHON_SITE_PACKAGES_DIR should not be used, since this most probably requires root permissions- The new variable can be adjusted via the cache. Also, this patch removes the PYTHON_LIBS_WITH_KDE_LIBS switch, this was undocumented, and anything with "KDE" in the name shouldn't appear in "FindPythonLibrary.cmake". Alex CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=1141934 --- modules/FindPythonLibrary.cmake | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index 4fe427d0..7b4b9538 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -12,6 +12,11 @@ # PYTHON_LONG_VERSION - The version of the Python interpreter found as a human # readable string. # +# PYTHON_SITE_PACKAGES_INSTALL_DIR - this cache variable can be used for installing +# own python modules. You may want to adjust this to be the +# same as ${PYTHON_SITE_PACKAGES_DIR}, but then admin +# privileges may be required for installation. +# # PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory. # # PYTHON_INCLUDE_PATH - Directory holding the python.h include file. @@ -46,14 +51,17 @@ else(EXISTS PYTHON_LIBRARY) string(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) string(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) string(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) - string(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) - if(NOT PYTHON_SITE_PACKAGES_DIR) - if(NOT PYTHON_LIBS_WITH_KDE_LIBS) - string(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) - else(NOT PYTHON_LIBS_WITH_KDE_LIBS) - set(PYTHON_SITE_PACKAGES_DIR ${KDE4_LIB_INSTALL_DIR}/python${PYTHON_SHORT_VERSION}/site-packages) - endif(NOT PYTHON_LIBS_WITH_KDE_LIBS) - endif(NOT PYTHON_SITE_PACKAGES_DIR) + + string(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" _TMP_PYTHON_INCLUDE_PATH ${python_config}) + string(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" _TMP_PYTHON_SITE_PACKAGES_DIR ${python_config}) + + # Put these two variables in the cache so they are visible for the user, but read-only: + set(PYTHON_INCLUDE_PATH "${_TMP_PYTHON_INCLUDE_PATH}" CACHE PATH "The python include directory" FORCE) + set(PYTHON_SITE_PACKAGES_DIR "${_TMP_PYTHON_SITE_PACKAGES_DIR}" CACHE PATH "The python site packages dir" FORCE) + + # This one is intended to be used and changed by the user for installing own modules: + set(PYTHON_SITE_PACKAGES_INSTALL_DIR lib/python${PYTHON_SHORT_VERSION}/site-packages CACHE PATH "The directory where python modules will be installed to.") + string(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) if(WIN32) -- cgit v1.2.1 From 65bce8b61f24033d79d14f21b975cc18cbfcb2b7 Mon Sep 17 00:00:00 2001 From: Michael Jansen Date: Thu, 24 Jun 2010 20:43:06 +0000 Subject: Make PYTHON_SITE_PACKAGES_INSTALL_DIR honor LIB_SUFFIX. svn path=/trunk/KDE/kdelibs/; revision=1142400 --- modules/FindPythonLibrary.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index 7b4b9538..141037fc 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -60,7 +60,7 @@ else(EXISTS PYTHON_LIBRARY) set(PYTHON_SITE_PACKAGES_DIR "${_TMP_PYTHON_SITE_PACKAGES_DIR}" CACHE PATH "The python site packages dir" FORCE) # This one is intended to be used and changed by the user for installing own modules: - set(PYTHON_SITE_PACKAGES_INSTALL_DIR lib/python${PYTHON_SHORT_VERSION}/site-packages CACHE PATH "The directory where python modules will be installed to.") + set(PYTHON_SITE_PACKAGES_INSTALL_DIR lib${LIB_SUFFIX}/python${PYTHON_SHORT_VERSION}/site-packages CACHE PATH "The directory where python modules will be installed to.") string(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) -- cgit v1.2.1 From 786680cdb287a4f23429b45780037c86c55aafc1 Mon Sep 17 00:00:00 2001 From: Michael Jansen Date: Thu, 8 Jul 2010 19:18:02 +0000 Subject: Make PYTHON_SITE_PACKAGES_INSTALL_DIR an absolute path. CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=1147584 --- modules/FindPythonLibrary.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/FindPythonLibrary.cmake') diff --git a/modules/FindPythonLibrary.cmake b/modules/FindPythonLibrary.cmake index 141037fc..60567e29 100644 --- a/modules/FindPythonLibrary.cmake +++ b/modules/FindPythonLibrary.cmake @@ -60,7 +60,7 @@ else(EXISTS PYTHON_LIBRARY) set(PYTHON_SITE_PACKAGES_DIR "${_TMP_PYTHON_SITE_PACKAGES_DIR}" CACHE PATH "The python site packages dir" FORCE) # This one is intended to be used and changed by the user for installing own modules: - set(PYTHON_SITE_PACKAGES_INSTALL_DIR lib${LIB_SUFFIX}/python${PYTHON_SHORT_VERSION}/site-packages CACHE PATH "The directory where python modules will be installed to.") + set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/python${PYTHON_SHORT_VERSION}/site-packages CACHE PATH "The directory where python modules will be installed to.") string(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) -- cgit v1.2.1