AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.59k stars 643 forks source link

find_packge(OpenVDB) failed after brew install openvdb #412

Closed Danielmelody closed 1 year ago

Danielmelody commented 5 years ago

So I 'm using openvdb as a module of my project. Everything goes fine until I add afind_package(OpenVDB REQUIRED) command in my CMakeLists.txt. The error message is:

CMake Error at xxx/xxx/CMakeLists.txt:8 (find_package):
  By not providing "FindOpenVDB.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenVDB", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenVDB" with any
  of the following names:

    OpenVDBConfig.cmake
    openvdb-config.cmake

  Add the installation prefix of "OpenVDB" to CMAKE_PREFIX_PATH or set
  "OpenVDB_DIR" to a directory containing one of the above files.  If
  "OpenVDB" provides a separate development package or SDK, be sure it has
  been installed.

Other modules, like GLEW can be found as expected after installed by homebrew

danrbailey commented 5 years ago

@Idclip - are you able to shed any light on this question?

Idclip commented 5 years ago

IIRC, homebrew uses the makefile to install OpenVDB v6.0.0 and there's no make or CMake support for actually installing the modules themselves. This has been added in v6.1 but the homebrew formula now needs to be updated. You might be able to point CMAKE_MODULE_PATH to homebrew's Cellar/openvdb directory but I'm unable to test this at the moment and can't remember exactly how homebrew configures its installs. I'll try and verify this soon

Danielmelody commented 5 years ago

I solved this temporally by manually adding

and linking as -lOpenVDB.

Looking forward to the update.

Idclip commented 5 years ago

Glad to hear! I've created a ticket to update homebrew itself here https://jira.aswf.io/browse/OVDB-92

ComFreek commented 4 years ago

I am experiencing the same issue with the MinGW openvdb package. I think this is a problem with the CMake files provided by OpenVDB (i.e. this repo) and not with the packages. Someone in #cmake on Freenode IRC also said:

fwiw conceptually a package shouldn't ever be installing a find module for itself either

So it seems the CMake files provided by this repo are a bit broken.

Idclip commented 4 years ago

Have you tried pointing your project to the location of your OpenVDB install through MinGW by providing the location of the installed find modules with CMAKE_MODULE_PATH?

fwiw conceptually a package shouldn't ever be installing a find module for itself either So it seems the CMake files provided by this repo are a bit broken.

These find modules were written at a time when some of the required dependencies didn't have find modules themselves. Yes, I believe we should now be transitioning to a config module for OpenVDB and deprecating the dependency find modules (FindTBB/FindOpenEXR etctec). This work would massively benefit from external contribution from users who are more familiar with "correct" CMake.

ComFreek commented 4 years ago

Have you tried pointing your project to the location of your OpenVDB install through MinGW by providing the location of the installed find modules with CMAKE_MODULE_PATH?

Yes, that didn't help. CMake searches for the wrong filenames (as per the first post here) since it tries to look for configs, not modules -- if I understand CMake correctly.

This work would massively benefit from external contribution from users who are more familiar with "correct" CMake.

I agree! I know too little CMake to cook up a correct solution, though.

Idclip commented 4 years ago

Yes, that didn't help. CMake searches for the wrong filenames (as per the first post here) since it tries to look for configs, not modules -- if I understand CMake correctly.

Hmm If I'm looking at the MinGW port correctly it should be installing VDB 7.0.0 - the original poster ran into this issue due to brew (at the time) using an older version of VDB (6.0.0). This should work in 7.0.0:

set(CMAKE_MODULE_PATH "C:\path\to\cmake") # Path to the folder containing FindOpenVDB.cmake, located in the cmake folder of the OpenVDB installation
find_package(OpenVDB REQUIRED)

If not I'll try and see if there's an easy patch solution.

I agree! I know to little CMake to cook up a correct solution, though.

No problem, just highlighting for any CMake gurus out there!

ComFreek commented 4 years ago

Your proposal at least let me compile my files. However, at link time it complained about undefined references to Boost even though I link to it. I am using Boost in the project I am compiling myself. Does OpenVDB also use Boost? Somehow those undefined references sound like incompatible Boost versions.

But I don't have my hands anymore on that particular kind of build setup. Actually, that was only a PR to add Windows support to some OSS, which worked good enough with manual inclusion/linking. So somebody else would need to try and see if your proposal works.

j20232 commented 4 years ago

I have also the same problem.

Environment

CMakeLists.txt

find_package(OpenVDB CONFIG REQUIRED)

Error

CMake Error at CMakeLists.txt:36 (find_package):
  Could not find a package configuration file provided by "OpenVDB" with any
  of the following names:

    OpenVDBConfig.cmake
    openvdb-config.cmake

  Add the installation prefix of "OpenVDB" to CMAKE_PREFIX_PATH or set
  "OpenVDB_DIR" to a directory containing one of the above files.  If
  "OpenVDB" provides a separate development package or SDK, be sure it has
  been installed.

There are no config files at /usr/local/lib/cmake related to openvdb as follows.

@ /usr/local/lib/cmake/OpenVDB

If you have the newer solution, could you tell me it?

DragonLiu1 commented 4 years ago

Can anyone post a CMakeLists.txt to run OpenVDB samples

j20232 commented 4 years ago

@DragonLiu1 Hi, I created tiny demo https://github.com/j20232/vdb_sample

# tbb
find_library(TBB_LIBRARY tbb HINTS /usr/local/lib)

# openexr
find_library(HALF_LIB half HINTS /usr/local/lib)

# openvdb
list(APPEND SAMPLE_INCLUDE_DIR /usr/local/include)
find_library(OpenVDB_LIBRARY openvdb HINTS /usr/local/lib)

## include headers
include_directories(${SAMPLE_INCLUDE_DIR})
add_executable(sample ${SAMPLE_SOURCES})
target_link_libraries(
    sample
    ${TBB_LIBRARY}
    ${HALF_LIB}
    ${OpenVDB_LIBRARY}
)

You need to load tbb and openexr in my example. There may be other solution to use CMakeLists.txt, so please share us if you know other samples.

DragonLiu1 commented 3 years ago

Thank you for your kind reply, and the path of HALF_LIB is "/usr/lib/x86_64-linux-gnu" in my computer, however, it doesn't work when I add this path to CMakeLists.txt. Fortunately it works when I manually add the path in CMake GUI, which really confused me.

CMakeLists.txt

cmake_minimum_required(VERSION 3.10) project(view) set(CMAKE_MODULE_PATH "/usr/local/lib/cmake/OpenVDB") find_library(OpenVDB_LIBRARY openvdb HINTS /usr/local/lib) find_library(HALF_LIB half  HINTS "/usr/lib/x86_64-linux-gnu") find_library(TBB_LIBRARY tbb HINTS /usr/local/lib) add_executable(view view.cpp) target_link_libraries(view ${TBB_LIBRARY}     ${HALF_LIB}     ${OpenVDB_LIBRARY} )

------------------ 原始邮件 ------------------ 发件人: "mocobt"<notifications@github.com>; 发送时间: 2020年9月2日(星期三) 凌晨1:10 收件人: "AcademySoftwareFoundation/openvdb"<openvdb@noreply.github.com>; 抄送: "刘龙"<771686615@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [AcademySoftwareFoundation/openvdb] find_packge(OpenVDB) failed after brew install openvdb (#412)

@DragonLiu1 Hi, I created tiny demo https://github.com/j20232/vdb_sample

tbb find_library(TBB_LIBRARY tbb HINTS /usr/local/lib) # openexr find_library(HALF_LIB half HINTS /usr/local/lib) # openvdb list(APPEND SAMPLE_INCLUDE_DIR /usr/local/include) find_library(OpenVDB_LIBRARY openvdb HINTS /usr/local/lib) ## include headers include_directories(${SAMPLE_INCLUDE_DIR}) add_executable(sample ${SAMPLE_SOURCES}) target_link_libraries( sample ${TBB_LIBRARY} ${HALF_LIB} ${OpenVDB_LIBRARY} )

You need to load tbb and openexr in my example. There may be other solution to use CMakeLists.txt, so please share us if you know other samples.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

SallySoul commented 3 years ago

I am not the cmake expert needed here. However, I might have a useful connection to offer.

We had to use the above workaround on linux / macos to integrate openvdb. However on windows we use vcpkg to take care of our dependencies management, and that project has patched things to vendor the correct cmake files.

https://github.com/microsoft/vcpkg/blame/master/ports/openvdb/portfile.cmake

I think this may have been the PR that fixed the issue in question, hard to say for sure though.

https://github.com/microsoft/vcpkg/pull/14651

Idclip commented 1 year ago

Closing this issue as a duplicate of #1160 - basically we need to start shipping proper Config files. Going to use 1160 to track this