Skip to content

Enable use of Mbed TLS and Mbed Crypto as a CMake subproject #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2019

Conversation

Patater
Copy link
Contributor

@Patater Patater commented Jun 18, 2019

Remove use of CMAKE_SOURCE_DIR in case mbedtls is built from within
another CMake project. Define MBEDTLS_DIR to ${CMAKE_CURRENT_SOURCE_DIR}
in the main CMakeLists.txt file and refer to that when defining target
include paths to enable mbedtls to be built as a sub project.

Fixes Mbed-TLS/mbedtls#2609

Signed-off-by: Ashley Duncan [email protected]
Signed-off-by: Jaeden Amero [email protected]

@Patater Patater added enhancement New feature or request needs: review The pull request is ready for review. This generally means that it has no known issues. needs: ci Needs a passing full CI run labels Jun 18, 2019
@Patater Patater force-pushed the cmake-subproject-fix branch 2 times, most recently from ae1b548 to 3a36c5a Compare June 20, 2019 16:25
@Patater Patater requested review from dgreen-arm and andresag01 June 20, 2019 16:54
@Patater Patater force-pushed the cmake-subproject-fix branch from 3a36c5a to 6fd4022 Compare June 20, 2019 17:24
@Patater
Copy link
Contributor Author

Patater commented Jun 20, 2019

Rebased to add MBEDTLS_DIR setting to library/CMakeLists.txt, as that's how Mbed TLS includes Mbed Crypto.

@Patater Patater changed the title Remove use of CMAKE_SOURCE_DIR Enable use of Mbed TLS and Mbed Crypto as a CMake subproject Jun 20, 2019
@Patater Patater force-pushed the cmake-subproject-fix branch from 6fd4022 to 5d5cdc5 Compare June 21, 2019 09:12
@Patater
Copy link
Contributor Author

Patater commented Jun 21, 2019

Rebased to enable use of tests CMakeList.txt without crypto/CMakeLists.txt being included.

@Patater Patater removed the needs: ci Needs a passing full CI run label Jun 21, 2019
dgreen-arm
dgreen-arm previously approved these changes Jun 21, 2019
Copy link
Contributor

@dgreen-arm dgreen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andresag01 andresag01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me. I reviewed an analogous patch for Mbed TLS itself (Mbed-TLS/mbedtls#2706) and I quite liked the fact that that patch had tests. Why is it that we do not have one here? Is this pointless? Is it possible add the test?

@Patater
Copy link
Contributor Author

Patater commented Jun 25, 2019

The changes look good to me. I reviewed an analogous patch for Mbed TLS itself (ARMmbed/mbedtls#2706) and I quite liked the fact that that patch had tests. Why is it that we do not have one here? Is this pointless? Is it possible add the test?

It's not pointless. We get similar coverage from our CI system, since we build Mbed Crypto as a submodule of Mbed TLS. However, we can add an explicit test to build a program with Mbed Crypto as a standalone library via a CMake subfolder. I've added a commit to do this.

@Patater
Copy link
Contributor Author

Patater commented Jun 25, 2019

Rebased to add a regression test and to change the minimum CMake version to 2.6, to match the version required by the top level project CMakeLists.txt.

@andresag01
Copy link
Contributor

@Patater: Thanks for adding the test. I will wait for your answer regarding the test in Mbed-TLS/mbedtls#2706 (comment) before approving your changes.

@Patater Patater force-pushed the cmake-subproject-fix branch from 95df979 to ffe10a8 Compare June 25, 2019 14:22
@Patater
Copy link
Contributor Author

Patater commented Jun 25, 2019

Rebased to move cleanup of the CMake subproject test to cleanup().

ashesman and others added 3 commits June 26, 2019 12:46
Remove use of CMAKE_SOURCE_DIR in case mbedtls is built from within
another CMake project. Define MBEDTLS_DIR to ${CMAKE_CURRENT_SOURCE_DIR}
in the main CMakeLists.txt file and refer to that when defining target
include paths to enable mbedtls to be built as a sub project.

Fixes Mbed-TLS/mbedtls#2609

Signed-off-by: Ashley Duncan <[email protected]>
Signed-off-by: Jaeden Amero <[email protected]>
When building Mbed Crypto when including it via CMake's
`add_subdirectory()`, the tests are also built by default. This means
all headers the tests need must be public, in order for the build of the
tests to have access to the headers.
If we have a regression with the "build Mbed Crypto as a subdirectory
with CMake" feature and fail to build, fail the test.
@Patater Patater force-pushed the cmake-subproject-fix branch from ffe10a8 to e8451f2 Compare June 26, 2019 11:48
@Patater
Copy link
Contributor Author

Patater commented Jun 26, 2019

Rebased to update to latest development, in order to avoid test failures due to assert.h being incompatible with older versions of tests.

@Patater Patater removed the needs: review The pull request is ready for review. This generally means that it has no known issues. label Jul 2, 2019
@Patater Patater merged commit ee6f9b2 into ARMmbed:development Jul 2, 2019
Patater added a commit to Patater/mbedtls that referenced this pull request Jul 2, 2019
Update Mbed Crypto to a commit on its development branch that contains
the merged [mbed-crypto#152
PR](ARMmbed/mbed-crypto#152).
RonEld pushed a commit to RonEld/mbed-crypto that referenced this pull request Jul 9, 2019
Patater added a commit to Patater/mbedtls that referenced this pull request Jul 12, 2019
Update Mbed Crypto to a commit on its development branch that contains
the merged [mbed-crypto#152
PR](ARMmbed/mbed-crypto#152).
Patater added a commit to Patater/mbedtls that referenced this pull request Jul 12, 2019
Update Mbed Crypto to a commit on its development branch that contains
the merged [mbed-crypto#152
PR](ARMmbed/mbed-crypto#152).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cant build mbedtls as cmake subdirectory
4 participants