about summary refs log tree commit diff
path: root/third_party/immer/extra/python/CMakeLists.txt
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-07-15T07·20+0100
committerVincent Ambo <mail@tazj.in>2020-07-15T07·23+0100
commit1213b086a1015a662ab7ebd658f784534fd3116a (patch)
treed3bc8f3b7f40b8b60f0ef6fbd649cf765f4fdfb6 /third_party/immer/extra/python/CMakeLists.txt
parent1390827b9ea1e04bc9863e48930bfd16db3b716e (diff)
parent7f19d641647ac4ef313ed88d6b5c140983ce5436 (diff)
merge(3p/immer): Subtree merge at 'ad3e3556d' as 'third_party/immer' r/1299
Change-Id: I9636a41ad44b4218293833fd3e9456d9b07c731b
Diffstat (limited to 'third_party/immer/extra/python/CMakeLists.txt')
-rw-r--r--third_party/immer/extra/python/CMakeLists.txt46
1 files changed, 46 insertions, 0 deletions
diff --git a/third_party/immer/extra/python/CMakeLists.txt b/third_party/immer/extra/python/CMakeLists.txt
new file mode 100644
index 000000000000..11d5fff209ad
--- /dev/null
+++ b/third_party/immer/extra/python/CMakeLists.txt
@@ -0,0 +1,46 @@
+
+option(USE_PYBIND "bind with pybind1" off)
+option(USE_BOOST_PYTHON  "bind with boost::python" off)
+
+if (USE_PYBIND)
+  set(PYBIND11_CPP_STANDARD -std=c++14)
+  find_package(Boost 1.56 REQUIRED)
+  add_subdirectory(lib/pybind11)
+  pybind11_add_module(immer_python_module src/immer-pybind.cpp)
+  target_link_libraries(immer_python_module PUBLIC
+    immer)
+
+elseif(USE_BOOST_PYTHON)
+  find_package(PythonInterp)
+  find_package(PythonLibs)
+  find_package(Boost 1.56 COMPONENTS python)
+  python_add_module(immer_python_module src/immer-boost.cpp)
+  include_directories(immer_python_module PUBLIC
+    ${immer_include_dir}
+    ${Boost_INCLUDE_DIRS}
+    ${PYTHON_INCLUDE_DIRS})
+  target_link_libraries(immer_python_module PUBLIC
+    immer
+    ${Boost_LIBRARIES}
+    ${PYTHON_LIBRARIES})
+
+else()
+  find_package(PythonInterp)
+  find_package(PythonLibs)
+
+  if (NOT PYTHONLIBS_FOUND)
+    message(STATUS "Disabling Python modules")
+    return()
+  endif()
+
+  python_add_module(immer_python_module EXCLUDE_FROM_ALL
+    src/immer-raw.cpp)
+  target_include_directories(immer_python_module PUBLIC
+    ${PYTHON_INCLUDE_DIRS})
+  target_link_libraries(immer_python_module PUBLIC
+    immer
+    ${PYTHON_LIBRARIES})
+
+endif()
+
+add_custom_target(python DEPENDS immer_python_module)