Skip to content

CMake dependencies _FOUND tests are wrong. CMake variables are case sensitive #824

@HekyM

Description

@HekyM

Hi,

You are using CMake find_package(<PackageName> ...) to find dependencies. Based on documentation https://cmake.org/cmake/help/latest/command/find_package.html#basic-signature this call will define <PackageName>_FOUND variable.

find_package(BZip2)
find_package(ZLIB)
find_package(Readline)
find_package(Editline)

But later in pcre2 CMakeLists.txt, these are used as <PACKAGENAME>_FOUND (uppercase). CMake variables are case sensitive.

So for example find_package(BZip2) will define BZip2_FOUND, not BZIP2_FOUND as You use for example here https://github.com/PCRE2Project/pcre2/blob/master/CMakeLists.txt#L501C6-L501C17. So it will raise a FATAL_ERROR.

if(PCRE2_SUPPORT_LIBBZ2)
  if(BZIP2_FOUND)
    include_directories(${BZIP2_INCLUDE_DIR})
  else()
    message(
      FATAL_ERROR
      " libbz2 not found. Set BZIP2_INCLUDE_DIR to a compatible header\n"
      " or set BZip2_ROOT to a full bzip2 installed tree, as needed."
    )
  endif()
endif()

Here is how CMake builtin finder for BZip2 works https://cmake.org/cmake/help/latest/module/FindBZip2.html#result-variables

Metadata

Metadata

Assignees

No one assigned

    Labels

    untidinessNot exactly a bug, but could do better

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions