#set them in the PATH to run tests. The following appends the
#path of a target dependency.
#
- #NOTE: get_target_property LOCATION is being deprecated as of
- #CMake 3.2.0, which just prints a warning & notes that this
- #functionality will be removed in the future. Leave it here for
- #now until someone can figure out how to do this in Windows.
- foreach(target ${test_name} ${VOLK_TEST_TARGET_DEPS})
- get_target_property(location "${target}" LOCATION)
- if(location)
- get_filename_component(path ${location} PATH)
- string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path})
- list(APPEND libpath ${path})
- endif(location)
- endforeach(target)
-
- list(APPEND libpath ${DLL_PATHS} "%PATH%")
+ #create a list of target directories to be determined by the
+ #"add_test" command, via the $<FOO:BAR> operator; make sure the
+ #test's directory is first, since it ($1) is prepended to PATH.
+ unset(TARGET_DIR_LIST)
+ foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS})
+ list(APPEND TARGET_DIR_LIST "$<TARGET_FILE_DIR:${target}>")
+ endforeach()
+ #replace list separator with the path separator (escaped)
+ string(REPLACE ";" "\\\\;" TARGET_DIR_LIST "${TARGET_DIR_LIST}")
+
+ #add command line argument (TARGET_DIR_LIST) to path and append current path
+ list(INSERT libpath 0 "%1")
+ list(APPEND libpath "%PATH%")
#replace list separator with the path separator (escaped)
string(REPLACE ";" "\\;" libpath "${libpath}")
file(APPEND ${bat_file} "SET ${environ}\n")
endforeach(environ)
+ set(VOLK_TEST_ARGS "${test_name}")
+
#redo the test args to have a space between each
string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}")
#finally: append the test name to execute
- file(APPEND ${bat_file} ${test_name} " " ${VOLK_TEST_ARGS} "\n")
+ file(APPEND ${bat_file} "${executable_name} ${VOLK_TEST_ARGS}\n")
file(APPEND ${bat_file} "\n")
- add_test(${test_name} ${bat_file})
+ add_test(NAME qa_${test_name}
+ COMMAND ${bat_file} ${TARGET_DIR_LIST}
+ )
endif(WIN32)
endfunction(VOLK_ADD_TEST)