Skip to content

FindFreetype: Imported target name versus upstream CMake package

There doesn't seem to be an easy way for projects to add namespaced targets in a backwards compatible way to their <project>-config.cmake file.

I noticed that the FreeType project's freetype-config.cmakefile provides the target "freetype" while CMake's FindFreetype.cmake module provides "Freetype::Freetype" which means the MODULE and CONFIG modes of find_package(freetype) will provide different targets, which is not ideal. I therefore opened freetype #1165 asking for their freetype-config.cmake to provide "Freetype::Freetype" for compatibility. They have in return asked for a pull request, but there doesn't seem to be an easy way to extend the install(EXPORT ...) statement they are using in freetype/CMakeLists.txt:624 to provide both the freetype IMPORTED target for compatibility with existing CONFIG mode users and Freetype::Freetype?

I have seen several other cases where the CONFIG modules provided different targets than those provided by the CMake Find.cmake modules and typically the CONFIG modules, which I expect are the desired future approach, use unnamespaced targets where I also understand that namespaces are actually preferred for IMPORTED targets. I therefore think it would be great for CMake to provide a good path for projects to add namespaced targets while preserving existing targets for backwards compatibility. Preferably without having to hand-generate the -config.cmake file.

If this is already possible/easy then I apologize and hope this issue can then at least serve to lead other developers with the same problem in the right direction.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information