diff options
Diffstat (limited to 'cmake/run-and-compare.cmake')
-rw-r--r-- | cmake/run-and-compare.cmake | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cmake/run-and-compare.cmake b/cmake/run-and-compare.cmake index 209d31e..eb2218d 100644 --- a/cmake/run-and-compare.cmake +++ b/cmake/run-and-compare.cmake @@ -16,6 +16,10 @@ if(NOT DEFINED OUTPUT OR NOT DEFINED COMPARE OR NOT DEFINED COMMAND) message(FATAL_ERROR "Run and compare arguments missing") endif() +# Ensure directory exists for output files +get_filename_component(OUTPUT_DIR "${OUTPUT}" DIRECTORY) +file(MAKE_DIRECTORY "${OUTPUT_DIR}") + if(INPUT) # Run command with stdin input and redirect stdout to output execute_process(COMMAND ${CMAKE_COMMAND} @@ -41,10 +45,16 @@ endif() # Use configure_file to normalize line-endings if(IGNORE_LINE_ENDINGS) - configure_file(${COMPARE} ${COMPARE}.cmp NEWLINE_STYLE LF) - set(COMPARE ${COMPARE}.cmp) - configure_file(${OUTPUT} ${OUTPUT}.cmp NEWLINE_STYLE LF) - set(OUTPUT ${OUTPUT}.cmp) + # Rewrite files with normalized line endings to temporary directory + get_filename_component(COMPARE_NAME ${COMPARE} NAME) + set(COMPARE_TEMP ${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary/${COMPARE_NAME}.cmp) + configure_file(${COMPARE} ${COMPARE_TEMP} NEWLINE_STYLE LF) + set(COMPARE ${COMPARE_TEMP}) + + get_filename_component(OUTPUT_NAME ${OUTPUT} NAME) + set(OUTPUT_TEMP ${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary/${OUTPUT_NAME}.cmp) + configure_file(${OUTPUT} ${OUTPUT_TEMP} NEWLINE_STYLE LF) + set(OUTPUT ${OUTPUT_TEMP}) endif() # Compare that output is equal to specified file |