| include(CMakeParseArguments) |
| |
| # springbok_test() |
| # |
| # A wrapper for the iree_cc_binary to attach lit run files to an executable |
| # Parameters: |
| # NAME: Name of target. |
| # SRCS: List of source files for the binary |
| # DEPS: List of other libraries to be linked in to the binary targets |
| # COPTS: List of public defines |
| # LINKOPTS: List of link options |
| # TESTFILES: List of lit test run files |
| # |
| # Examples: |
| # springbok_test( |
| # NAME |
| # simple_int_vec_mul_emitc_static |
| # SRCS |
| # "int_vec.c" |
| # DEPS |
| # ::simple_int_mul_c_module_static_c |
| # ::simple_int_mul_c_module_static_emitc |
| # samples::util::util |
| # COPTS |
| # "-DBUILD_EMITC" |
| # TESTFILES |
| # "simple_test.run" |
| # ) |
| function(springbok_test) |
| cmake_parse_arguments( |
| _RULE |
| "" |
| "NAME" |
| "SRCS;COPTS;LINKOPTS;DEPS;TESTFILES" |
| ${ARGN} |
| ) |
| |
| iree_cc_binary( |
| NAME |
| ${_RULE_NAME} |
| SRCS |
| ${_RULE_SRCS} |
| DEPS |
| ${_RULE_DEPS} |
| COPTS |
| ${_RULE_COPTS} |
| LINKOPTS |
| ${_RULE_LINKOPTS} |
| ) |
| if(NOT _RULE_TESTFILES) |
| return() |
| endif() |
| |
| iree_package_name(_PACKAGE_NAME) |
| foreach(_FILE ${_RULE_TESTFILES}) |
| get_filename_component(_FILE_PATH ${_FILE} REALPATH) |
| get_filename_component(_FILE_NAME ${_FILE_PATH} NAME) |
| set(_FILE_TARGET ${_PACKAGE_NAME}_${_FILE_NAME}) |
| if(NOT TARGET ${_FILE_TARGET}) |
| add_custom_target( |
| ${_FILE_TARGET} |
| COMMAND ${CMAKE_COMMAND} -E copy ${_FILE_PATH} |
| ${CMAKE_CURRENT_BINARY_DIR}/${_FILE_NAME} |
| BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${_FILE_NAME} |
| COMMENT "Copy lit run file ${_FILE_NAME}" |
| VERBATIM |
| ) |
| endif() |
| |
| add_dependencies(${_PACKAGE_NAME}_${_RULE_NAME} ${_FILE_TARGET}) |
| endforeach() |
| endfunction() |