diff options
author | Gilles Peskine <Gilles.Peskine@arm.com> | 2018-03-21 12:12:47 +0100 |
---|---|---|
committer | Gilles Peskine <Gilles.Peskine@arm.com> | 2018-03-21 12:28:59 +0100 |
commit | 84052570355bb5608248f162b622068b7b9eaa7c (patch) | |
tree | da32496dbc5dc10610683a71f6c3b99f66f62c4e /CMakeLists.txt | |
parent | 32605dc83042d737e715a685e53176388d73540e (diff) | |
download | mbedtls-84052570355bb5608248f162b622068b7b9eaa7c.zip mbedtls-84052570355bb5608248f162b622068b7b9eaa7c.tar.gz mbedtls-84052570355bb5608248f162b622068b7b9eaa7c.tar.bz2 |
Support out-of-tree testing with CMake
Create extra symbolic links with CMake so that SSL testing (ssl-opt.sh
and compat.sh) works in out-of-tree builds.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ca4cba2..df03dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,30 @@ 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) +# Create a symbolic link from ${base_name} in the binary directory +# to the corresponding path in the source directory. +function(link_to_source base_name) + # Get OS dependent path to use in `execute_process` + file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${base_name}" link) + file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}" target) + + if (NOT EXISTS ${link}) + if (CMAKE_HOST_UNIX) + set(command ln -s ${target} ${link}) + else() + set(command cmd.exe /c mklink /j ${link} ${target}) + endif() + + execute_process(COMMAND ${command} + RESULT_VARIABLE result + ERROR_VARIABLE output) + + if (NOT ${result} EQUAL 0) + message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}") + endif() + endif() +endfunction(link_to_source) + string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") if(CMAKE_COMPILER_IS_GNUCC) @@ -164,3 +188,9 @@ if(ENABLE_TESTING) ) endif(UNIX) endif() + +# Make scripts and data files needed for testing available in an +# out-of-source build. +if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + link_to_source(scripts) +endif() |