xref: /llvm-project/openmp/runtime/test/CMakeLists.txt (revision 36d4e4c9b5f6cd0577b6029055b825caaec2dd11)
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
27list(APPEND OPENMP_TEST_COMPILER_FEATURE_LIST "${LIBOMP_ARCH}")
28update_test_compiler_features()
29
30pythonize_bool(LIBOMP_USE_HWLOC)
31pythonize_bool(LIBOMP_OMPT_SUPPORT)
32pythonize_bool(LIBOMP_OMPT_OPTIONAL)
33pythonize_bool(LIBOMP_OMPX_TASKGRAPH)
34pythonize_bool(LIBOMP_HAVE_LIBM)
35pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
36pythonize_bool(OPENMP_STANDALONE_BUILD)
37pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS)
38pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMP_H)
39
40add_library(ompt-print-callback INTERFACE)
41target_include_directories(ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ompt)
42
43
44add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp)
45# Add target check-ompt, but make sure to not add the tests twice to check-openmp.
46add_openmp_testsuite(check-ompt "Running OMPT tests" ${CMAKE_CURRENT_BINARY_DIR}/ompt EXCLUDE_FROM_CHECK_ALL DEPENDS omp)
47
48# Configure the lit.site.cfg.in file
49set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
50configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
51