1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-05 19:35:48 +03:00

Use emptiness-checks rather than DEFINED checks

For the MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE variables,
check that they are non-empty and defined. This means they can be
unconditionally created in the cache, simplifying the CMakeLists.txt

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann
2023-02-15 14:44:25 +00:00
parent 6762231e4b
commit 58dda6713c
2 changed files with 7 additions and 11 deletions

View File

@@ -135,13 +135,9 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
FORCE) FORCE)
endif() endif()
# If set, make MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE into PATHs # Make MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE into PATHs
if(DEFINED MBEDTLS_CONFIG_FILE) set(MBEDTLS_CONFIG_FILE "" CACHE FILEPATH "Mbed TLS config file (overrides default).")
set(MBEDTLS_CONFIG_FILE "" CACHE PATH "Mbed TLS config file (overrides default).") set(MBEDTLS_USER_CONFIG_FILE "" CACHE FILEPATH "Mbed TLS user config file (appended to default).")
endif()
if(DEFINED MBEDTLS_USER_CONFIG_FILE)
set(MBEDTLS_USER_CONFIG_FILE "" CACHE PATH "Mbed TLS user config file (appended to default).")
endif()
# Create a symbolic link from ${base_name} in the binary directory # Create a symbolic link from ${base_name} in the binary directory
# to the corresponding path in the source directory. # to the corresponding path in the source directory.
@@ -314,13 +310,13 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/everest/include) PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/everest/include)
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE # Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
if(DEFINED MBEDTLS_CONFIG_FILE) if(MBEDTLS_CONFIG_FILE)
target_compile_definitions(mbedtls_test target_compile_definitions(mbedtls_test
PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}") PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}")
target_compile_definitions(mbedtls_test_helpers target_compile_definitions(mbedtls_test_helpers
PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}") PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}")
endif() endif()
if(DEFINED MBEDTLS_USER_CONFIG_FILE) if(MBEDTLS_USER_CONFIG_FILE)
target_compile_definitions(mbedtls_test target_compile_definitions(mbedtls_test
PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}") PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}")
target_compile_definitions(mbedtls_test_helpers target_compile_definitions(mbedtls_test_helpers

View File

@@ -230,11 +230,11 @@ foreach(target IN LISTS target_libraries)
target_compile_definitions(${target} target_compile_definitions(${target}
PRIVATE ${thirdparty_def}) PRIVATE ${thirdparty_def})
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE # Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
if(DEFINED MBEDTLS_CONFIG_FILE) if(MBEDTLS_CONFIG_FILE)
target_compile_definitions(${target} target_compile_definitions(${target}
PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}") PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}")
endif() endif()
if(DEFINED MBEDTLS_USER_CONFIG_FILE) if(MBEDTLS_USER_CONFIG_FILE)
target_compile_definitions(${target} target_compile_definitions(${target}
PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}") PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}")
endif() endif()