2017-01-26 05:27:24 +08:00
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
#
|
2019-01-19 18:56:40 +08:00
|
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-01-26 05:27:24 +08:00
|
|
|
#
|
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
#
|
2017-12-07 05:59:04 +08:00
|
|
|
# Build offloading library and related plugins.
|
2017-01-26 05:27:24 +08:00
|
|
|
#
|
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
|
2017-11-30 03:31:43 +08:00
|
|
|
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
|
|
|
|
endif()
|
2017-01-26 05:27:24 +08:00
|
|
|
|
|
|
|
# Add cmake directory to search for custom cmake functions.
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
|
|
|
|
|
2017-11-30 03:31:43 +08:00
|
|
|
if(OPENMP_STANDALONE_BUILD)
|
2017-11-11 21:59:45 +08:00
|
|
|
# Build all libraries into a common place so that tests can find them.
|
2018-09-28 23:05:43 +08:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
2017-11-11 21:59:45 +08:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
2017-01-26 05:27:24 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Message utilities.
|
|
|
|
include(LibomptargetUtils)
|
|
|
|
|
|
|
|
# Get dependencies for the different components of the project.
|
|
|
|
include(LibomptargetGetDependencies)
|
|
|
|
|
|
|
|
# This is a list of all the targets that are supported/tested right now.
|
2017-03-07 05:00:07 +08:00
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu")
|
2017-01-26 05:27:24 +08:00
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64-ibm-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} x86_64-pc-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda")
|
|
|
|
|
|
|
|
# Once the plugins for the different targets are validated, they will be added to
|
|
|
|
# the list of supported targets in the current system.
|
|
|
|
set (LIBOMPTARGET_SYSTEM_TARGETS "")
|
|
|
|
|
2019-03-26 23:19:15 +08:00
|
|
|
# Check whether using debug mode. In debug mode, allow dumping progress
|
|
|
|
# messages at runtime by default. Otherwise, it can be enabled
|
|
|
|
# independently using the LIBOMPTARGET_ENABLE_DEBUG option.
|
2017-11-30 03:31:48 +08:00
|
|
|
string( TOLOWER "${CMAKE_BUILD_TYPE}" LIBOMPTARGET_CMAKE_BUILD_TYPE)
|
|
|
|
if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
|
2019-03-26 23:19:15 +08:00
|
|
|
option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" ON)
|
|
|
|
else()
|
|
|
|
option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" OFF)
|
|
|
|
endif()
|
|
|
|
if(LIBOMPTARGET_ENABLE_DEBUG)
|
2017-11-30 03:31:48 +08:00
|
|
|
add_definitions(-DOMPTARGET_DEBUG)
|
|
|
|
endif()
|
|
|
|
|
2017-12-07 05:59:04 +08:00
|
|
|
include_directories(include)
|
2017-11-30 03:31:48 +08:00
|
|
|
|
2017-12-07 05:59:04 +08:00
|
|
|
# Build target agnostic offloading library.
|
|
|
|
add_subdirectory(src)
|
2017-11-30 03:31:48 +08:00
|
|
|
|
|
|
|
# Retrieve the path to the resulting library so that it can be used for
|
|
|
|
# testing.
|
|
|
|
get_target_property(LIBOMPTARGET_LIBRARY_DIR omptarget LIBRARY_OUTPUT_DIRECTORY)
|
|
|
|
if(NOT LIBOMPTARGET_LIBRARY_DIR)
|
|
|
|
set(LIBOMPTARGET_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
endif()
|
|
|
|
|
2018-09-28 23:05:43 +08:00
|
|
|
# Definitions for testing, for reuse when testing libomptarget-nvptx.
|
|
|
|
if(OPENMP_STANDALONE_BUILD)
|
|
|
|
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" CACHE STRING
|
|
|
|
"Path to folder containing omp.h")
|
|
|
|
set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src" CACHE STRING
|
|
|
|
"Path to folder containing libomp.so")
|
|
|
|
else()
|
|
|
|
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../runtime/src")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-11-30 03:31:48 +08:00
|
|
|
# Build offloading plugins and device RTLs if they are available.
|
|
|
|
add_subdirectory(plugins)
|
2018-01-29 21:59:35 +08:00
|
|
|
add_subdirectory(deviceRTLs)
|
2017-11-30 03:31:48 +08:00
|
|
|
|
|
|
|
# Add tests.
|
|
|
|
add_subdirectory(test)
|