Skip to content

cmake control of CMAKE_BUILD_TYPE when using mbedtls in other projects #3789

Closed

Description

@peter-toft-greve

If using mbedtls from other cmake projects it is quite problematic to set the CMAKE_BUILD_TYPE
like it is done in https://github.com/ARMmbed/mbedtls/blob/72ca39737f974db44723760623d1b29980c00a88/CMakeLists.txt#L115

I suggest a simple patch - basically only do the lines when the project is the top project

$ git diff HEAD^
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5af4c8124..27590ef08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,9 +112,12 @@ option: \n\
     endif()
 endif()
 
-set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
-    CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull"
-    FORCE)
+# If this is the root project add longer list of available CMAKE_BUILD_TYPE values
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+    set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
+        CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull"
+        FORCE)
+endif()
 
 # Create a symbolic link from ${base_name} in the binary directory
 # to the corresponding path in the source directory.

Description

  • Type: Bug
  • Priority: Minor

Bug

OS
All

mbed TLS build:
Version: git commit id 72ca397
branch: development


Enhancement\Feature Request

Justification - why does the library need this feature?
Integration to other projects also running cmake. The current code traverses the CMAKE_BUILD_TYPE to the mother project, which can be anything - thus clearly problematic.

Suggested enhancement
With the patch the code will let the project using mbedtls control the build types

Activity

  1. paul-elliott-arm commented on Oct 14, 2020

    @paul-elliott-arm
    Member

    Could you potentially submit this as a pull request?

  2. added
    good-first-issue
    help-wanted
    on Oct 14, 2020
  3. peter-toft-greve commented on Oct 14, 2020

    @peter-toft-greve
    Author

    Thanx @paul-elliott-arm I have it ready - tried to push to feature/cmake-not-top but got

    ERROR: Permission to ARMmbed/mbedtls.git denied to peter-toft-greve.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    The same snippet can be found at https://pastebin.pl/view/raw/8ff3dcd6

  4. gilles-peskine-arm commented on Oct 14, 2020

    @gilles-peskine-arm
    Contributor

    @peter-toft-greve Please fork the repository on GitHub, push the branch to your forked repository, and then open a pull request from that branch.

    Note that the commit message needs a signoff line indicating that you have the right to submit the patch.

  5. peter-toft-greve commented on Oct 14, 2020

    @peter-toft-greve
    Author
  6. added
    historical-reviewing
    and removed
    help-wanted
    on Jan 27, 2023
  7. tom-cosgrove-arm commented on Jan 27, 2023

    @tom-cosgrove-arm
    Contributor

    Fixed by #3790 (which said "Solves: #3789" rather than "Resolves:", hence why this wasn't closed automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood-first-issuehistorical-reviewing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions