[test-suite] r259908 - cmake: Factor out common code
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 11:30:07 PST 2016
Author: matze
Date: Fri Feb 5 13:30:06 2016
New Revision: 259908
URL: http://llvm.org/viewvc/llvm-project?rev=259908&view=rev
Log:
cmake: Factor out common code
Modified:
test-suite/trunk/cmake/modules/SingleMultiSource.cmake
Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=259908&r1=259907&r2=259908&view=diff
==============================================================================
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Fri Feb 5 13:30:06 2016
@@ -121,6 +121,21 @@ function(llvm_add_test name exename)
CONTENT "${TESTSCRIPT}")
endfunction()
+macro(test_suite_add_executable name mainsource)
+ list(FIND PROGRAMS_TO_SKIP ${name} name_idx)
+ # Should we skip this?
+ if(${name_idx} EQUAL -1)
+ get_unique_exe_name(source_exename ${mainsource})
+ add_executable(${source_exename} ${ARGN})
+ append_cflags(${source_exename} CFLAGS)
+ append_cflags(${source_exename} CPPFLAGS)
+ append_cflags(${source_exename} CXXFLAGS)
+ target_link_libraries(${source_exename} ${LDFLAGS})
+ llvm_add_test(${name} ${source_exename})
+ add_dependencies(${source_exename} timeit-host timeit-target fpcmp-host)
+ endif()
+endmacro()
+
# llvm_singlesource - configure the current directory as a SingleSource subdirectory -
# i.e. every file in *.{c,cpp,cc} is treated as its own test.
macro(llvm_singlesource)
@@ -130,18 +145,7 @@ macro(llvm_singlesource)
string(REGEX REPLACE ".[cp]+$" "" path ${source})
string(REGEX REPLACE ".*/" "" name ${path})
- # Should we skip this?
- list(FIND PROGRAMS_TO_SKIP ${name} name_idx)
- if(${name_idx} EQUAL -1)
- get_unique_exe_name(source_exename ${source})
- add_executable(${source_exename} ${source})
- append_cflags(${source_exename} CFLAGS)
- append_cflags(${source_exename} CPPFLAGS)
- append_cflags(${source_exename} CXXFLAGS)
- target_link_libraries(${source_exename} ${LDFLAGS})
- llvm_add_test(${name} ${source_exename})
- add_dependencies(${source_exename} timeit-host timeit-target fpcmp-host)
- endif()
+ test_suite_add_executable(${name} ${source} ${source})
endforeach()
endmacro()
@@ -157,20 +161,9 @@ macro(llvm_multisource)
list(LENGTH sources sources_len)
if(sources_len GREATER 0 AND DEFINED PROG)
- # Should we skip this?
- list(FIND PROGRAMS_TO_SKIP ${PROG} name_idx)
- if(${name_idx} EQUAL -1)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
- get_unique_exe_name(source_exename "${PROG}.c")
- add_executable(${source_exename} ${sources})
- append_cflags(${source_exename} CFLAGS)
- append_cflags(${source_exename} CPPFLAGS)
- append_cflags(${source_exename} CXXFLAGS)
- target_link_libraries(${source_exename} ${LDFLAGS})
- llvm_add_test(${PROG} ${source_exename})
- add_dependencies(${source_exename} timeit-host timeit-target fpcmp-host)
- endif()
+ test_suite_add_executable(${PROG} "${PROG}.c" ${sources})
endif()
endmacro()
More information about the llvm-commits
mailing list