From e96bfbc6bd3f3396da1c56aaddb72a8a9efeaa54 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Mon, 7 Jul 2014 16:55:03 +0200 Subject: [PATCH] Fixed testing with out-of-source builds using cmake --- ChangeLog | 1 + tests/CMakeLists.txt | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5d8da2277..100bb74e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ Bugfix * Replaced expired test certificate * ssl_mail_client now terminates lines with CRLF, instead of LF * Fix bug in RSA PKCS#1 v1.5 "reversed" operations + * Fixed testing with out-of-source builds using cmake = Version 1.2.10 released 2013-10-07 Changes diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index be93649a4..c6b908ddc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -69,3 +69,25 @@ add_test_suite(version) add_test_suite(xtea) add_test_suite(x509parse) add_test_suite(x509write) + +# Make data_files available in an out-of-source build +if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + # Get OS dependent path to use in `execute_process` + file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/data_files" link) + file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data_files" target) + + if (UNIX) + set(command ln -s ${target} ${link}) + else() + set(command cmd.exe /c mklink ${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() +