]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Add a component DEAL_II_COMPONENT_PYTHON_BINDINGS
authorMatthias Maier <tamiko@43-1.org>
Fri, 22 Jul 2016 19:13:29 +0000 (14:13 -0500)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 3 Aug 2016 20:34:02 +0000 (16:34 -0400)
cmake/modules/FindBOOST.cmake
cmake/setup_cached_variables.cmake
contrib/python-bindings/CMakeLists.txt [new file with mode: 0644]

index 83b6f8c221105902354f577eaaef755696d9b80f..b8a08bf3b3f7bf39bfa5a71e8b75c287e7ac7b32 100644 (file)
@@ -43,7 +43,13 @@ ENDIF()
 
 # temporarily disable ${CMAKE_SOURCE_DIR}/cmake/modules for module lookup
 LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
-FIND_PACKAGE(Boost 1.54 COMPONENTS iostreams serialization system thread)
+SET(_boost_python "")
+IF(DEAL_II_COMPONENT_PYTHON_BINDINGS)
+  SET(_boost_python "python")
+ENDIF()
+FIND_PACKAGE(Boost 1.54 COMPONENTS
+  iostreams serialization system thread ${_boost_python}
+  )
 LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
 
 #
index 3bbd7c1e0bb67aab56339a52aa02aef9ca2b2738..94ea7a0a9b76b338c459bf3684c7dffcea3e813b 100644 (file)
@@ -25,6 +25,7 @@
 #     DEAL_II_COMPONENT_DOCUMENTATION
 #     DEAL_II_COMPONENT_EXAMPLES
 #     DEAL_II_COMPONENT_PACKAGE
+#     DEAL_II_COMPONENT_PYTHON_BINDINGS
 #     DEAL_II_FORCE_AUTODETECTION
 #
 # Options regarding compilation and linking:
@@ -91,6 +92,12 @@ OPTION(DEAL_II_COMPONENT_PACKAGE
   )
 LIST(APPEND DEAL_II_COMPONENTS PACKAGE)
 
+OPTION(DEAL_II_COMPONENT_PYTHON_BINDINGS
+  "Enable configuration and installation of the python bindings. This adds a COMPONENT \"PYTHON_BINDINGS\" to the build system."
+  OFF
+  )
+LIST(APPEND DEAL_II_COMPONENTS PYTHON_BINDINGS)
+
 OPTION(DEAL_II_ALLOW_AUTODETECTION
   "Allow to automatically set up features by setting all undefined DEAL_II_WITH_* variables to ON or OFF"
   ON
diff --git a/contrib/python-bindings/CMakeLists.txt b/contrib/python-bindings/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b490eee
--- /dev/null
@@ -0,0 +1,74 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2016 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+FIND_LIBRARY(Boost_PYTHON_LIBRARY boost_python PATH ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH)
+INCLUDE(FindPythonLibs)
+INCLUDE(FindPythonInterp)
+INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(
+  ${CMAKE_BINARY_DIR}/include/
+  ${CMAKE_SOURCE_DIR}/include/
+  ${DEAL_II_BUNDLED_INCLUDE_DIRS}
+  ${DEAL_II_INCLUDE_DIRS}
+  ${CMAKE_SOURCE_DIR}/contrib/python-bindings/include/
+  )
+INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
+
+SET(_src
+  wrappers.cc
+  export_cell_accessor.cc
+  export_point.cc
+  export_triangulation.cc
+  cell_accessor_wrapper.cc
+  point_wrapper.cc
+  triangulation_wrapper.cc
+  )
+
+PYTHON_ADD_MODULE(PyDealII ${_src})
+
+SET(PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
+
+TARGET_LINK_LIBRARIES(PyDealII deal_II.g)
+TARGET_LINK_LIBRARIES(PyDealII ${Boost_PYTHON_LIBRARY})
+TARGET_LINK_LIBRARIES(PyDealII ${PYTHON_LIBRARIES})
+
+SET_TARGET_PROPERTIES(PyDealII PROPERTIES
+  CXX_STANDARD 11
+  )
+
+INSTALL(TARGETS PyDealII DESTINATION ${PYTHON_INSTALL_PREFIX}/pydealii)
+
+SET(PYTHON_SOURCES
+  __init__.py
+  )                                                                                                                                                                                                               
+
+FOREACH(PYTHON_SOURCE ${PYTHON_SOURCES})                                                                                                                                                                            
+  ADD_CUSTOM_COMMAND(                                                                                                                                                                                             
+    OUTPUT ${CMAKE_BINARY_DIR}/python/pydealii/${PYTHON_SOURCE}                                                                                                                                                    
+    DEPENDS ${CMAKE_SOURCE_DIR}/contrib/python-bindings/source/${PYTHON_SOURCE}
+    COMMAND ${CMAKE_COMMAND}                                                                                                                                                                                    
+    ARGS -E copy ${CMAKE_SOURCE_DIR}/contrib/python-bindings/source/${PYTHON_SOURCE} ${CMAKE_BINARY_DIR}/python/pydealii/${PYTHON_SOURCE}
+    COMMENT "Copying ${PYTHON_SOURCE}"                                                                                                                                                                          
+    )                                                                                                                                                                                                           
+  ADD_CUSTOM_TARGET(                                                                                                                                                                                              
+    ${PYTHON_SOURCE} ALL
+    DEPENDS ${CMAKE_BINARY_DIR}/python/pydealii/${PYTHON_SOURCE}                                                                                                                                                   
+    )                                                                                                                                                                                                           
+ENDFOREACH()                                                                                                                                                                                                        
+INSTALL(                                                                                                                                                                                                            
+  DIRECTORY ${CMAKE_BINARY_DIR}/python/pydealii
+  DESTINATION ${PYTHON_INSTALL_PREFIX}                                                                                                                                                                            
+  FILES_MATCHING PATTERN "*.py"                                                                                                                                                                                   
+  ) 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.