Skip to content

Case insensitive targets

The upcoming Qt6 wants to have its 3rd party dependencies found by find_package.

Some of the dependencies are:

  • zlib
  • png
  • freetype

CMake has find modules for them, which means that if you want to have the Linux system installed version you need to call:

find_package(ZLIB)
find_package(PNG)
find_package(Freetype)

vcpkg actually respects the CMake find modules naming. Hunter does it for zlib and png. Conan prefers all lowercase.

With !3339 (merged) merged now one can do the following:

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
find_package(ZLIB NAMES zlib Zlib)
find_package(PNG NAMES png Png)
find_package(Freetype NAMES freetype FreeType)

The find config package will be found, but now the problem is with the targets they export.

CMake defines them as:

  • ZLIB::ZLIB
  • PNG::PNG
  • Freetype::Freetype

Only vcpkg respects this. Hunter has ZLIB::zlib, PNG::png, freeType::freetype. Conan has ZLIB::ZLIB, no PNG::PNG target, and no Freetype package.

A setting similar to CMAKE_FIND_PACKAGE_PREFER_CONFIG let's say CMAKE_CASE_INSENSITIVE_TARGETS would fix all these issues.

When CMAKE_CASE_INSENSITIVE_TARGETS is set to ON, CMake could display a warning mentioning the mismatch.

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