Skip to content

Cannot find 'pcre.h' when using POCO_UNBUNDLED, a non-system PCRE, and CMake #1581

@ras0219-msft

Description

@ras0219-msft

Related to microsoft/vcpkg#475.

As part of the fix in e863111, a public header dependency was added from Foundation to PCRE. This wasn't reflected in the CMake buildsystem; notably, the JSON component uses RegularExpression from Foundation but does not have ${PCRE_INCLUDE_DIRS} added to its include paths.

On *nix systems where PCRE is available through /usr/include, this will not appear because JSON will implicitly have that directory added to its compile line. However, when using a privately-built version of PCRE, the header will be missing.

In Vcpkg, I've patched this issue via microsoft/vcpkg@1bfd724 [1], but I don't think that's the optimal upstream fix for POCO. Instead, I believe the clear intention (given the style of RegularExpression.h) is to completely hide PCRE as an implementation detail.

Therefore, I believe the best fix would be to completely eliminate all references to the PCRE structs from the header and instead replace the types of _pcre and _extra[2] with void*. In the implementation, these void*s would be cast to the correct PCRE structure when used. This would eliminate the header file dependence on the macro POCO_UNBUNDLED and completely avoid the problem of forward declaring structures from other libraries.

[1]

diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt
index 76005b1..efc99b6 100644
--- a/Foundation/CMakeLists.txt
+++ b/Foundation/CMakeLists.txt
@@ -166,6 +166,7 @@ target_link_libraries( "${LIBNAME}" ${SYSLIBS})
 target_include_directories( "${LIBNAME}"
 	PUBLIC
 		$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+		$<BUILD_INTERFACE:${PCRE_INCLUDE_DIRS}>
 		$<INSTALL_INTERFACE:include>
 	PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
 	)

[2] https://github.com/pocoproject/poco/blob/develop/Foundation/include/Poco/RegularExpression.h#L217-L218

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions