[package] xerces-c/3.2: CMakeDeps generation Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR XercesC_VERSION)
Description
I'm tring to use xerces-c with with Conan 2.0 within CMake using conan-io/cmake-conan (https://github.com/conan-io/cmake-conan/tree/develop2).
This is working for a bunch of other libraries, but when I try to use xerces-c, I get:
Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR XercesC_VERSION)
Looking at the generated CMake files, it looks like there is a mismatch where the pkg-config-name is being used instead of the cmake-target-name for the variables:
$ grep -irn -E 'xerces.*_LIBRARY'
XercesC-debug-x86_64-data.cmake:24:set(xerces-c_LIBRARY_TYPE_DEBUG STATIC)
XercesC-Target-debug.cmake:27: "${xerces-c_LIBRARY_TYPE_DEBUG}"
module-XercesC-debug-x86_64-data.cmake:24:set(xerces-c_LIBRARY_TYPE_DEBUG STATIC)
module-XercesC-Target-debug.cmake:27: "${xerces-c_LIBRARY_TYPE_DEBUG}"
CMakeCache.txt:222:XercesC_LIBRARY_DEBUG:FILEPATH=XercesC_LIBRARY_DEBUG-NOTFOUND
CMakeCache.txt:225:XercesC_LIBRARY_RELEASE:FILEPATH=XercesC_LIBRARY_RELEASE-NOTFOUND
CMakeCache.txt:388://ADVANCED property for variable: XercesC_LIBRARY_DEBUG
CMakeCache.txt:389:XercesC_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
CMakeCache.txt:390://ADVANCED property for variable: XercesC_LIBRARY_RELEASE
CMakeCache.txt:391:XercesC_LIBRARY_RELEASE-ADVANCED:INTERNAL=1
Package and Environment Details
- Package Name/Version: xerces-c/3.2.4
- Operating System+version: Red Hat Enterprise Linux 8
- Compiler+version: GCC 8
- Conan version: conan 2.0.2
- Python version: Python 3.8.12
Conan profile
[settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=8 os=Linux
Steps to reproduce
This is easily reproducible using the following:
$ mkdir tmp
$ cd tmp
$ conan install -r conancenter --requires xerces-c/3.2.4 -g CMakeDeps
Then create a CMakeLists.txt like this:
cmake_minimum_required(VERSION 3.20.0)
project(test-xercesc)
find_package(XercesC)
Simply running this command produces the error:
$ cmake .
-- Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR XercesC_VERSION)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mrussell/Source/tools/tmp
Logs
Click to expand log
I see the following error:
-- CMake-conan: find_package(XercesC) found, 'conan install' aready ran
-- Failed to find XercesC (missing: XercesC_LIBRARY XercesC_INCLUDE_DIR XercesC_VERSION)
You have forgotten CMakeToolchain generator (or to manually set CMAKE_MODULE_PATH or CMAKE_PREFIX_PATH if you know what you are doing), but it's not a bug in xerces-c recipe.
You have forgotten CMakeToolchain generator (or to manually set CMAKE_MODULE_PATH or CMAKE_PREFIX_PATH if you know what you are doing), but it's not a bug in xerces-c recipe.
Hi, thanks for the quick reply.
So I have 2 projects, 1 is the simple example/project I sent here and the other is my comprehensive project with a lot of other Conan packages being imported.
I noticed in my comprehensive project, it works if I use:
find_package(XercesC CONFIG REQUIRED)
The keyword here being CONFIG. I wondered if it was related to the use of:
self.cpp_info.set_property("cmake_find_mode", "both")
in the original recipe? which seems to be the main difference when I compare it to other recipes.
But you're also right. In my simple project (that I posed here), adding this fixed it:
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
I should file a bug with the https://github.com/conan-io/cmake-conan project, but I'm actually wondering how this fails still because they do add to the CMAKE_PREFIX_PATH already:
if (CONAN_GENERATORS_FOLDER)
list(PREPEND CMAKE_PREFIX_PATH "${CONAN_GENERATORS_FOLDER}")
endif()
and other packages (e.g. Boost, etc.) are being found before this failure with XercesC?
Also, the generator used is out of my control because this is handled automatically by the cmake-conan project's .cmake files for me.
Any ideas?
cmake-conan is not compatible with conan v2 client yet. I know conan team plans to bring this compatibility in the future, but I don't know more.
@uilianries @prince-chrismc I guess this issue should be moved to https://github.com/conan-io/cmake-conan or https://github.com/conan-io/conan?
I moved the issue, since this is using the experimental feature, it might be tied to here
find_package(XercesC)
I know in other issue https://github.com/conan-io/cmake-conan/issues/478#issuecomment-1473647189 how the config files worked changed behavior