1# CMakeLists.txt file for unit testing OpenMP host runtime library.
2include(CheckFunctionExists)
3include(CheckLibraryExists)
4
5# Some tests use math functions
6check_library_exists(m sqrt "" LIBOMP_HAVE_LIBM)
7# When using libgcc, -latomic may be needed for atomics
8# (but when using compiler-rt, the atomics will be built-in)
9# Note: we can not check for __atomic_load because clang treats it
10# as special built-in and that breaks CMake checks
11check_function_exists(__atomic_load_1 LIBOMP_HAVE_BUILTIN_ATOMIC)
12if(NOT LIBOMP_HAVE_BUILTIN_ATOMIC)
13  check_library_exists(atomic __atomic_load_1 "" LIBOMP_HAVE_LIBATOMIC)
14else()
15  # not needed
16  set(LIBOMP_HAVE_LIBATOMIC 0)
17endif()
18
19macro(pythonize_bool var)
20  if (${var})
21    set(${var} True)
22  else()
23    set(${var} False)
24  endif()
25endmacro()
26
27pythonize_bool(LIBOMP_USE_HWLOC)
28pythonize_bool(LIBOMP_OMPT_SUPPORT)
29pythonize_bool(LIBOMP_OMPT_OPTIONAL)
30pythonize_bool(LIBOMP_HAVE_LIBM)
31pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
32
33add_library(ompt-print-callback INTERFACE)
34target_include_directories(ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ompt)
35
36
37add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp)
38# Add target check-ompt, but make sure to not add the tests twice to check-openmp.
39add_openmp_testsuite(check-ompt "Running OMPT tests" ${CMAKE_CURRENT_BINARY_DIR}/ompt EXCLUDE_FROM_CHECK_ALL DEPENDS omp)
40
41# Configure the lit.site.cfg.in file
42set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
43configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
44