Skip to content

Commit

Permalink
Partially rollback to previous version of FindMatlab
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Sep 27, 2016
1 parent d52b276 commit 022ea30
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions cmake/modules/3.7/FindMatlab.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -783,30 +783,39 @@ function(matlab_add_unit_test)
endif()

set(options NO_UNITTEST_FRAMEWORK)
set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY
set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY)
set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS
UNITTEST_PRECOMMAND CUSTOM_TEST_COMMAND)
set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS)

set(prefix _matlab_unittest_prefix)
cmake_parse_arguments(PARSE_ARGV 0 ${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" )
cmake_parse_arguments(${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )

if(NOT ${prefix}_NAME)
message(FATAL_ERROR "[MATLAB] The Matlab test name cannot be empty")
endif()

# Escape MATLAB commands so they can be passed to add_test and to
# cmake -P script.
string(REPLACE "\"" "" custom_test_cmd_clean "${${prefix}_CUSTOM_TEST_COMMAND}")
string(REPLACE ";" "\\;" custom_test_cmd_clean "${custom_test_cmd_clean}")
string(REPLACE "\"" "" unittest_precmd_clean "${${prefix}_UNITTEST_PRECOMMAND}")
string(REPLACE ";" "\\;" unittest_precmd_clean "${unittest_precmd_clean}")
string(REPLACE " " "\ " unittest_precmd_clean "${unittest_precmd_clean}")
string(REPLACE ";" "\\;" additional_path_clean "${${prefix}_ADDITIONAL_PATH}")

add_test(NAME ${${prefix}_NAME}
COMMAND ${CMAKE_COMMAND}
"-Dtest_name=${${prefix}_NAME}"
"-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}"
"-Dtest_timeout=${${prefix}_TIMEOUT}"
"-Doutput_directory=${_matlab_temporary_folder}"
"-Dworking_directory=${${prefix}_WORKING_DIRECTORY}"
"-DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}"
"-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}"
"-DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}"
"-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}"
"-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}"
"-Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}"
-Dtest_name=${${prefix}_NAME}
-Dadditional_paths=${additional_path_clean}
-Dtest_timeout=${${prefix}_TIMEOUT}
-Doutput_directory=${_matlab_temporary_folder}
-Dworking_directory=${${prefix}_WORKING_DIRECTORY}
-DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}
-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}
-DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}
-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}
-Dcustom_Matlab_test_command=${custom_test_cmd_clean}
-Dcmd_to_run_before_test=${unittest_precmd_clean}
-P ${_FindMatlab_SELF_DIR}/MatlabTestsRedirect.cmake
${${prefix}_TEST_ARGS}
${${prefix}_UNPARSED_ARGUMENTS}
Expand Down

0 comments on commit 022ea30

Please sign in to comment.