Skip to content

Error message "Could NOT find PCRE2: missing: 8BIT" in response to find_package(..) #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
idruker-cerence opened this issue Aug 17, 2024 · 3 comments
Labels
question Question from a user
Milestone

Comments

@idruker-cerence
Copy link

Hello

I compile PCRE2 with cmake:

cd pcre2
mkdir build 
cmake -G "Unix Makefiles" -S . -B build
cmake --build build -j 8 --config Release --target install

The build succeeds and along libs produces the files pcre2-config.cmake and pcre2-config-version.cmake in the directory build/cmake.

Next, I want to compile a project that uses PCRE2 as a dependency - let's call it dummy. As per instruction, I set in its CMakeLists.txt

set(PCRE2_USE_STATIC_LIBS ON)
find_package(PCRE2 CONFIG COMPONENTS 8BIT)

and command the build as:

cd dummy
mkdir build
cmake -G "Unix Makefiles" -S . -B build -DCMAKE_PREFIX_PATH=../pcre2/build/cmake

I specified CMAKE_PREFIX_PATH in order that the compiler finds pcre2-config.cmake and indeed the compiler finds it but then produces the following error:

-- Could NOT find PCRE2: missing: 8BIT (found /mnt/c/Home/Workspaces/pcre2/build/cmake/pcre2-config.cmake (found version "10.42.0"))
CMake Warning at CMakeLists.txt:8 (find_package):
  Found package configuration file:

    /mnt/c/Home/Workspaces/pcre2/build/cmake/pcre2-config.cmake

  but it set PCRE2_FOUND to FALSE so package "PCRE2" is considered to be NOT
  FOUND.

It looks as if the required component 8BIT was not defined as the result of PCRE2 compilation. What have I missed?

Thank you

@carenas
Copy link
Contributor

carenas commented Aug 19, 2024

FWIW, can't reproduce this in macOS (using cmake 3.30.2), even with the old PCRE2 10.42 code but it seems broken (if not even more so as it can't find PCRE2_INCLUDE_DIR also in my tests) in Windows.

There are several unresolved issues with cmake (see #115) with some old bugs fixed in newer versions of PCRE2 that might help.

@NWilson NWilson added this to the 10.46 milestone Jan 8, 2025
@NWilson NWilson added the question Question from a user label Jan 8, 2025
@NWilson
Copy link
Member

NWilson commented Mar 31, 2025

@idruker-cerence From your description, it looks like you didn't run cmake --install. If you want to use find_config, you should point it to the installed directory of PCRE (which could be just a local directory, it doesn't have to be in a system-wide location).

If you want to actually load PCRE2 directly from a build/ directory, then you should instead use PCRE2 as a build dependency (where you add the PCRE2 directory using add_subdirectory()).

@NWilson
Copy link
Member

NWilson commented Apr 2, 2025

I have tested this with:

  • The "build interface", that is, using PCRE2 via add_subdirectory(). Tested with both static and dynamic linking, on Windows and Linux.
  • The "install interface", that is, using PCRE2 in an independent project using find_package(PCRE2 CONFIG) to load it using our provided pcre2-config.cmake file. This also supports both static and dynamic - tested these, on Linux & Windows.

I have also checked in these test projects, and have added them to the CI in #739. The CI job is now asserting that downstream projects can load PCRE2 using both the CMake build interface and the install interface. I am doing this testing in CI on both Mac & Windows.

I will consider this issue fixed in the next version of PCRE2 which incorporates this testing.

However, I am grateful to @idruker-cerence for the detailed & helpful feedback. Feel free to re-open or discuss further if you wish to.

@NWilson NWilson closed this as completed Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question from a user
Projects
None yet
Development

No branches or pull requests

3 participants