Skip to content

Commit

Permalink
Install CMake files in MbedTLS dir
Browse files Browse the repository at this point in the history
Right now, CMake files are installed in <prefix>/cmake. That being said,
it gets easily bloated, and the standard is to use a directory with the
same name as the project.

I discovered this issue with this "bug":
termux/termux-packages#12416
The issue's author claimed that MbedTLS's files were not installed in
the lib directory. But the patch applied by termux team broke CMake's
search of MbedTLS config files. So I wanted to upstream the real fix
here instead.

Here are some examples of projects using directories:
 - https://github.com/xiph/flac/blob/1.4.2/CMakeLists.txt#L239
 - https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-1.15.2/CMakeLists.txt#L675
 - https://github.com/catchorg/Catch2/blob/v3.2.0/CMakeLists.txt#L62
 - https://github.com/capnproto/capnproto/blob/v0.10.2/c++/CMakeLists.txt#L162

Signed-off-by: Issam E. Maghni <issam.e.maghni@mailbox.org>
  • Loading branch information
concatime committed Dec 4, 2022
1 parent 821d862 commit 760f3a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -355,7 +355,7 @@ if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/MbedTLSConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/MbedTLSConfigVersion.cmake"
DESTINATION "cmake")
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/MbedTLS")

export(
EXPORT MbedTLSTargets
Expand All @@ -365,7 +365,7 @@ if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
install(
EXPORT MbedTLSTargets
NAMESPACE MbedTLS::
DESTINATION "cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/MbedTLS"
FILE "MbedTLSTargets.cmake")

if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.d/cmake-install.txt
@@ -0,0 +1,3 @@
Changes
* Install the .cmake files into CMAKE_INSTALL_LIBDIR/cmake/MbedTLS,
typically /usr/lib/cmake/MbedTLS.
2 changes: 1 addition & 1 deletion programs/test/cmake_package_install/CMakeLists.txt
Expand Up @@ -26,7 +26,7 @@ execute_process(
# Locate the package.
#

set(MbedTLS_DIR "${MbedTLS_INSTALL_DIR}/cmake")
list(INSERT CMAKE_PREFIX_PATH 0 "${MbedTLS_INSTALL_DIR}")
find_package(MbedTLS REQUIRED)

#
Expand Down

0 comments on commit 760f3a0

Please sign in to comment.