Debian Codegraph @

openmp/runtime/test/CMakeLists.txt

raw
1 # CMakeLists.txt file for unit testing OpenMP host runtime library.
2 include(CheckFunctionExists)
3 include(CheckLibraryExists)
4
5 # Some tests use math functions
6 check_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
11 check_function_exists(__atomic_load_1 LIBOMP_HAVE_BUILTIN_ATOMIC)
12 if(NOT LIBOMP_HAVE_BUILTIN_ATOMIC)
13 check_library_exists(atomic __atomic_load_1 "" LIBOMP_HAVE_LIBATOMIC)
14 else()
15 # not needed
16 set(LIBOMP_HAVE_LIBATOMIC 0)
17 endif()
18
19 macro(pythonize_bool var)
20 if (${var})
21 set(${var} True)
22 else()
23 set(${var} False)
24 endif()
25 endmacro()
26
27 list(APPEND OPENMP_TEST_COMPILER_FEATURE_LIST "${LIBOMP_ARCH}")
28 update_test_compiler_features()
29
30 pythonize_bool(LIBOMP_USE_HWLOC)
31 pythonize_bool(LIBOMP_OMPT_SUPPORT)
32 pythonize_bool(LIBOMP_OMPT_OPTIONAL)
33 pythonize_bool(LIBOMP_OMPX_TASKGRAPH)
34 pythonize_bool(LIBOMP_HAVE_LIBM)
35 pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
36 pythonize_bool(OPENMP_STANDALONE_BUILD)
37 pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTER_FLAGS)
38 pythonize_bool(OPENMP_TEST_COMPILER_HAS_OMP_H)
39
40 add_library(ompt-print-callback INTERFACE)
41 target_include_directories(ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ompt)
42
43
44 add_custom_target(libomp-test-depends)
45 add_dependencies(libomp-test-depends omp)
46 if (LLVM_RUNTIMES_BUILD AND OPENMP_TEST_Fortran_COMPILER AND "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
47 add_dependencies(libomp-test-depends flang-rt)
48 endif ()
49
50 add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS libomp-test-depends)
51 # Add target check-ompt, but make sure to not add the tests twice to check-openmp.
52 add_openmp_testsuite(check-ompt "Running OMPT tests" ${CMAKE_CURRENT_BINARY_DIR}/ompt EXCLUDE_FROM_CHECK_ALL DEPENDS omp)
53
54 # Configure the lit.site.cfg.in file
55 set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
56 configure_file(lit.site.cfg.in lit.site.cfg @ONLY)