summaryrefslogtreecommitdiffstats
path: root/project/cmake/modules/FindPython.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/modules/FindPython.cmake')
-rw-r--r--project/cmake/modules/FindPython.cmake43
1 files changed, 43 insertions, 0 deletions
diff --git a/project/cmake/modules/FindPython.cmake b/project/cmake/modules/FindPython.cmake
new file mode 100644
index 0000000..6f9f236
--- /dev/null
+++ b/project/cmake/modules/FindPython.cmake
@@ -0,0 +1,43 @@
1# - Try to find python
2# Once done this will define
3#
4# PYTHON_FOUND - system has PYTHON
5# PYTHON_INCLUDE_DIRS - the python include directory
6# PYTHON_LIBRARIES - The python libraries
7
8if(PKG_CONFIG_FOUND AND NOT CMAKE_CROSSCOMPILING)
9 pkg_check_modules (PYTHON python)
10endif()
11
12if(NOT PYTHON_FOUND)
13 if(CMAKE_CROSSCOMPILING)
14 find_program(PYTHON_EXECUTABLE python ONLY_CMAKE_FIND_ROOT_PATH)
15 find_library(PYTHON_LIBRARY NAMES python2.6 python2.7)
16 find_path(PYTHON_INCLUDE_DIRS NAMES Python.h PATHS ${DEPENDS_PATH}/include/python2.6 ${DEPENDS_PATH}/include/python2.7)
17 set(PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIRS} CACHE PATH "python include dir" FORCE)
18
19 find_library(FFI_LIBRARY ffi)
20 find_library(EXPAT_LIBRARY expat)
21 find_library(INTL_LIBRARY intl)
22
23 if(NOT CORE_SYSTEM_NAME STREQUAL android)
24 set(PYTHON_DEP_LIBRARIES -lpthread -ldl -lutil)
25 endif()
26
27 set(PYTHON_LIBRARIES ${PYTHON_LIBRARY} ${FFI_LIBRARY} ${EXPAT_LIBRARY} ${INTL_LIBRARY} ${PYTHON_DEP_LIBRARIES}
28 CACHE INTERNAL "python libraries" FORCE)
29 else()
30 find_package(PythonLibs)
31 endif()
32endif()
33
34include(FindPackageHandleStandardArgs)
35find_package_handle_standard_args(Python DEFAULT_MSG PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES)
36
37if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
38 find_library(FFI_LIBRARY ffi REQUIRED)
39 find_library(INTL_LIBRARY intl)
40 list(APPEND PYTHON_LIBRARIES ${FFI_LIBRARY} ${INTL_LIBRARY})
41endif()
42
43mark_as_advanced(PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES PYTHON_LDFLAGS)