1 ##===----------------------------------------------------------------------===##
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
7 ##===----------------------------------------------------------------------===##
9 # Build offloading library and related plugins.
11 ##===----------------------------------------------------------------------===##
13 if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
14 message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
17 # Add cmake directory to search for custom cmake functions.
18 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
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})
27 include(LibomptargetUtils)
29 # Get dependencies for the different components of the project.
30 include(LibomptargetGetDependencies)
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")
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 "")
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)
51 option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" OFF)
53 if(LIBOMPTARGET_ENABLE_DEBUG)
54 add_definitions(-DOMPTARGET_DEBUG)
57 include_directories(include)
59 # Build target agnostic offloading library.
62 # Retrieve the path to the resulting library so that it can be used for
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})
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")
76 set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src")
80 # Build offloading plugins and device RTLs if they are available.
81 add_subdirectory(plugins)
82 add_subdirectory(deviceRTLs)
85 add_subdirectory(test)