-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathCMakeLists.txt
158 lines (129 loc) · 5.84 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# #############################################################################
# Copyright (c) 2016 - present Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# #############################################################################
# The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5
cmake_minimum_required( VERSION 3.5 )
# This should appear before the project command, because it does not
# use FORCE
if( WIN32 )
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH
"Install path prefix, prepended onto install directories" )
else( )
set( CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH
"Install path prefix, prepended onto install directories" )
endif( )
# Workaround for missing llvm cmake files in /opt/rocm/lib/cmake. Remove when this is fixed
list( APPEND CMAKE_PREFIX_PATH /opt/rocm/llvm /opt/rocm )
# This has to be initialized before the project() command appears
# Set the default of CMAKE_BUILD_TYPE to be release, unless user
# specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE
if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." )
endif()
project( rocfft LANGUAGES CXX )
# Control hip-clang use:
set( USE_HIP_CLANG OFF CACHE BOOL "Use hip-clang to build for amdgpu" )
if( USE_HIP_CLANG )
message( STATUS "Use hip-clang to build for amdgpu backend" )
set( HIP_PLATFORM "hip-clang" )
set( HIP_COMPILER "clang" )
else()
set( HIP_PLATFORM "hcc" )
endif()
# The nvcc backend can be used to compile for CUDA devices.
if( USE_CUDA )
# NB: CUDA has first-class since cmake 2.8; find_package(CUDA) is deprecated.
# See, eg, https://cmake.org/cmake/help/v3.12/module/FindCUDA.html
set( ENV{HIP_PLATFORM} "nvcc" )
set( HIP_PLATFORM "nvcc" )
set( CMAKE_C_COMPILE_OPTIONS_PIC
-Xcompiler ${CMAKE_C_COMPILE_OPTIONS_PIC} )
set( CMAKE_CXX_COMPILE_OPTIONS_PIC
-Xcompiler ${CMAKE_CXX_COMPILE_OPTIONS_PIC} )
set( CMAKE_SHARED_LIBRARY_C_FLAGS
-Xlinker ${CMAKE_SHARED_LIBRARY_C_FLAGS} )
set( CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Xlinker -fPIC" )
set( CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Xlinker -soname," )
set( CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Xlinker -soname," )
set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Xlinker -rpath," )
set( CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Xlinker -rpath," )
set( CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Xlinker -rpath," )
set( CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG "-Xlinker -rpath," )
endif( )
# This finds the rocm-cmake project, and installs it if not found
# rocm-cmake contains common cmake code for rocm projects to help
# setup and install
find_package( ROCM CONFIG )
include( ROCMSetupVersion )
include( ROCMCreatePackage )
include( ROCMInstallTargets )
include( ROCMPackageConfigHelpers )
include( ROCMInstallSymlinks )
# Using standardized versioning from rocm-cmake
set ( VERSION_STRING "1.0.9" )
rocm_setup_version( VERSION ${VERSION_STRING} )
# Append our library helper cmake path and the cmake path for hip (for
# convenience).
# Users may override HIP path by specifying their own in CMAKE_MODULE_PATH
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
# Enable verbose output
option( BUILD_VERBOSE "Output additional build information" OFF )
# Build the reference C++ kernel implementations.
option( BUILD_CPUREF "Build CPU reference debug code" OFF )
# BUILD_SHARED_LIBS is a cmake built-in; we make it an explicit option
# such that it shows in cmake-gui
option( BUILD_SHARED_LIBS "Build rocFFT as a shared library" ON )
option( WERROR "Treat warnings as errors" OFF )
if( WERROR )
set( WARNING_FLAGS -Wall -Wno-unused-function -Werror )
else( )
set( WARNING_FLAGS -Wall -Wno-unused-function )
endif( )
# force library install path to lib (CentOS 7 defaults to lib64)
set(CMAKE_INSTALL_LIBDIR "lib" CACHE INTERNAL
"Installation directory for libraries" FORCE)
# CMake list of machine targets
set( AMDGPU_TARGETS gfx803;gfx900:xnack-;gfx906:xnack-;gfx908:xnack- CACHE STRING
"List of specific machine types for library to target" )
# Find HCC/HIP dependencies
if( CMAKE_CXX_COMPILER MATCHES ".*/hcc$|.*/hipcc$" )
message( STATUS "Building with ROCm tools" )
find_package( hip REQUIRED CONFIG PATHS )
endif( )
# Hip headers required of all clients; clients use hip to allocate
# device memory
find_package( hip REQUIRED CONFIG PATHS )
add_subdirectory( library )
include( clients/cmake/build-options.cmake )
# Build clients of the library
if( BUILD_CLIENTS_ALL )
set( BUILD_CLIENTS_RIDER ON )
set( BUILD_CLIENTS_SAMPLES ON )
set( BUILD_CLIENTS_SELFTEST ON )
set( BUILD_CLIENTS_TESTS ON )
endif( )
if( BUILD_CLIENTS_SAMPLES
OR BUILD_CLIENTS_TESTS
OR BUILD_CLIENTS_SELFTEST
OR BUILD_CLIENTS_RIDER )
add_subdirectory( clients )
endif( )