forked from cryos/avogadro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PythonDeps.cmake
80 lines (69 loc) · 3.02 KB
/
PythonDeps.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Find All python dependencies
# This CMake file defines
# ALL_PYTHON_FOUND, if false, do not try to use python.
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND AND NUMPY_FOUND)
# In cache already
set(ALL_PYTHON_FOUND TRUE CACHE BOOL "True if all Python dependencies satisfied.")
else(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND AND NUMPY_FOUND)
message(STATUS "Searching for python dependencies...")
# Boost Python
message(STATUS "[1/5] Boost Python")
# CMake's new FindBoost has an option to look for additional versions
# e.g., there's now a 1.37.0 (and thus 1.37) release.
set(Boost_ADDITIONAL_VERSIONS "1.37" "1.37.0")
find_package(Boost COMPONENTS python)
if (Boost_PYTHON_FOUND)
message(STATUS "Boost Python found...")
else (Boost_PYTHON_FOUND)
message(STATUS "Boost Python NOT found - Python support disabled.")
# message(STATUS "debian/ubuntu: install the libboost-python-dev package.")
set(ALL_PYTHON_FOUND FALSE CACHE BOOL "True if all Python dependencies satisfied.")
return()
endif (Boost_PYTHON_FOUND)
# Python Libraries
message(STATUS "[2/5] Python Libraries")
find_package(PythonLibs)
if (NOT PYTHONLIBS_FOUND)
message(STATUS "Python libraries NOT found - Python support disabled.")
# message(STATUS "debian/ubuntu: install the python-dev package. Correct?????")
set(ALL_PYTHON_FOUND FALSE CACHE BOOL "True if all Python dependencies satisfied.")
return()
endif (NOT PYTHONLIBS_FOUND)
# Python Interpreter
message(STATUS "[3/5] Python Interpreter")
find_package(PythonInterp)
if (NOT PYTHONINTERP_FOUND)
message(STATUS "Python interpreter NOT found - Python support disabled.")
# message(STATUS "debian/ubuntu: install the python package.")
set(ALL_PYTHON_FOUND FALSE CACHE BOOL "True if all Python dependencies satisfied.")
return()
endif (NOT PYTHONINTERP_FOUND)
# Numpy
message(STATUS "[4/5] Numpy Module")
find_package(Numpy)
if (NOT NUMPY_FOUND)
message(STATUS "Numpy NOT found - Python support disabled.")
# message(STATUS "debian/ubuntu: install the python-numpy package.")
set(ALL_PYTHON_FOUND FALSE CACHE BOOL "True if all Python dependencies satisfied.")
return()
endif (NOT NUMPY_FOUND)
# SIP
message(STATUS "[5/5] SIP Module")
if (EXISTS ${PYTHON_INCLUDE_PATH}/sip.h)
message(STATUS "Found sip.h header...")
else (EXISTS ${PYTHON_INCLUDE_PATH}/sip.h)
message(STATUS "sip.h header NOT found - Python support disabled")
# message(STATUS "debian/ubuntu: install the python-sip4-dev package.")
set(ALL_PYTHON_FOUND FALSE CACHE BOOL "True if all Python dependencies satisfied.")
return()
endif (EXISTS ${PYTHON_INCLUDE_PATH}/sip.h)
# Everything was found, define ENABLE_PYTHON. This can be used in code:
#
# #ifdef ENABLE_PYTHON
# ...
# #endif
add_definitions( -DENABLE_PYTHON )
# to be used in subdir CMakeLists.txt files
set(ALL_PYTHON_FOUND TRUE CACHE BOOL "True if all Python dependencies satisfied.")
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND AND NUMPY_FOUND)
mark_as_advanced(ALL_PYTHON_FOUND)