Skip to content

Conversation

@jasjuang
Copy link
Contributor

@jasjuang jasjuang commented Nov 5, 2019

Without this PR, when the downstream CMakeLists uses find_package(tinyobjloader REQUIRED), there will be the below error:

CMake Error at modules/Mesh/CMakeLists.txt:68 (find_package):
  By not providing "Findtinyobjloader.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "tinyobjloader", but CMake did not find one.

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

    tinyobjloaderConfig.cmake
    tinyobjloader-config.cmake

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

The reason is the tinyobjloader config file path /usr/lib/x86_64-linux-gnu/tinyobjloader/cmake/tinyobjloader_double-config.cmake does not conform to one of the cmake default path in module mode, after this change it will be back to /usr/lib/x86_64-linux-gnu/tinyobjloader/cmake/tinyobjloader-config.cmake, which is one of the cmake default path in module mode, so the downstream CMakeLists can use find_package(tinyobjloader REQUIRED) and target_link_libraries(${PROJECT_NAME} tinyobjloader::tinyobjloader_double) like usual.

@syoyo syoyo merged commit 7485407 into tinyobjloader:master Nov 6, 2019
@syoyo
Copy link
Collaborator

syoyo commented Nov 6, 2019

Awesome!

But if you want to use tinyobjloader as a submodule or subdirectory, I do not recommend to use add_subdirectory. You can simply copy a header file to your app, or add include path to tinyobjloader repo.

syoyo added a commit that referenced this pull request Nov 10, 2025
fix cmake downstream find_package failure in double mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants