Skip to content

Poco can be built with ENABLE_UTIL=ON and ENABLE_XML=OFF, but use of Poco::Util requires Poco::XML #3815

@insi-eb

Description

@insi-eb

Describe the bug

It is possible (and, based on https://github.com/pocoproject/poco/blob/devel/Util/CMakeLists.txt#L34, also intended) to build Poco with ENABLE_UTIL=ON and ENABLE_XML=OFF, but a corresponding find_package on Poco with just Util fails due to the missing PocoXml configuration:

find_package(Poco CONFIG REQUIRED COMPONENTS Foundation Util)

reports

  Could not find a package configuration file provided by "PocoXML" with any
  of the following names:

    PocoXMLConfig.cmake
    pocoxml-config.cmake

  Add the installation prefix of "PocoXML" to CMAKE_PREFIX_PATH or set
  "PocoXML_DIR" to a directory containing one of the above files.  If
  "PocoXML" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  install/lib64/cmake/Poco/PocoUtilConfig.cmake:3 (find_dependency)
  install/lib64/cmake/Poco/PocoConfig.cmake:29 (find_package)

as find_dependency(PocoXML) is hardcoded at
https://github.com/pocoproject/poco/blob/devel/Util/cmake/PocoUtilConfig.cmake#L3

To Reproduce

build Poco with ENABLE_UTIL=ON and ENABLE_XML=OFF and do a find_package on Poco with Util, but without Xml

Expected behavior

CMake config file differentiates which Poco build options were enabled (or different config files are installed, depending on the build options), so that using Poco::Util without Poco::XML is possible

Logs
n/a

Screenshots
n/a

Please add relevant environment information:

  • OS Type and Version: Linux w/ 5.14 kernel, clang-14.0.6 w/ libstdc++-11
  • POCO Version: 1.12.1
  • Third-party product (eg. database or library) type and version: n/a

Additional context

the following patch fixes this issue as the PocoUtilConfig.cmake is already passed through CMake's configure_file()

diff -r -u a/Util/cmake/PocoUtilConfig.cmake b/Util/cmake/PocoUtilConfig.cmake
--- a/Util/cmake/PocoUtilConfig.cmake	2022-09-28 14:14:34.948543187 +0200
+++ b/Util/cmake/PocoUtilConfig.cmake	2022-09-29 12:26:29.948532946 +0200
@@ -1,5 +1,9 @@
 include(CMakeFindDependencyMacro)
 find_dependency(PocoFoundation)
-find_dependency(PocoXML)
-find_dependency(PocoJSON)
+if(@ENABLE_XML@)
+    find_dependency(PocoXML)
+endif(@ENABLE_XML@)
+if(@ENABLE_JSON@)
+    find_dependency(PocoJSON)
+endif(@ENABLE_JSON@)
 include("${CMAKE_CURRENT_LIST_DIR}/PocoUtilTargets.cmake")

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions