diff --git a/cmake/ec_sort.cmake b/cmake/ec_sort.cmake index 1ac8c4f..b98478b 100755 --- a/cmake/ec_sort.cmake +++ b/cmake/ec_sort.cmake @@ -4,6 +4,8 @@ # Call as, e.g.: # cmake -D EDITORCONFIG_CMD="../editorconfig" -D ECARGS:LIST="-f;.editorconfig;foo" -P cmake/ec_sort.cmake +# EDITORCONFIG_CMD may also be list-valued. EDITORCONFIG_CMD and ECARGS +# are put together on the command line, in that order, and split by CMake. # BSD-2-Clause # Copyright 2018 Christopher White (cxw42 at GitHub; http://devwrench.com) @@ -38,6 +40,11 @@ list(APPEND CMAKE_MODULE_PATH "${tests_cmake_ec_sort_dir}/../cmake") include(runandsort) # Required parameters are in variables: EDITORCONFIG_CMD and ECARGS +if("${EDITORCONFIG_CMD}" STREQUAL "") + message(FATAL_ERROR "No EDITORCONFIG_CMD parameter specified") + return() +endif() + if("${ECARGS}" STREQUAL "") message(FATAL_ERROR "No ECARGS parameter specified") return() @@ -47,8 +54,7 @@ endif() #message(FATAL_ERROR " Running ${EDITORCONFIG_CMD} with ${ECARGS}") run_and_sort(RETVAL lines RETVAL_FAILURE did_fail - PGM "${EDITORCONFIG_CMD}" - ARGS ${ECARGS} + CMDLINE ${EDITORCONFIG_CMD} ${ECARGS} ) if(${did_fail}) diff --git a/cmake/runandsort.cmake b/cmake/runandsort.cmake index d279607..6c46794 100755 --- a/cmake/runandsort.cmake +++ b/cmake/runandsort.cmake @@ -48,8 +48,7 @@ cmake_minimum_required(VERSION 3.5) # Arguments: # RETVAL . . . . . . . The name of the variable to store the result in -# PGM . . . . . . . . The program to run -# ARGS . . . . . . . . Any arguments to pass to the program +# CMDLINE . . . . . . . The program to run, and any arguments # RETVAL_FAILURE . . . . If present, a variable that will be set to TRUE # if PGM returns a non-zero exit code. # CAPTURE_STDERR . . . . If present, capture stderr instead of stdout @@ -64,13 +63,13 @@ cmake_minimum_required(VERSION 3.5) function(run_and_sort) # Argument parsing set(option_keywords CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE) - set(one_value_keywords RETVAL RETVAL_FAILURE PGM) - set(multi_value_keywords ARGS) + set(one_value_keywords RETVAL RETVAL_FAILURE) + set(multi_value_keywords CMDLINE ARGS) cmake_parse_arguments(P "${option_keywords}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) - #message(STATUS "Running ${P_PGM} with ${P_ARGS}") - execute_process(COMMAND "${P_PGM}" ${P_ARGS} + #message(STATUS "Running ${P_CMDLINE}") + execute_process(COMMAND ${P_CMDLINE} RESULT_VARIABLE ep_retval OUTPUT_VARIABLE ep_stdout ERROR_VARIABLE ep_stderr diff --git a/meta/sample.cmake b/meta/sample.cmake index b5e5546..a7e9eae 100644 --- a/meta/sample.cmake +++ b/meta/sample.cmake @@ -9,8 +9,8 @@ include( runandsort ) run_and_sort( RETVAL lines RETVAL_FAILURE did_fail CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE # since we're using almostcat - PGM "cmake" - ARGS "-DWHICH:STRING=${tests_meta_sample_dir}/sample.txt" "-P" "${tests_meta_sample_dir}/../cmake/almostcat.cmake" + CMDLINE "cmake" "-DWHICH:STRING=${tests_meta_sample_dir}/sample.txt" + "-P" "${tests_meta_sample_dir}/../cmake/almostcat.cmake" ) # Don't use cat(1) since we might be running on Windows if( ${did_fail} )