From 2610d628131cbbbb8471ebc0429f4885c601b42f Mon Sep 17 00:00:00 2001 From: Simon Layton Date: Tue, 6 Dec 2016 13:06:16 -0500 Subject: [PATCH] Build Python libs --- caffe2/CMakeLists.txt | 3 +++ caffe2/python/CMakeLists.txt | 15 +++++++++++++++ cmake/Dependencies.cmake | 11 +++++++++++ 3 files changed, 29 insertions(+) create mode 100644 caffe2/python/CMakeLists.txt diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index 1a4140ea8286..04fbfc0476fd 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -94,3 +94,6 @@ add_executable(Caffe2_CPU_TEST ${Caffe2_CPU_TEST_SRCS}) target_link_libraries(Caffe2_CPU_TEST Caffe2_CPU gtest glog atlas cblas) target_compile_features(Caffe2_CPU_TEST PRIVATE cxx_range_for) + +# ---[ Python +add_subdirectory(python) diff --git a/caffe2/python/CMakeLists.txt b/caffe2/python/CMakeLists.txt new file mode 100644 index 000000000000..966fc3279e18 --- /dev/null +++ b/caffe2/python/CMakeLists.txt @@ -0,0 +1,15 @@ +set(Caffe2_PYTHON_CPU_SRC + "/pybind_state.cc" +) +set(Caffe2_PYTHON_GPU_SRC + "/pybind_state.cc" + "/pybind_state_gpu.cc" +) + +prepend(Caffe2_PYTHON_CPU_SRC ${CMAKE_CURRENT_SOURCE_DIR} ${Caffe2_PYTHON_CPU_SRC}) +prepend(Caffe2_PYTHON_GPU_SRC ${CMAKE_CURRENT_SOURCE_DIR} ${Caffe2_PYTHON_GPU_SRC}) + +add_library(Caffe2_PYTHON_CPU SHARED ${Caffe2_PYTHON_CPU_SRC}) +# target_link_libraries(Caffe2_PYTHON_CPU) + +add_library(Caffe2_PYTHON_GPU_SHARED SHARED ${Caffe2_PYTHON_GPU_SRC}) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 49e170a05438..3ef061a37d02 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -80,3 +80,14 @@ endif() # ---[ EIGEN include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/eigen) + +# ---[ pybind11 +include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/pybind11/include) + +# ---[ Python + Numpy +find_package(PythonInterp 2.7) +find_package(PythonLibs 2.7) +find_package(NumPy REQUIRED) + +include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS}) +list(APPEND Caffe2_LINKER_LIBS ${PYTHON_LIBRARIES})