Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cjdb opened this issue Aug 27, 2018 · 5 comments
Closed

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

cjdb opened this issue Aug 27, 2018 · 5 comments

Comments

@cjdb
Copy link
Contributor

cjdb commented Aug 27, 2018

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
@mmha
Copy link

mmha commented Aug 27, 2018

There is an issue on the Kitware Gitlab open for this limitation: https://gitlab.kitware.com/cmake/cmake/issues/16184

@horenmar
Copy link
Member

So, if I understand this correctly, the problem is that CMake automatically encodes and checks what "bitness" a package is when using PackageConfig, and Conan generates the package on a 32bit machine, which means that 64bit machines cannot use the package?

@mmha
Copy link

mmha commented Aug 29, 2018

@horenmar That is correct. It's more of an upstream CMake issue than a Catch issue, but as it stands right now the version check for the config file makes the CMake package nonportable.

@horenmar
Copy link
Member

Yeah, I am gonna say that either of the upstreams (CMake/conan) need to fix this. Catch2ConfigVersion.cmake is completely autogenerated using CMake facilities, so either conan needs to provide properly configured files, or CMake needs to provide the ability to mark a package as platform-independent, but I don't want to change our CMake files to write our bespoke ConfigVersion file.

@horenmar horenmar added 3rd party bug Resolved - pending review Issue waiting for feedback from the original author labels Aug 29, 2018
@horenmar
Copy link
Member

horenmar commented Sep 1, 2018

As it turns out, there is a fairly reasonable workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants