Skip to content
Snippets Groups Projects
Commit c66ca483 authored by Rahil Doshi's avatar Rahil Doshi Committed by Frederik Hennig
Browse files

Swich to fetchContent for pybind11

parent b2a3b880
Branches
No related merge requests found
[submodule "extern/pybind11"]
path = extern/pybind11
url = https://github.com/pybind/pybind11.git
branch = stable
...@@ -345,50 +345,16 @@ endif() ...@@ -345,50 +345,16 @@ endif()
## ##
############################################################################################################################# #############################################################################################################################
if ( WALBERLA_BUILD_WITH_PYTHON ) if ( WALBERLA_BUILD_WITH_PYTHON )
if (NOT DEFINED PYBIND11_MINIMUM_VERSION)
set(PYBIND11_MINIMUM_VERSION "2.6.0")
endif()
execute_process(COMMAND ${Python_EXECUTABLE} -c "import pybind11; print(pybind11._version.__version__)" include(FetchContent)
OUTPUT_VARIABLE pybind11_VERSION ERROR_QUIET RESULT_VARIABLE pybind11_VERSION_RESULT)
string(STRIP "${pybind11_VERSION}" pybind11_VERSION)
if(pybind11_VERSION_RESULT EQUAL "0" AND pybind11_VERSION VERSION_GREATER_EQUAL "${PYBIND11_MINIMUM_VERSION}")
execute_process(COMMAND ${Python_EXECUTABLE} -m pybind11 --cmakedir
OUTPUT_VARIABLE PYBIND11_CMAKE_PATH)
string(STRIP "${PYBIND11_CMAKE_PATH}" PYBIND11_CMAKE_PATH)
find_package(pybind11 PATHS "${PYBIND11_CMAKE_PATH}" NO_DEFAULT_PATH REQUIRED)
else()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
if(WALBERLA_GIT_SUBMODULE_AUTO)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/pybind11/CMakeLists.txt") FetchContent_Declare(
if(EXISTS "${PROJECT_SOURCE_DIR}/.git") pybind11
message(FATAL_ERROR "Please update git submodules or install pybind11 via pip.") GIT_REPOSITORY https://github.com/pybind/pybind11.git
else() GIT_TAG v2.13.6
message(FATAL_ERROR "Please install pybind11 via pip or download it to ${PROJECT_SOURCE_DIR}/extern/pybind11.") )
endif()
endif()
add_subdirectory(extern/pybind11) FetchContent_MakeAvailable(pybind11)
if(pybind11_VERSION VERSION_LESS "2.6.2")
# if pybind11 was installed into ${Python_INCLUDE_DIRS} (e.g. by pip), that will have a higher priority than the Git submodule unless we reorder the search path
# introduced in 2.6.0 (https://github.com/pybind/pybind11/issues/2709), fixed in 2.6.2 (https://github.com/pybind/pybind11/pull/2716)
set_property( TARGET pybind11::pybind11
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_SOURCE_DIR}/extern/pybind11/include" "${Python_INCLUDE_DIRS}")
endif()
endif()
# a python module is a shared library - so everything has to be compiled to position independent code # a python module is a shared library - so everything has to be compiled to position independent code
# otherwise linking the static libs into the shared lib will result in errors # otherwise linking the static libs into the shared lib will result in errors
......
...@@ -74,7 +74,4 @@ set(CMAKE_CXX_FLAGS_DEBUGOPTIMIZED "${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} -O3") ...@@ -74,7 +74,4 @@ set(CMAKE_CXX_FLAGS_DEBUGOPTIMIZED "${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED} -O3")
if(WALBERLA_BUILD_WITH_GPROF) if(WALBERLA_BUILD_WITH_GPROF)
add_flag(CMAKE_CXX_FLAGS "-pg") add_flag(CMAKE_CXX_FLAGS "-pg")
add_flag(CMAKE_EXE_LINKER_FLAGS "-pg") add_flag(CMAKE_EXE_LINKER_FLAGS "-pg")
endif() endif()
\ No newline at end of file
# Intel C++17 support introduced in 2.6.2 (https://github.com/pybind/pybind11/pull/2729)
set(PYBIND11_MINIMUM_VERSION "2.6.2")
\ No newline at end of file
Subproject commit 58c382a8e3d7081364d2f5c62e7f429f0412743b
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment