mbedtls
mbedtls copied to clipboard
Install .cmake files into libdir
Currently the .cmake files (such as MbedTLSConfig.cmake) are installed to a 'cmake' directory under the prefix, which typically ends up as /usr/cmake. This isn't FHS-compliant[1] and every distribution packaging mbedtls will need to manually move the files.
Instead install the files in a 'cmake' directory under CMAKE_INSTALL_LIBDIR, which is also on the find_package() search path.
[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
Signed-off-by: Ross Burton [email protected]
Please could you add a changelog entry? Thanks
Please could you add a changelog entry? Thanks
Hopefully that's sufficient.
@CJKay @gyuri-szing as you've previously had experience with CMake in Mbed TLS, would one of you be able to help review this please?
Looks good to me. The package install test might need updating to account for the change in install path.
(shakes fist at cmake, CI, and computers in general)
Looks good to me for bare-meatal projects (where no FHS compliant sysroot available). I made some tests. My setup is:
- running on ubuntu 18.04
- using cmake v3.18.4
- when building MbedTLS
CMAKE_INSTALL_PREFIX
is set to$HOME/mbedtls_install
I can successfully find MbedTLS from dependeing project the following ways (possibly others are working too):
- pass
-DCMAKE_FIND_ROOT_PATH=$HOME/mbetdls_install
and call find_package() likefind_package(MbedTLS)
- pass
-DMBEDTLS_INSTALL_DIR=$HOME/mbetdls_install
and search for MbedTLS likefind_package(MbedTLS PATHS "${MBEDTLS_INSTALL_DIR}" PATH_SUFFIXES lib/MbedTLS)
- pass
-DMbedTLS_DIR=$HOME/mbetdls_install/lib/cmake/MbedTLS/
and search likefind_package(MbedTLS)
@rossburton
(shakes fist at cmake, CI, and computers in general)
They do exactly what we tell them. That is both their strength and their weakness. And ours!
@rossburton The CI is failing, and it looks to be related to the change, rather than a spurious issue. Are you able to have a look? For example,
[2022-07-24T00:18:15.851Z] -- Installing: /var/lib/build/programs/test/cmake_package_install/mbedtls/include/psa/crypto_values.h
[2022-07-24T00:18:15.851Z] -- Installing: /var/lib/build/programs/test/cmake_package_install/mbedtls/lib/libmbedcrypto.a
[2022-07-24T00:18:15.851Z] -- Installing: /var/lib/build/programs/test/cmake_package_install/mbedtls/lib/libmbedx509.a
[2022-07-24T00:18:15.851Z] -- Installing: /var/lib/build/programs/test/cmake_package_install/mbedtls/lib/libmbedtls.a
[2022-07-24T00:18:15.851Z] CMake Error at CMakeLists.txt:30 (find_package):
[2022-07-24T00:18:15.851Z] By not providing "FindMbedTLS.cmake" in CMAKE_MODULE_PATH this project has
[2022-07-24T00:18:15.851Z] asked CMake to find a package configuration file provided by "MbedTLS", but
[2022-07-24T00:18:15.851Z] CMake did not find one.
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z] Could not find a package configuration file provided by "MbedTLS" with any
[2022-07-24T00:18:15.851Z] of the following names:
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z] MbedTLSConfig.cmake
[2022-07-24T00:18:15.851Z] mbedtls-config.cmake
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z] Add the installation prefix of "MbedTLS" to CMAKE_PREFIX_PATH or set
[2022-07-24T00:18:15.851Z] "MbedTLS_DIR" to a directory containing one of the above files. If
[2022-07-24T00:18:15.851Z] "MbedTLS" provides a separate development package or SDK, be sure it has
[2022-07-24T00:18:15.851Z] been installed.
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z] -- Configuring incomplete, errors occurred!
[2022-07-24T00:18:15.851Z] See also "/var/lib/build/programs/test/cmake_package_install/CMakeFiles/CMakeOutput.log".
[2022-07-24T00:18:15.851Z] ^^^^test_cmake_as_package_install: build: cmake 'as-installed-package' build: cmake . -> 1^^^^
[2022-07-24T00:18:15.851Z]
[2022-07-24T00:18:15.851Z] ******************************************************************
[2022-07-24T00:18:15.851Z] * Done, cleaning up
[2022-07-24T00:18:15.851Z] * Sun Jul 24 00:18:15 UTC 2022
[2022-07-24T00:18:15.851Z] ******************************************************************
[2022-07-24T00:18:17.258Z]
[2022-07-24T00:18:17.258Z] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[2022-07-24T00:18:17.258Z] FAILED: 1 components
[2022-07-24T00:18:17.258Z] test_cmake_as_package_install: build: cmake 'as-installed-package' build: cmake . -> 1
[2022-07-24T00:18:17.258Z] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Yes, I'll get to this shortly.
Hi @rossburton - will you have time to progress this one at some point? thanks
This is duplicated by #6629. Since that PR has passed CI, I'll review it in preference to this PR.
Looks good to me.
This is duplicated by #6629. Since that PR has passed CI, I'll review it in preference to this PR.
In that case I will close this one - thanks both