Old cmake package version in install content #553

Closed
opened 2025-10-29 03:23:30 -05:00 by gyuri-szing · 2 comments
gyuri-szing commented 2025-10-29 03:23:30 -05:00 (Migrated from github.com)

Summary

The installed cmake package file (TF-PSA-CryptoConfigVersion.cmake) contains a hardcoded version number (0.1.0) when building v1.0.0 tag. As a result find_package(TF-PSA-Crypto 1.0.0 REQUIRED) fails to find the library.
IMHO the version should match the product version to allow 3rd parties to depend on the correct version.

(Note: tfpsacrypto.pc has the correct 1.0.0 version.)

System information

TF-PSA-Crypto version (number or commit id): v1.0.0
Operating system and version: Ubuntu 22.01 (irrelevant)
Configuration (if not default, please attach crypto_config.h): irrelevant
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): irrelevant
Additional environment information: none

Expected behavior

Package version should match product version. find_package(TF-PSA-Crypto 1.0.0) should find the cmake package when building v1.0.0.

Actual behavior

find_package(TF-PSA-Crypto 1.0.0 REQUIRED) returns arror as the package version is 0.1.0.

Steps to reproduce

Create test.cmake file with the following content:

cmake_minimum_required(VERSION 3.18)
find_package(TF-PSA-Crypto 0.1.0 REQUIRED)

Build TF-PSA-Crypto and install it to INSTALL_DIR.

Run the test.cmake:

cmake -P test.cmake -DCMAKE_PREFIX_PATH=$(readlink -f $INSTALL_DIR)

Additional information

Please fix the version number here: https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/development/CMakeLists.txt#L467

Updating this line should be part of the release process.

### Summary The installed cmake package file (TF-PSA-CryptoConfigVersion.cmake) contains a hardcoded version number (0.1.0) when building v1.0.0 tag. As a result find_package(TF-PSA-Crypto 1.0.0 REQUIRED) fails to find the library. IMHO the version should match the product version to allow 3rd parties to depend on the correct version. (Note: tfpsacrypto.pc has the correct 1.0.0 version.) ### System information TF-PSA-Crypto version (number or commit id): v1.0.0 Operating system and version: Ubuntu 22.01 (irrelevant) Configuration (if not default, please attach `crypto_config.h`): irrelevant Compiler and options (if you used a pre-built binary, please indicate how you obtained it): irrelevant Additional environment information: none ### Expected behavior Package version should match product version. find_package(TF-PSA-Crypto 1.0.0) should find the cmake package when building v1.0.0. ### Actual behavior find_package(TF-PSA-Crypto 1.0.0 REQUIRED) returns arror as the package version is 0.1.0. ### Steps to reproduce Create test.cmake file with the following content: ``` cmake_minimum_required(VERSION 3.18) find_package(TF-PSA-Crypto 0.1.0 REQUIRED) ``` Build TF-PSA-Crypto and install it to INSTALL_DIR. Run the test.cmake: ``` cmake -P test.cmake -DCMAKE_PREFIX_PATH=$(readlink -f $INSTALL_DIR) ``` ### Additional information Please fix the version number here: https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/development/CMakeLists.txt#L467 Updating this line should be part of the release process.
gilles-peskine-arm commented 2025-10-29 03:34:56 -05:00 (Migrated from github.com)

CMakeLists.txt in Mbed TLS has the same duplication. There we remembered to update the version.

To the CMake experts (which I'm not): is there any reason why the package version would ever be different from the product version? Why didn't we write

    write_basic_package_version_file(
        "cmake/TF-PSA-CryptoConfigVersion.cmake"
            COMPATIBILITY SameMajorVersion
            VERSION "$TF_PSA_CRYPTO_VERSION")

`CMakeLists.txt` in Mbed TLS has the same duplication. There we remembered to update the version. To the CMake experts (which I'm not): is there any reason why the package version would ever be different from the product version? Why didn't we write ``` write_basic_package_version_file( "cmake/TF-PSA-CryptoConfigVersion.cmake" COMPATIBILITY SameMajorVersion VERSION "$TF_PSA_CRYPTO_VERSION") ```
gyuri-szing commented 2025-10-29 03:47:14 -05:00 (Migrated from github.com)

CMakeLists.txt in Mbed TLS has the same duplication. There we remembered to update the version.

To the CMake experts (which I'm not): is there any reason why the package version would ever be different from the product version? Why didn't we write

    write_basic_package_version_file(
        "cmake/TF-PSA-CryptoConfigVersion.cmake"
            COMPATIBILITY SameMajorVersion
            VERSION "$TF_PSA_CRYPTO_VERSION")

IMHO the CMake package version has the same purpose as the pkgconfig version, which is to identify the product, and it shall behave the same way.
As far as I am aware of, cmake package versions do not have complex schemes like Debian packages, where the package version captures the up-stream version (1.0.0. in this case) and the package version. This allows the package maintainer to update the package itself.

> `CMakeLists.txt` in Mbed TLS has the same duplication. There we remembered to update the version. > > To the CMake experts (which I'm not): is there any reason why the package version would ever be different from the product version? Why didn't we write > > ``` > write_basic_package_version_file( > "cmake/TF-PSA-CryptoConfigVersion.cmake" > COMPATIBILITY SameMajorVersion > VERSION "$TF_PSA_CRYPTO_VERSION") > ``` IMHO the CMake package version has the same purpose as[ the pkgconfig version](https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/development/pkgconfig/tfpsacrypto.pc.in), which is to identify the product, and it shall behave the same way. As far as I am aware of, cmake package versions do not have complex schemes like Debian packages, where the package version captures the up-stream version (1.0.0. in this case) and the package version. This allows the package maintainer to update the package itself.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto#553
No description provided.