forked from pydata/numexpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (92 loc) · 3.27 KB
/
CMakeLists.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# WARNING! EXPERIMENTAL! Use setup.py if you're not familiar with cmake.
#
# We recommend that you create a separate directory for the build,
# so that the build files aren't mixed in with the source files.
# e.g.
# $ mkdir build-cmake
# $ cd build-cmake
# $ cmake ..
# $ make
#
# MacOSX Notes:
# On MacOSX, it may default to 64-bit, even if your Python is 32-bit.
# The linker will give NO WARNING, and the resulting .so file will
# fail to load in Python. To fix this, run cmake as follows,
# assuming you're in <source dir>/build-cmake/:
# cmake -DCMAKE_OSX_ARCHITECTURES=i386 ..
# To debug this issue, you can compare "lipo -info `which python`"
# with "lipo -info numexpr.so". They should have the same platform info.
#
# Further problems on OS X appear to be related to EPD Python. CMake's
# default detection may be detecting the wrong python to link against.
#
# Windows Notes:
# Python 2.7 is built with Visual C++ 9 (aka 2008). This is the one
# you should pick when running cmake-gui. Be sure to switch the build
# configuration from Debug to Release (or RelWithDebInfo) in Visual Studio.
project(numexpr)
cmake_minimum_required(VERSION 2.8)
# Force the default build type to be Release, because a Debug
# build doesn't work properly with the default Python build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release
RelWithDebInfo MinSizeRel."
FORCE)
endif()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
find_package(PythonInterp REQUIRED)
find_package(PythonLibsNew REQUIRED)
find_package(NumPy REQUIRED)
# Default install location for Python packages
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PYTHON_SITE_PACKAGES}" CACHE STRING
"Choose the Python module directory (default site-packages)" FORCE)
endif()
# Require version >= 1.6
if(NUMPY_VERSION_DECIMAL LESS 10600)
message(FATAL_ERROR,
"NumExpr requires NumPy >= 1.6")
endif()
include_directories(
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
)
set(numexpr_SRC
numexpr/interpreter.cpp
numexpr/module.cpp
numexpr/numexpr_object.cpp
numexpr/complex_functions.hpp
numexpr/functions.hpp
numexpr/interpreter.hpp
numexpr/module.hpp
numexpr/missing_posix_functions.hpp
numexpr/msvc_function_stubs.hpp
numexpr/numexpr_config.hpp
numexpr/numexpr_object.hpp
numexpr/opcodes.hpp
)
if(CMAKE_HOST_WIN32)
set(numexpr_SRC
${numexpr_SRC}
numexpr/win32/pthread.c
)
endif()
python_add_module(interpreter ${numexpr_SRC})
# Generate __config__.py. This is a dummy placeholder, as I
# don't know why it's here.
file(WRITE "${PROJECT_BINARY_DIR}/__config__.py"
"# This file is generated by a CMakeFiles.txt configuration\n"
"__all__ = ['get_info','show']\n"
"def get_info(name):\n"
" return None\n"
"def show():\n"
" print('someone called show()')\n")
# Install all the Python scripts
install(DIRECTORY numexpr DESTINATION "${CMAKE_INSTALL_PREFIX}"
FILES_MATCHING PATTERN "*.py")
# Install __config__.py
install(FILES "${PROJECT_BINARY_DIR}/__config__.py"
DESTINATION "${CMAKE_INSTALL_PREFIX}/numexpr")
# Install the module
install(TARGETS interpreter DESTINATION "${CMAKE_INSTALL_PREFIX}/numexpr")