mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

Install .cmake files into libdir

Open rossburton opened this issue 2 years ago • 9 comments

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]

rossburton avatar Jul 21 '22 12:07 rossburton

Please could you add a changelog entry? Thanks

daverodgman avatar Jul 21 '22 13:07 daverodgman

Please could you add a changelog entry? Thanks

Hopefully that's sufficient.

rossburton avatar Jul 21 '22 13:07 rossburton

@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?

daverodgman avatar Jul 21 '22 14:07 daverodgman

Looks good to me. The package install test might need updating to account for the change in install path.

CJKay avatar Jul 22 '22 11:07 CJKay

(shakes fist at cmake, CI, and computers in general)

rossburton avatar Jul 22 '22 13:07 rossburton

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() like find_package(MbedTLS)
  • pass -DMBEDTLS_INSTALL_DIR=$HOME/mbetdls_install and search for MbedTLS like find_package(MbedTLS PATHS "${MBEDTLS_INSTALL_DIR}" PATH_SUFFIXES lib/MbedTLS)
  • pass -DMbedTLS_DIR=$HOME/mbetdls_install/lib/cmake/MbedTLS/ and search like find_package(MbedTLS)

gyuri-szing avatar Jul 22 '22 15:07 gyuri-szing

@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!

tom-cosgrove-arm avatar Jul 23 '22 16:07 tom-cosgrove-arm

@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] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

tom-cosgrove-arm avatar Jul 27 '22 10:07 tom-cosgrove-arm

Yes, I'll get to this shortly.

rossburton avatar Jul 27 '22 10:07 rossburton

Hi @rossburton - will you have time to progress this one at some point? thanks

daverodgman avatar Oct 26 '22 17:10 daverodgman

This is duplicated by #6629. Since that PR has passed CI, I'll review it in preference to this PR.

davidhorstmann-arm avatar Dec 01 '22 14:12 davidhorstmann-arm

Looks good to me.

rossburton avatar Dec 01 '22 14:12 rossburton

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

daverodgman avatar Dec 05 '22 09:12 daverodgman