forked from halide/Halide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
95 lines (79 loc) · 2.42 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
project(PyHalide)
cmake_minimum_required(VERSION 3.0) # for up-to-date FindPythonLibs.cmake
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR} )
# Find Python and boost python
if(USE_PYTHON EQUAL 2)
find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(NumPy REQUIRED)
if (NOT USE_EXTERNAL_BOOST)
find_package(Boost COMPONENTS python REQUIRED)
endif()
find_package(Halide REQUIRED)
else()
find_package(PythonInterp 3.4 REQUIRED)
find_package(PythonLibs 3.4 REQUIRED)
find_package(NumPy REQUIRED)
if (NOT USE_EXTERNAL_BOOST)
string( REGEX REPLACE "([0-9]+).([0-9]+).[0-9.]+" "\\1\\2" PYTHON_CONCAT_VERSION_STRING ${PYTHON_VERSION_STRING} )
find_package(Boost COMPONENTS python-py${PYTHON_CONCAT_VERSION_STRING})
if(NOT Boost_FOUND)
find_package(Boost COMPONENTS python3 REQUIRED)
endif()
endif()
find_package(Halide REQUIRED)
endif()
option(USE_BOOST_NUMPY "Use Boost.Numpy dependency instead of Halide.Numpy" OFF)
if(USE_BOOST_NUMPY)
add_definitions( -DUSE_BOOST_NUMPY )
set(BoostNumpy_INCLUDE_DIRS "")
set(BoostNumpy_LIBRARY_DIR "")
set(BoostNumpy_LIBRARIES boost_numpy)
else()
#(NOT USE_BOOST_NUMPY) is true
file(GLOB MicroNumpyCpp
numpy/*.cpp
numpy/*.hpp
)
add_library(halide_numpy STATIC ${MicroNumpyCpp})
target_link_libraries(halide_numpy ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${NumPy_LIBRARIES})
set_property(TARGET halide_numpy PROPERTY POSITION_INDEPENDENT_CODE TRUE)
set(BoostNumpy_INCLUDE_DIRS ./numpy)
set(BoostNumpy_LIBRARY_DIR ./numpy)
set(BoostNumpy_LIBRARIES halide_numpy)
endif()
add_definitions("-std=c++11")
include_directories(
${HALIDE_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${BoostNumpy_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
)
link_directories(
../build/lib
${HALIDE_ROOT_DIR}/lib
${Boost_LIBRARY_DIRS}
${BoostNumpy_LIBRARY_DIR}
${Numpy_LIBRARY_DIR}
)
if(FALSE AND UNIX )
# Disable the pointer-to-function and pointer-to-object warnings
add_definitions( -Wno-unused-local-typedefs )
set_property(SOURCE util.cpp PROPERTY COMPILE_FLAGS -w )
endif()
file(GLOB SrcCpp
python/*.cpp
../src/OutputImageParam.cpp
../src/ImageParam.cpp)
add_library(halide SHARED ${SrcCpp})
target_link_libraries(halide
${HALIDE_LIBRARIES}
${Boost_LIBRARIES}
${BoostNumpy_LIBRARIES}
${PYTHON_LIBRARIES}
)
set_target_properties( halide PROPERTIES PREFIX "")
if(APPLE)
set_target_properties( halide PROPERTIES SUFFIX ".so" )
endif()