diff options
author | Justin Bassett <jbassett271@gmail.com> | 2018-11-26 07:40:36 (GMT) |
---|---|---|
committer | Justin Bassett <jbassett271@gmail.com> | 2018-12-01 06:52:40 (GMT) |
commit | eb973f935f25f5bafdb8d55360a1b122e9dabfa5 (patch) | |
tree | f7d7ad0665c8ea0e04efe8a7b7d782beabad60d7 /Modules | |
parent | 6786345210994063030ad82f7ece66a461bbfb76 (diff) | |
download | CMake-eb973f935f25f5bafdb8d55360a1b122e9dabfa5.zip CMake-eb973f935f25f5bafdb8d55360a1b122e9dabfa5.tar.gz CMake-eb973f935f25f5bafdb8d55360a1b122e9dabfa5.tar.bz2 |
CMakePackageConfigHelpers: Add ARCH_INDEPENDENT option
Allow skipping the architecture check in the package version file generated from calling
write_basic_package_version_file. Document said architecture check.
Fixes: #16184
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/BasicConfigVersion-AnyNewerVersion.cmake.in | 6 | ||||
-rw-r--r-- | Modules/BasicConfigVersion-ExactVersion.cmake.in | 5 | ||||
-rw-r--r-- | Modules/BasicConfigVersion-SameMajorVersion.cmake.in | 5 | ||||
-rw-r--r-- | Modules/BasicConfigVersion-SameMinorVersion.cmake.in | 5 | ||||
-rw-r--r-- | Modules/CMakePackageConfigHelpers.cmake | 15 | ||||
-rw-r--r-- | Modules/WriteBasicConfigVersionFile.cmake | 3 |
6 files changed, 37 insertions, 2 deletions
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index bc78016..afffc04 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -18,6 +18,12 @@ else() endif() endif() + +# if the installed project requested no architecture check, don't perform the check +if("@CVF_ARCH_INDEPENDENT@") + return() +endif() + # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") return() diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index de4a23a..fe5c2e5 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -34,6 +34,11 @@ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) endif() +# if the installed project requested no architecture check, don't perform the check +if("@CVF_ARCH_INDEPENDENT@") + return() +endif() + # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") return() diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index a32245d..d885c0f 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -33,6 +33,11 @@ else() endif() +# if the installed project requested no architecture check, don't perform the check +if("@CVF_ARCH_INDEPENDENT@") + return() +endif() + # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") return() diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in index 59ca253..bf055e8 100644 --- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in @@ -37,6 +37,11 @@ else() endif() +# if the installed project requested no architecture check, don't perform the check +if("@CVF_ARCH_INDEPENDENT@") + return() +endif() + # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") return() diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index bcc9bf8..22fc953 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -124,7 +124,8 @@ Generating a Package Version File write_basic_package_version_file(<filename> [VERSION <major.minor.patch>] - COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> ) + COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> + [ARCH_INDEPENDENT] ) Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to @@ -158,6 +159,18 @@ If your project has more elaborated version matching rules, you will need to write your own custom ``ConfigVersion.cmake`` file instead of using this macro. +If ``ARCH_INDEPENDENT`` is given, the installed package version will be +considered compatible even if it was built for a different architecture than +the requested architecture. Otherwise, an architecture check will be performed, +and the package will be considered compatible only if the architecture matches +exactly. For example, if the package is built for a 32-bit architecture, the +package is only considered compatible if it is used on a 32-bit architecture, +unless ``ARCH_INDEPENDENT`` is given, in which case the package is considered +compatible on any architecture. + +.. note:: ``ARCH_INDEPENDENT`` is intended for header-only libraries or similar + packages with no binaries. + Internally, this macro executes :command:`configure_file()` to create the resulting version file. Depending on the ``COMPATIBILITY``, the corresponding ``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used. diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 1f13096..45f9e58 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -15,6 +15,7 @@ WriteBasicConfigVersionFile WRITE_BASIC_CONFIG_VERSION_FILE( filename [VERSION major.minor.patch] COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion) + [ARCH_INDEPENDENT] ) @@ -22,7 +23,7 @@ WriteBasicConfigVersionFile function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) - set(options ) + set(options ARCH_INDEPENDENT ) set(oneValueArgs VERSION COMPATIBILITY ) set(multiValueArgs ) |