Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2236

Dependencies aren't loaded when using provided CMake config package

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.3
    • 3.2.4
    • Build
    • None
    • Ubuntu 18.04, CMake 3.22.2

    Description

      We have a CMake config package for our libraries that tries to load Xerces support like so:

      find_package(XercesC PATHS "${OPENDDS_XERCES3}" NO_DEFAULT_PATH)
      if (NOT XercesC_FOUND)
        find_package(XercesC)
      endif()

      Where OPENDDS_XERCES3 is the path to the Xerces our libraries were built with. This works on Windows and Linux when using system-provided package. When building and installing from source on Linux it seem this doesn't work. In this case it's trying to use the CMake package provided by Xerces instead of the one builtin to CMake.

      I've created an example to demonstrate this. Xerces is built and installed to a location on Linux using CMake. Then we create a CMakeLists.txt:

      cmake_minimum_required(VERSION 3.12.0)
      project(xerces_cmake_config_pkg_test)
      find_package(XercesC PATHS "${THE_XERCES_ROOT}" NO_DEFAULT_PATH)
      add_executable(testexe test.cpp)
      target_link_libraries(testexe XercesC::XercesC)
      
      

      test.cpp has to be created, but it doesn't matter what it contains because CMake doesn't get far enough to allow us to attempt to build. When configuring, setting THE_XERCES_ROOT to the installed Xerces, CMake gives these errors:

      CMake Error at CMakeLists.txt:10 (add_executable):
        Target "testexe" links to target "ICU::uc" but the target was not found.
        Perhaps a find_package() call is missing for an IMPORTED target, or an
        ALIAS target is missing?
      CMake Error at CMakeLists.txt:10 (add_executable):
        Target "testexe" links to target "ICU::data" but the target was not found.
        Perhaps a find_package() call is missing for an IMPORTED target, or an
        ALIAS target is missing?
      CMake Error at CMakeLists.txt:10 (add_executable):
        Target "testexe" links to target "Threads::Threads" but the target was not
        found.  Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? 

       

      This seems to be caused by the packages being specified by Xerces during its configure (like ICU) being referenced in the Config package, but not being loaded for the using find_package or equivalent. CMake documenation suggests that this should be done in somewhere in the config file.

       

       

       

       

      Attachments

        1. xercesc-2236-fix.patch
          0.5 kB
          Fred Hornsey

        Activity

          People

            scantor Scott Cantor
            hornsef-oci Fred Hornsey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: