Skip to content

Commit

Permalink
Remove find_package for Pybind11
Browse files Browse the repository at this point in the history
## Context

There is two ways to use the pybind11 package
* To find if the package is already present on the machine via find_package
* To use the package present in the third_party directory

## Issue

With the first option, the version of pybind11 present on the machine might present some problems with N2D2.

## Solution

By imposing the third_party version, we can guarantee a stable version of pybind11.
  • Loading branch information
vtemplier committed Mar 25, 2022
2 parents d8733b4 + 85e8c94 commit 02b6c21
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,17 @@ function(add_n2d2_pybind name source linked_libs)

find_package(Python 3.7 COMPONENTS Interpreter Development)

find_package(pybind11 CONFIG 2.2)
if(NOT pybind11_FOUND)
find_package(pybind11 2.2)
endif()

if(pybind11_FOUND)
message(STATUS "System pybind11 found.")
else()
message(STATUS "Using third_party/pybind11.")
add_subdirectory(${N2D2_SOURCE_DIR}/third_party/pybind11)

if (NOT EXISTS "${N2D2_SOURCE_DIR}/third_party/pybind11/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/pybind11 directory that's needed to "
"build N2D2. If you use git, make sure you have cloned submodules:\n"
" git submodule update --init --recursive\n")
endif()

message(STATUS "Using third_party/pybind11.")
add_subdirectory(${N2D2_SOURCE_DIR}/third_party/pybind11)

if (NOT EXISTS "${N2D2_SOURCE_DIR}/third_party/pybind11/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/pybind11 directory that's needed to "
"build N2D2. If you use git, make sure you have cloned submodules:\n"
" git submodule update --init --recursive\n")
endif()


pybind11_add_module(${name} MODULE ${source})
message(STATUS "pybind11 include dirs: " "${pybind11_INCLUDE_DIRS}")
Expand Down

0 comments on commit 02b6c21

Please sign in to comment.