Skip to content

CMake Config checks for system architecture causes problems on Conan #1368

Closed
@cjdb

Description

Description

While trying to build something with Conan (that uses Catch2), I encountered this diagnostic:

CMake Error at CMakeLists.txt:28 (find_package):
  Could not find a configuration file for package "Catch2" that is compatible
  with requested version "2.3.0".

  The following configuration files were considered but not accepted:

    /home/cjdb/.conan/data/catch2/2.3.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/lib/cmake/Catch2/Catch2Config.cmake, version: 2.3.0 (32bit)

@mmha identified that the call to write_basic_package_version_file in the root CMakeLists.txt generates something that checks the system architecture. By commenting out the following lines in /home/cjdb/.conan/data/catch2/2.3.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/lib/cmake/Catch2/Catch2ConfigVersion.cmake, we were able to kill the error:

# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
#if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "4")
#  math(EXPR installedBits "4 * 8")
#  set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
#  set(PACKAGE_VERSION_UNSUITABLE TRUE)

I'm using a 64-bit machine, which is appears to be different to the bincrafters' machine (as it is expecting a 32-bit machine).

Steps to reproduce

Add this to your project's CMakeLists.txt

find_package(Catch2 2.3.0 REQUIRED)

Extra information

# conanfile.txt
[requires]
boost/1.68.0@conan/stable
range-v3/0.3.6@ericniebler/stable
catch2/2.3.0@bincrafters/stable

[generators]
cmake_paths
virtualenv

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions