2015-09-22 04:41:31 +08:00
|
|
|
# CMakeLists.txt file for unit testing OpenMP Library
|
|
|
|
include(FindPythonInterp)
|
|
|
|
include(CheckTypeSize)
|
2015-12-01 04:02:59 +08:00
|
|
|
|
2015-09-22 04:41:31 +08:00
|
|
|
if(NOT PYTHONINTERP_FOUND)
|
|
|
|
libomp_warning_say("Could not find Python.")
|
|
|
|
libomp_warning_say("The check-libomp target will not be available!")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2015-12-01 04:02:59 +08:00
|
|
|
macro(pythonize_bool var)
|
|
|
|
if (${var})
|
|
|
|
set(${var} True)
|
|
|
|
else()
|
|
|
|
set(${var} False)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
pythonize_bool(LIBOMP_USE_HWLOC)
|
|
|
|
|
2015-09-22 04:41:31 +08:00
|
|
|
set(LIBOMP_TEST_CFLAGS "" CACHE STRING
|
|
|
|
"Extra compiler flags to send to the test compiler")
|
|
|
|
|
|
|
|
if(${LIBOMP_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(LIBOMP_TEST_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
|
|
|
|
"Compiler to use for testing OpenMP library")
|
|
|
|
set(LIBOMP_TEST_OPENMP_FLAG -fopenmp CACHE STRING
|
|
|
|
"OpenMP compiler flag to use for testing OpenMP library")
|
|
|
|
set(LIBOMP_LLVM_LIT_EXECUTABLE "" CACHE STRING
|
|
|
|
"Path to llvm-lit")
|
2016-02-05 15:00:13 +08:00
|
|
|
find_program(LIT_EXECUTABLE
|
|
|
|
NAMES llvm-lit
|
|
|
|
HINTS ${LIBOMP_LLVM_LIT_EXECUTABLE}
|
|
|
|
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
2015-09-22 04:41:31 +08:00
|
|
|
if(NOT LIT_EXECUTABLE)
|
|
|
|
libomp_say("Cannot find llvm-lit.")
|
2016-02-05 15:00:13 +08:00
|
|
|
libomp_say("Please put llvm-lit in your PATH, set LIBOMP_LLVM_LIT_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory")
|
2015-09-22 04:41:31 +08:00
|
|
|
libomp_warning_say("The check-libomp 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.
|
2015-11-02 21:43:32 +08:00
|
|
|
set(LIBOMP_LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail")
|
2015-09-22 04:41:31 +08:00
|
|
|
if(MSVC OR XCODE)
|
|
|
|
set(LIBOMP_LIT_ARGS_DEFAULT "${LIBOMP_LIT_ARGS_DEFAULT} --no-progress-bar")
|
|
|
|
endif()
|
|
|
|
set(LIBOMP_LIT_ARGS "${LIBOMP_LIT_ARGS_DEFAULT}" CACHE STRING
|
|
|
|
"Default options for lit")
|
|
|
|
separate_arguments(LIBOMP_LIT_ARGS)
|
|
|
|
add_custom_target(check-libomp
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${LIT_EXECUTABLE} ${LIBOMP_LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS omp
|
|
|
|
COMMENT "Running libomp tests"
|
|
|
|
${cmake_3_2_USES_TERMINAL}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
# LLVM source tree build, test just-built clang
|
|
|
|
if(NOT MSVC)
|
|
|
|
set(LIBOMP_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
|
|
|
|
endif()
|
|
|
|
set(LIBOMP_TEST_OPENMP_FLAG -fopenmp=libomp)
|
|
|
|
# Use add_lit_testsuite() from LLVM CMake.
|
2015-11-02 21:43:32 +08:00
|
|
|
add_lit_testsuite(check-libomp
|
2015-09-22 04:41:31 +08:00
|
|
|
"Running libomp tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
2015-11-02 21:43:32 +08:00
|
|
|
DEPENDS clang clang-headers FileCheck omp
|
2015-09-22 04:41:31 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Configure the lit.site.cfg.in file
|
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
|
|
|
|
configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
|
|
|
|
|