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.
This commit is contained in:
Gilles Peskine 2018-03-21 12:12:47 +01:00
parent 32605dc830
commit 8405257035
3 changed files with 42 additions and 21 deletions

View file

@ -105,26 +105,11 @@ add_test_suite(xtea)
add_test_suite(x509parse)
add_test_suite(x509write)
# Make data_files available in an out-of-source build
# 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})
# 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 (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()
link_to_source(compat.sh)
link_to_source(data_files)
link_to_source(scripts)
link_to_source(ssl-opt.sh)
endif()