[PATCH] D20221: [test-suite] parameterization of llvm_{multi, single}source()
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 11:35:09 PDT 2016
tra updated this revision to Diff 69593.
tra added a comment.
Rebased on top of recent HEAD.
https://reviews.llvm.org/D20221
Files:
cmake/modules/SingleMultiSource.cmake
Index: cmake/modules/SingleMultiSource.cmake
===================================================================
--- cmake/modules/SingleMultiSource.cmake
+++ cmake/modules/SingleMultiSource.cmake
@@ -125,30 +125,37 @@
add_dependencies(${executable} timeit-host fpcmp-host)
endmacro()
-macro(test_suite_add_executable name mainsource)
- list(FIND PROGRAMS_TO_SKIP ${name} name_idx)
+macro(test_suite_add_executable)
+ cmake_parse_arguments(_ARG "" "PROG;MAIN" "SOURCES;CFLAGS;CPPFLAGS;CXXFLAGS;LDFLAGS;LIBS;DEPS" ${ARGN})
+ list(FIND PROGRAMS_TO_SKIP ${_ARG_PROG} name_idx)
# Should we skip this?
if(${name_idx} EQUAL -1)
- get_unique_exe_name(executable ${mainsource})
- add_executable(${executable} ${ARGN})
- append_compile_flags(${executable} ${CFLAGS})
- append_compile_flags(${executable} ${CPPFLAGS})
- append_compile_flags(${executable} ${CXXFLAGS})
+ get_unique_exe_name(executable ${_ARG_MAIN})
+ add_executable(${executable} ${_ARG_SOURCES})
+ append_compile_flags(${executable} ${CFLAGS} ${_ARG_CFLAGS})
+ append_compile_flags(${executable} ${CPPFLAGS} ${_ARG_CPPFLAGS})
+ append_compile_flags(${executable} ${CXXFLAGS} ${_ARG_CXXFLAGS})
# Note that we cannot use target_link_libraries() here because that one
# only interprets inputs starting with '-' as flags.
- append_link_flags(${executable} ${LDFLAGS})
+ append_link_flags(${executable} ${LDFLAGS} ${_ARG_LDFLAGS})
+ if (_ARG_LIBS)
+ target_link_libraries(${executable} ${_ARG_LIBS})
+ endif()
set(executable_path ${CMAKE_CURRENT_BINARY_DIR}/${executable})
if (TEST_SUITE_PROFILE_USE)
append_compile_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)
append_link_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)
endif()
+ if (${_ARG_DEPS})
+ add_dependencies(${executable} ${_ARG_DEPS})
+ endif()
set_property(GLOBAL APPEND PROPERTY TEST_SUITE_TARGETS ${executable})
# Fall back to old style involving RUN_OPTIONS and STDIN_FILENAME if
# llvm_test_run() was not called yet.
if(NOT TESTSCRIPT)
- llvm_test_traditional(${executable_path}.test ${executable_path} ${name})
+ llvm_test_traditional(${executable_path}.test ${executable_path} ${_ARG_PROG})
else()
llvm_add_test(${executable_path}.test ${executable_path})
endif()
@@ -165,24 +172,30 @@
string(REGEX REPLACE ".[cp]+$" "" path ${source})
string(REGEX REPLACE ".*/" "" name ${path})
- test_suite_add_executable(${name} ${source} ${source})
+ test_suite_add_executable(PROG "${name}" MAIN "${source}" SOURCES ${source} ${ARGN})
endforeach()
endmacro()
# Configure the current directory as a MultiSource subdirectory - i.e. there is
# one test and it consists of all sources in the directory (or a curated list,
# if Source is defined).
macro(llvm_multisource)
- if(DEFINED Source)
- set(sources ${Source})
+ cmake_parse_arguments(_ARG "" "PROG" "SOURCES" ${ARGN})
+ if(DEFINED Source OR _ARG_SOURCES)
+ set(sources ${Source} ${_ARG_SOURCES})
else()
file(GLOB sources *.c *.cpp *.cc)
endif()
list(LENGTH sources sources_len)
-
- if(sources_len GREATER 0 AND DEFINED PROG)
+ # PROG passed as an argument has higher precedence.
+ if (_ARG_PROG)
+ set(_PROG ${_ARG_PROG})
+ elseif(DEFINED PROG)
+ set(_PROG ${PROG})
+ endif()
+ if(sources_len GREATER 0 AND _PROG)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
- test_suite_add_executable(${PROG} "${PROG}.c" ${sources})
+ test_suite_add_executable(PROG ${_PROG} MAIN "${_PROG}.c" SOURCES ${sources} ${ARGN})
endif()
endmacro()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20221.69593.patch
Type: text/x-patch
Size: 3732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160829/9cb40603/attachment.bin>
More information about the llvm-commits
mailing list