Skip to content

CMake version config file is architecture-dependent #1697

Description

@uhoreg

CMake's write_basic_package_version_file by default creates a file that checks that the word size is the same as the word size used when the file was created. That means that if the file was created on a 64-bit machine, then CMake will refuse to use it on a 32-bit machine (or vice versa). This is a problem for the Debian package, since the package is architecture-independent, and so it is only built once on one architecture, and that package used when building other packages on other architectures. See, for example, https://buildd.debian.org/status/fetch.php?pkg=nheko&arch=i386&ver=0.6.4-1&stamp=1564680125&file=log in which it tries to build a package on a 32-bit architecture, using the JSON library package built on a 64-bit architecture.

In CMake 3.14, they added a ARCH_INDEPENDENT flag to write_basic_package_version_file to drop this check. However, if you use that, it would require bumping the minimum version of CMake to 3.14. This also doesn't help us in Debian, since we still have CMake 3.13. For Debian, I've worked around this for now by creating my own template for nlohmann_jsonConfigVersion.cmake:

set(PACKAGE_VERSION "@PROJECT_VERSION@")

if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
  set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()

  if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@")
    set(PACKAGE_VERSION_COMPATIBLE TRUE)
  else()
    set(PACKAGE_VERSION_COMPATIBLE FALSE)
  endif()

  if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
      set(PACKAGE_VERSION_EXACT TRUE)
  endif()
endif()

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions