From 85b83e06cfdd7f17c1ffc0f02015da773402acd2 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 17 May 2017 11:40:24 -0400
Subject: [PATCH] P4 to Git Change 1410629 by lmoriche@lmoriche_palamida on
2017/05/17 11:27:06
SWDEV-102733 - [OCL-LC-ROCm] Cmake build Write CMakeLists.txt to enable building with and without the DK environment
- Add FindROCR.cmake, and use find_package() to locate the ROCR
Affected files ...
... //depot/stg/opencl/drivers/opencl/CMakeLists.txt#8 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/CMakeLists.txt#5 edit
... //depot/stg/opencl/drivers/opencl/cmake/modules/FindROCR.cmake#1 add
... //depot/stg/opencl/drivers/opencl/runtime/CMakeLists.txt#3 edit
---
rocclr/CMakeLists.txt | 8 ++++++++
rocclr/cmake/modules/FindROCR.cmake | 23 +++++++++++++++++++++++
rocclr/runtime/CMakeLists.txt | 2 +-
3 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 rocclr/cmake/modules/FindROCR.cmake
diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt
index b54fd4298b..416cf0da8c 100644
--- a/rocclr/CMakeLists.txt
+++ b/rocclr/CMakeLists.txt
@@ -7,6 +7,13 @@ endif()
project(OpenCL-ROCm)
+# Add path for custom modules
+set(CMAKE_MODULE_PATH
+ ${CMAKE_MODULE_PATH}
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+ )
+
set(LLVM_INCLUDE_TESTS CACHE BOOL OFF)
set(LLVM_TARGETS_TO_BUILD "AMDGPU" CACHE STRING "")
set(LLVM_ENABLE_PROJECTS CACHE STRING "clang")
@@ -40,5 +47,6 @@ add_subdirectory(compiler/lib/loaders/elf/utils/libelf)
add_subdirectory(tools/bc2h)
+find_package(ROCR REQUIRED)
add_subdirectory(runtime)
add_subdirectory(api/opencl/amdocl)
diff --git a/rocclr/cmake/modules/FindROCR.cmake b/rocclr/cmake/modules/FindROCR.cmake
new file mode 100644
index 0000000000..a771ce0043
--- /dev/null
+++ b/rocclr/cmake/modules/FindROCR.cmake
@@ -0,0 +1,23 @@
+# - Try to find the ROCm Runtime.
+# Once done this will define
+# ROCR_FOUND - System has the ROCR installed
+# ROCR_INCLUDE_DIRS - The ROCR include directories
+# ROCR_LIBRARIES - The libraries needed to use the ROCR
+
+find_path(ROCR_INCLUDE_DIR hsa.h
+ HINTS /opt/rocm/include /opt/rocm/hsa/include
+ PATH_SUFFIXES hsa)
+
+find_library(ROCR_LIBRARY libhsa-runtime64
+ HINTS /opt/rocm/lib /opt/rocm/hsa/lib)
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set ROCR_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(ROCR DEFAULT_MSG
+ ROCR_LIBRARY ROCR_INCLUDE_DIR)
+
+mark_as_advanced(ROCR_INCLUDE_DIR ROCR_LIBRARY)
+
+set(ROCR_LIBRARIES ${ROCR_LIBRARY})
+set(ROCR_INCLUDE_DIRS ${ROCR_INCLUDE_DIR})
diff --git a/rocclr/runtime/CMakeLists.txt b/rocclr/runtime/CMakeLists.txt
index 728d8cd01d..4076bd318d 100644
--- a/rocclr/runtime/CMakeLists.txt
+++ b/rocclr/runtime/CMakeLists.txt
@@ -2,7 +2,7 @@ set(CMAKE_CXX_FLAGS "-std=c++11")
add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER)
-include_directories(/opt/rocm/include/hsa)
+include_directories(${ROCR_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/runtime)
include_directories(${CMAKE_SOURCE_DIR}/api/opencl)