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

Install CMake config to LIBDIR by default, to correctly support multiarch #3849

Merged
merged 2 commits into from
Mar 17, 2020

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Mar 17, 2020

Using share/cmake/${PROJECT_NAME} as DESTINATION for installing ZeroMQConfig.cmake et al works for arch-independent configs (like cppzmq's header-only package), but is wrong for arch-dependent packages when installed on multiarch systems.

The ...Config.cmake file is the library interface definition, and in arch-dependent multiarch builds is specific to the architecture currently being built. Each build of a library should have its interface installed below the arch-dependent LIBDIR.

This PR sets the default ZEROMQ_CMAKECONFIG_INSTALL_DIR to "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}", using the GNUInstallDirs ${CMAKE_INSTALL_LIBDIR} variable to target the correct arch-dependent dir.

See e.g. Daniel Pfeifer's "Effective CMake" (PDF of slides from CPPNow 2017), though he doesn't use GNUInstallDirs:

Export your library interface!

include(CMakePackageConfigHelpers)
write_basic_package_version_file("FooConfigVersion.cmake"
  VERSION ${Foo_VERSION}
  COMPATIBILITY SameMajorVersion
  )
install(FILES "FooConfig.cmake" "FooConfigVersion.cmake"
  DESTINATION lib/cmake/Foo
  )

Or Pablo Arias' "It's Time To Do CMake Right" post, which does:

install(EXPORT jsonutils-targets
  FILE
    JSONUtilsTargets.cmake
  NAMESPACE
    JSONUtils::
  DESTINATION
    ${CMAKE_INSTALL_LIBDIR}/cmake/JSONUtils
)

Administrative: Relicensing statement included, signoffs in commit messages

Solution: Install CMake config in arch-dependent LIBDIR/cmake

Using "share/cmake/${PROJECT_NAME}" as DESTINATION for installing
ZeroMQConfig.cmake et al works for arch-independent configs, but
is wrong for multiarch. The configs for each version of the
library should be stored below the arch-dependent LIBDIR, using
the GNUInstallDirs ${CMAKE_INSTALL_LIBDIR} variable.

Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
@bluca bluca merged commit 876d4bf into zeromq:master Mar 17, 2020
@ferdnyc ferdnyc deleted the zeromq-config-install branch March 17, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants