150
|
1 ##===----------------------------------------------------------------------===##
|
|
2 #
|
|
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
4 # See https://llvm.org/LICENSE.txt for license information.
|
|
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
6 #
|
|
7 ##===----------------------------------------------------------------------===##
|
|
8 #
|
|
9 # Build offloading library and related plugins.
|
|
10 #
|
|
11 ##===----------------------------------------------------------------------===##
|
|
12
|
|
13 if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
14 message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
|
|
15 endif()
|
|
16
|
|
17 # Add cmake directory to search for custom cmake functions.
|
|
18 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
|
|
19
|
|
20 if(OPENMP_STANDALONE_BUILD)
|
|
21 # Build all libraries into a common place so that tests can find them.
|
|
22 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
23 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
24 endif()
|
|
25
|
|
26 # Message utilities.
|
|
27 include(LibomptargetUtils)
|
|
28
|
|
29 # Get dependencies for the different components of the project.
|
|
30 include(LibomptargetGetDependencies)
|
|
31
|
|
32 # This is a list of all the targets that are supported/tested right now.
|
|
33 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu")
|
|
34 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu")
|
|
35 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64-ibm-linux-gnu")
|
|
36 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} x86_64-pc-linux-gnu")
|
|
37 set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda")
|
|
38
|
|
39 # Once the plugins for the different targets are validated, they will be added to
|
|
40 # the list of supported targets in the current system.
|
|
41 set (LIBOMPTARGET_SYSTEM_TARGETS "")
|
|
42 set (LIBOMPTARGET_TESTED_PLUGINS "")
|
|
43
|
|
44 # Check whether using debug mode. In debug mode, allow dumping progress
|
|
45 # messages at runtime by default. Otherwise, it can be enabled
|
|
46 # independently using the LIBOMPTARGET_ENABLE_DEBUG option.
|
|
47 string( TOLOWER "${CMAKE_BUILD_TYPE}" LIBOMPTARGET_CMAKE_BUILD_TYPE)
|
|
48 if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
|
|
49 option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" ON)
|
|
50 else()
|
|
51 option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" OFF)
|
|
52 endif()
|
|
53 if(LIBOMPTARGET_ENABLE_DEBUG)
|
|
54 add_definitions(-DOMPTARGET_DEBUG)
|
|
55 endif()
|
|
56
|
|
57 include_directories(include)
|
|
58
|
|
59 # Build target agnostic offloading library.
|
|
60 add_subdirectory(src)
|
|
61
|
|
62 # Retrieve the path to the resulting library so that it can be used for
|
|
63 # testing.
|
|
64 get_target_property(LIBOMPTARGET_LIBRARY_DIR omptarget LIBRARY_OUTPUT_DIRECTORY)
|
|
65 if(NOT LIBOMPTARGET_LIBRARY_DIR)
|
|
66 set(LIBOMPTARGET_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
67 endif()
|
|
68
|
|
69 # Definitions for testing, for reuse when testing libomptarget-nvptx.
|
|
70 if(OPENMP_STANDALONE_BUILD)
|
|
71 set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" CACHE STRING
|
|
72 "Path to folder containing omp.h")
|
|
73 set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" CACHE STRING
|
|
74 "Path to folder containing libomp.so")
|
|
75 else()
|
|
76 set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src")
|
|
77 endif()
|
|
78
|
|
79
|
|
80 # Build offloading plugins and device RTLs if they are available.
|
|
81 add_subdirectory(plugins)
|
|
82 add_subdirectory(deviceRTLs)
|
|
83
|
|
84 # Add tests.
|
|
85 add_subdirectory(test)
|