Skip to content

adding CMake find_package() support to installed DiligentEngine #352

@fdarling

Description

@fdarling

I notice that if you can use CMake to build and then "install" DiligentEngine to an installation prefix, but the files it copies do not include any .cmake scripts suitable for having CMake's find_package() find DiligentEngine in a third party CMake project (such as a game project).

Typically files would be placed in subdirectory of the installation prefix such as lib/cmake/DiligentCore/, though there are alternative locations that CMake will search:

https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure

The type of .cmake file(s) that are expected to be in that folder would be of the form DiligentCore-config.cmake:

https://cmake.org/cmake/help/latest/command/find_package.html#config-mode

You could either have the different components be top-level libraries, or be modules to a common library/namespace. For example:

find_package(DiligentEngine REQUIRED Core FX)
# ...
target_link_libraries(myApp PRIVATE
   DiligentEngine::Core
   DiligentEngine::FX
)

Rather than:

find_package(DiligentCore)
find_package(DiligentFX)
# ...
target_link_libraries(myApp PRIVATE
   DiligentCore
   DiligentFX
)

I see that currently you support having people pull in DiligentEngine by using add_subdirectory() on something like DiligentCore (possibly a submodule folder) and then linking with things like Diligent-GraphicsEngineOpenGL-shared. What I am hoping for is find_package(DiligentCore) or find_package(Diligent::Core) and then linking similarly to before (though ideally with namespaces / components).

CMake also has a feature where by simply linking with a library, you pull in the include paths that library advertises with "INTERFACE_INCLUDE_DIRECTORIES". I don't fully know how to write CMake files to set this up, but I have used libraries that have done so!

Let me know if this makes sense, and if so, I am willing to help make it happen! I know CMake pretty well, and I have friends that know more than me 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions