Merge remote-tracking branch 'gitlab/master'

This commit is contained in:
Christopher Lackner 2022-09-13 16:16:36 +02:00
commit 4eb380b7ad

View File

@ -5,10 +5,12 @@ endif(NOT CMAKE_BUILD_TYPE)
cmake_minimum_required(VERSION 3.13)
cmake_policy(VERSION 3.13)
include (CMakeDependentOption)
option( USE_NATIVE_ARCH "build for native cpu architecture" ON)
option( USE_GUI "build with GUI" ON )
option( USE_PYTHON "build with python interface" ON )
cmake_dependent_option( PREFER_SYSTEM_PYBIND11 "Use system wide PyBind11" ON "USE_PYTHON" OFF)
option( USE_MPI "enable mpi parallelization" OFF )
option( USE_MPI4PY "enable mpi4py interface" ON )
option( USE_OCC "build with OpenCascade geometry kernel interface" OFF)
@ -302,24 +304,30 @@ else()
endif()
if (USE_PYTHON)
add_subdirectory(external_dependencies/pybind11)
find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h HINTS ${PYTHON_INCLUDE_DIR})
if( PYBIND_INCLUDE_DIR )
message(STATUS "Found Pybind11: ${PYBIND_INCLUDE_DIR}")
else( PYBIND_INCLUDE_DIR )
message(FATAL_ERROR "Could NOT find pybind11!")
endif( PYBIND_INCLUDE_DIR )
if (PREFER_SYSTEM_PYBIND11)
find_package(pybind11 CONFIG)
endif()
if (pybind11_FOUND)
set(NG_INSTALL_PYBIND OFF)
else()
add_subdirectory(external_dependencies/pybind11)
if (pybind11_INCLUDE_DIR)
message(STATUS "Found Pybind11: ${pybind11_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Could NOT find pybind11!")
endif()
endif()
target_include_directories(netgen_python INTERFACE ${PYBIND_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
target_include_directories(nglib PRIVATE ${PYBIND_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
if(NOT ${BUILD_FOR_CONDA} OR WIN32)
# Don't link python libraries in conda environments
target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES})
endif()
if(NG_INSTALL_PYBIND)
install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel)
install(DIRECTORY ${pybind11_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
install(FILES ${pybind11_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel)
endif(NG_INSTALL_PYBIND)
endif (USE_PYTHON)