Hey
This is a little "noobish" question but I have been struggling with it for a while now. I'm trying to add pybind11 to my c++ project but I cant get past through cmake setup.
Here are the steps that I did
Download pybind
Extract it to my externalLib/pybind/pybind11 folder
Add environment path helper to find pybind so its something like ${externalLibs}/pybind/pybind11
and then did this cmake as shown below
SET(PYBIND_LIB ${externalLibs}/pybind/pybind11)
set(pybind11_DIR ${PYBIND_LIB}/tools)
find_package(pybind11 REQUIRED)
And that gives me this error :
`
CMake Error at CMakeLists.txt:65 (find_package):
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "pybind11",
but CMake did not find one.
Could not find a package configuration file provided by "pybind11" with any
of the following names:
pybind11Config.cmake
pybind11-config.cmake
Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
"pybind11_DIR" to a directory containing one of the above files. If
"pybind11" provides a separate development package or SDK, be sure it has
been installed.
`
I even tried this
find_package(pybind11 REQUIRED PATHS "C:/dev/externalLibs/pybind/pybind11/tools")
And he still does not find the stuff?!
What am I doing wrong here?!
I went over the directory again, slower... I found out that the file
pybind11Config.cmake
was in fact named
pybind11Config.cmake.in
so I renamed it, now it goes through but crashes here :
Parse error. Expected a command name, got unquoted argument with text
"@PACKAGE_INIT@".
Call Stack (most recent call first):
CMakeLists.txt:65 (find_package
is ${externalLibs} in your project? you could use add_subdirectory(${externalLibs}/pybind/pybind11) instead of find_package
have you checked out the cmake_example project?
No its in different location.
have you checked out the cmake_example project?
Yeah I did look in to it. But my pybind11 is not inside the project. Its in generic external lib location.
I'm unable to link it/add it or test it when using find_package. Even when he finds it he just throw the error with PACKAGE_INIT listed above.
Regards
Dariusz
pybind11Config.cmake.in is a template file, and is baked into pybind11Config.cmake once you build the pybind project.
$ mkdir build
$ cd build
$ cmake ..
$ make check -j 4
After then you will find pybind11Config.cmake file in build/ directory. The problem is that I don't know what is the right way to make the baked config.cmake available from my project (via find_package) I tried to set pybind11_DIR or add the path to the CMAKE_MODULE_PATH, but it is quite cumbersome.
I'd appreciate if anyone can help us solving it.
Same tour de force here, so here it goes:
Thanks for answering, @kabukunz!
Most helpful comment
Same tour de force here, so here it goes:
pybind11Config.cmake, pybind11Targets.cmake
I've installed mine into my python version of choice in shared/cmake/pybind11 but mind this is very manual and moreover not required