Skip to content

Commit 242ee25

Browse files
committed
wip
1 parent 1082b9f commit 242ee25

48 files changed

Lines changed: 18 additions & 5296 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ endif(enable-fortran-bindings)
3636

3737
#python bindings
3838
option(enable-python-bindings "enable python bindings support" OFF)
39-
option(enable-broken-boost-python-module-visibility-handling
40-
"workaround a bug in boost python which occurs on FreeBSD+clang. See https://github.com/boostorg/python/issues/173 for details" OFF)
39+
option(enable-pybind11 "using pybind11 to make the python bindings (otherwise, boost/python is used)" OFF)
40+
41+
if(enable-pybind11)
42+
if(NOT enable-python-bindings)
43+
message(FATAL_ERROR "the option enable-pybind11 is only meaningful if the python bindings are enabled")
44+
endif(NOT enable-python-bindings)
45+
endif(enable-pybind11)
4146

4247
if(enable-python-bindings)
4348
find_package(Python REQUIRED COMPONENTS Interpreter Development NumPy)
@@ -55,86 +60,12 @@ if(enable-python-bindings)
5560
if(NOT HAVE_PYTHON)
5661
message(FATAL_ERROR "python not found. python is mandatory for python bindings.")
5762
endif(NOT HAVE_PYTHON)
58-
# numpy detection
59-
execute_process(
60-
COMMAND "${PYTHON_EXECUTABLE}" -c
61-
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
62-
OUTPUT_VARIABLE NUMPY_INCLUDE_PATH)
63-
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
64-
HINTS "${NUMPY_INCLUDE_PATH}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH)
65-
if(NOT PYTHON_NUMPY_INCLUDE_DIR)
66-
message(FATAL_ERROR "numpy not found. numpy is mandatory for python bindings.")
67-
endif(NOT PYTHON_NUMPY_INCLUDE_DIR)
68-
# boost python detection
69-
message(STATUS "Trying to find libboost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
70-
# Fix a bug in FindBoost 1.70
71-
# https://github.com/boostorg/boost_install/issues/5
72-
if(NOT DEFINED BUILD_SHARED_LIBS)
73-
set(MGIS_TMP_BUILD_SHARED_LIBS ON)
74-
set(BUILD_SHARED_LIBS ON)
75-
endif(NOT DEFINED BUILD_SHARED_LIBS)
76-
find_package(Boost 1.36.0 COMPONENTS
77-
"python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
78-
if(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
79-
set(Boost_PYTHON_FOUND ON)
80-
set(Boost_PYTHON_LIBRARY "${Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_LIBRARY}")
81-
else(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
82-
set(Boost_PYTHON_FOUND OFF)
83-
endif(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
84-
if(NOT Boost_PYTHON_FOUND)
85-
message(STATUS "Trying to find libboost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
86-
find_package(Boost 1.36.0 COMPONENTS
87-
"python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
88-
if(Boost_PYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
89-
set(Boost_PYTHON_FOUND ON)
90-
set(Boost_PYTHON_LIBRARY "${Boost_PYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_LIBRARY}")
91-
else(Boost_PYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
92-
set(Boost_PYTHON_FOUND OFF)
93-
endif(Boost_PYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND)
94-
endif(NOT Boost_PYTHON_FOUND)
95-
if(NOT Boost_PYTHON_FOUND)
96-
message(STATUS "Trying to find libboost_python-py${PYTHON_VERSION_MAJOR}")
97-
find_package(Boost 1.36.0 COMPONENTS
98-
"python-py${PYTHON_VERSION_MAJOR}")
99-
if(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}_FOUND)
100-
set(Boost_PYTHON_FOUND ON)
101-
set(Boost_PYTHON_LIBRARY "${Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}_LIBRARY}")
102-
else(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}_FOUND)
103-
set(Boost_PYTHON_FOUND OFF)
104-
endif(Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}_FOUND)
105-
endif(NOT Boost_PYTHON_FOUND)
106-
if(NOT Boost_PYTHON_FOUND)
107-
message(STATUS "Trying to find libboost_python${PYTHON_VERSION_MAJOR}")
108-
find_package(Boost 1.36.0 COMPONENTS
109-
"python${PYTHON_VERSION_MAJOR}")
110-
if(Boost_PYTHON${PYTHON_VERSION_MAJOR}_FOUND)
111-
set(Boost_PYTHON_FOUND ON)
112-
set(Boost_PYTHON_LIBRARY "${Boost_PYTHON${PYTHON_VERSION_MAJOR}_LIBRARY}")
113-
else(Boost_PYTHON${PYTHON_VERSION_MAJOR}_FOUND)
114-
set(Boost_PYTHON_FOUND OFF)
115-
endif(Boost_PYTHON${PYTHON_VERSION_MAJOR}_FOUND)
116-
endif(NOT Boost_PYTHON_FOUND)
117-
if(NOT Boost_PYTHON_FOUND)
118-
message(STATUS "Trying to find libboost_python")
119-
find_package(Boost 1.36.0 COMPONENTS python)
120-
endif(NOT Boost_PYTHON_FOUND)
121-
if(Boost_PYTHON_FOUND)
122-
message(STATUS "Boost library python found (${Boost_PYTHON_LIBRARY}).")
123-
else(Boost_PYTHON_FOUND)
124-
message(FATAL_ERROR "Boost python libraries not found.\n"
125-
"Required packages are :" ${BOOST_MANDATORY_COMPONENTS})
126-
endif(Boost_PYTHON_FOUND)
127-
if(DEFINED MGIS_TMP_BUILD_SHARED_LIBS)
128-
set(BUILD_SHARED_LIBS ${MGIS_TMP_BUILD_SHARED_LIBS})
129-
unset(MGIS_TMP_BUILD_SHARED_LIBS)
130-
endif(DEFINED MGIS_TMP_BUILD_SHARED_LIBS)
131-
list(APPEND CPACK_COMPONENTS_ALL python_bindings)
132-
set(CPACK_COMPONENT_PYTHON_BINDINGS_DESCRIPTION
133-
"Contains the python bindings for TFEL, MFront and MTest")
134-
set(CPACK_COMPONENT_PYTHON_BINDINGS_DEPENDS core mfront mtest)
135-
if(enable-broken-boost-python-module-visibility-handling)
136-
add_definitions("-DMGIS_BOOST_PYTHON_USE_GCC_SYMBOL_VISIBILITY")
137-
endif(enable-broken-boost-python-module-visibility-handling)
63+
if(enable-pybind11)
64+
find_package(pybind11 CONFIG REQUIRED)
65+
else(enable-pybind11)
66+
include(cmake/modules/boost-python.cmake)
67+
detect_boost_python()
68+
endif(enable-pybind11)
13869
endif(enable-python-bindings)
13970

14071
# fenics-bindings (placed before compiler detection)

bindings/python/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ else(MGIS_APPEND_SUFFIX)
1717
endif(WIN32)
1818
endif(MGIS_APPEND_SUFFIX)
1919

20-
add_subdirectory(src)
21-
add_subdirectory(mgis)
22-
if(MGIS_HAVE_TFEL)
23-
add_subdirectory(tests)
24-
endif(MGIS_HAVE_TFEL)
20+
if(enable-pybind11)
21+
add_subdirectory(pybind11)
22+
else(enable-pybind11)
23+
add_subdirectory(boost)
24+
endif(enable-pybind11)

bindings/python/include/MGIS/Python/NumPySupport.hxx

Lines changed: 0 additions & 118 deletions
This file was deleted.

bindings/python/include/MGIS/Python/PairConverter.hxx

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)