2017-01-26 05:27:24 +08:00
# CMakeLists.txt file for unit testing OpenMP Library
include ( FindPythonInterp )
include ( CheckTypeSize )
if ( NOT PYTHONINTERP_FOUND )
libomptarget_warning_say ( "Could not find Python." )
libomptarget_warning_say ( "The check-libomptarget target will not be available!" )
return ( )
endif ( )
set ( LIBOMPTARGET_TEST_CFLAGS "" CACHE STRING
" E x t r a c o m p i l e r f l a g s t o s e n d t o t h e t e s t c o m p i l e r " )
2017-08-14 23:09:59 +08:00
if ( LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug )
set ( LIBOMPTARGET_DEBUG True )
else ( )
set ( LIBOMPTARGET_DEBUG False )
endif ( )
2017-01-26 05:27:24 +08:00
if ( ${ LIBOMPTARGET_STANDALONE_BUILD } )
# Make sure we can use the console pool for recent cmake and ninja > 1.5
if ( CMAKE_VERSION VERSION_LESS 3.1.20141117 )
set ( cmake_3_2_USES_TERMINAL )
else ( )
set ( cmake_3_2_USES_TERMINAL USES_TERMINAL )
endif ( )
set ( LIBOMPTARGET_TEST_C_COMPILER ${ CMAKE_C_COMPILER } CACHE STRING
" C c o m p i l e r t o u s e f o r t e s t i n g O p e n M P o f f l o a d i n g l i b r a r y " )
set ( LIBOMPTARGET_TEST_CXX_COMPILER ${ CMAKE_CXX_COMPILER } CACHE STRING
" C + + c o m p i l e r t o u s e f o r t e s t i n g O p e n M P o f f l o a d i n g l i b r a r y " )
set ( LIBOMPTARGET_TEST_OPENMP_FLAG -fopenmp CACHE STRING
" O p e n M P c o m p i l e r f l a g t o u s e f o r t e s t i n g O p e n M P o f f l o a d i n g l i b r a r y " )
2017-02-07 14:58:15 +08:00
find_program ( LIBOMPTARGET_LLVM_LIT_EXECUTABLE
N A M E S l l v m - l i t l i t . p y l i t
P A T H S $ { O P E N M P _ L L V M _ T O O L S _ D I R } )
if ( NOT LIBOMPTARGET_LLVM_LIT_EXECUTABLE )
2017-01-26 05:27:24 +08:00
libomptarget_say ( "Cannot find llvm-lit." )
2017-02-07 14:58:15 +08:00
libomptarget_say ( "Please put llvm-lit in your PATH or set LIBOMPTARGET_LLVM_LIT_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory" )
2017-01-26 05:27:24 +08:00
libomptarget_warning_say ( "The check-libomptarget target will not be available!" )
return ( )
endif ( )
2017-02-07 14:58:15 +08:00
find_program ( LIBOMPTARGET_FILECHECK_EXECUTABLE
N A M E S F i l e C h e c k
P A T H S $ { O P E N M P _ L L V M _ T O O L S _ D I R } )
if ( NOT LIBOMPTARGET_FILECHECK_EXECUTABLE )
2017-01-26 05:27:24 +08:00
libomptarget_say ( "Cannot find FileCheck." )
2017-02-07 14:58:15 +08:00
libomptarget_say ( "Please put FileCheck in your PATH or set LIBOMPTARGET_FILECHECK_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory" )
2017-01-26 05:27:24 +08:00
libomptarget_warning_say ( "The check-libomptarget target will not be available!" )
return ( )
endif ( )
# Set lit arguments
# The -j 1 lets the actual tests run with the entire machine.
# We have one test thread that spawns the tests serially. This allows
# Each test to use the entire machine.
set ( LIBOMPTARGET_LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail -j 1" )
if ( MSVC OR XCODE )
set ( LIBOMPTARGET_LIT_ARGS_DEFAULT "${LIBOMPTARGET_LIT_ARGS_DEFAULT} --no-progress-bar" )
endif ( )
set ( LIBOMPTARGET_LIT_ARGS "${LIBOMPTARGET_LIT_ARGS_DEFAULT}" CACHE STRING
" D e f a u l t o p t i o n s f o r l i t " )
separate_arguments ( LIBOMPTARGET_LIT_ARGS )
add_custom_target ( check-libomptarget
2017-02-07 14:58:15 +08:00
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { L I B O M P T A R G E T _ L L V M _ L I T _ E X E C U T A B L E } $ { L I B O M P T A R G E T _ L I T _ A R G S } $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
2017-01-26 05:27:24 +08:00
D E P E N D S o m p t a r g e t
C O M M E N T " R u n n i n g l i b o m p t a r g e t t e s t s "
$ { c m a k e _ 3 _ 2 _ U S E S _ T E R M I N A L }
)
set ( LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../../runtime/src" CACHE STRING
" P a t h t o f o l d e r c o n t a i n i n g o m p . h " )
set ( LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../../runtime/src" CACHE STRING
" P a t h t o f o l d e r c o n t a i n i n g l i b o m p . s o " )
else ( )
# LLVM source tree build, test just-built clang
if ( NOT MSVC )
set ( LIBOMPTARGET_TEST_C_COMPILER ${ LLVM_RUNTIME_OUTPUT_INTDIR } /clang )
set ( LIBOMPTARGET_TEST_CXX_COMPILER ${ LLVM_RUNTIME_OUTPUT_INTDIR } /clang++ )
2017-02-07 14:58:15 +08:00
set ( LIBOMPTARGET_FILECHECK_EXECUTABLE ${ LLVM_RUNTIME_OUTPUT_INTDIR } /FileCheck )
2017-01-26 05:27:24 +08:00
else ( )
libomptarget_warning_say ( "Not prepared to run tests on Windows systems." )
endif ( )
set ( LIBOMPTARGET_TEST_OPENMP_FLAG -fopenmp=libomp )
# Use add_lit_testsuite() from LLVM CMake. This also depends on OpenMP
# implementation because it uses omp.h.
add_lit_testsuite ( check-libomptarget
" R u n n i n g l i b o m p t a r g e t t e s t s "
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S o m p t a r g e t o m p
)
set ( LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMPTARGET_BINARY_DIR}/../runtime/src" )
endif ( )
# Configure the lit.site.cfg.in file
set ( AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!" )
configure_file ( lit.site.cfg.in lit.site.cfg @ONLY )