The package pcre2 is compatible with built-in CMake targets: # Each component imports a target: # TARGETS: PCRE2::8BIT PCRE2::16BIT PCRE2::32BIT PCRE2::POSIX find_package(pcre2 CONFIG REQUIRED) target_link_libraries(main PRIVATE PCRE2::8BIT PCRE2::16BIT PCRE2::32BIT PCRE2::POSIX)