forked from google/clspv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
114 lines (88 loc) · 3.73 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
# Copyright 2017 The Clspv Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.4.3)
# If we are the parent CMakeLists.txt, need to declare a project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(clspv)
endif()
# Check if required third-party dependencies exist.
macro(use_component path)
if(NOT IS_DIRECTORY ${path})
message(FATAL_ERROR "Required component '${path}' does not exist! Please run 'python utils/fetch_sources.py' in the '${CMAKE_CURRENT_SOURCE_DIR}' folder.")
endif()
endmacro()
option(SKIP_CLSPV_TOOLS_INSTALL "Skip installation" ${SKIP_CLSPV_TOOLS_INSTALL})
if(NOT ${SKIP_CLSPV_TOOLS_INSTALL})
set(ENABLE_CLSPV_TOOLS_INSTALL ON)
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
# GCC 7.3 complains about LLVM code: RetryAfterSignal in lib/Support/Process.cpp
# Silence that warning for now.
# TODO(dneto): Upgrade to newer LLVM to avoid this issue.
add_compile_options("-Wno-noexcept-type")
endif()
use_component(${CMAKE_CURRENT_SOURCE_DIR}/third_party/clang)
use_component(${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm)
use_component(${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Headers)
use_component(${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Tools)
set(CLSPV_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CLSPV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
${CLSPV_BINARY_DIR}/include
)
# First tell LLVM where to find clang.
set(LLVM_EXTERNAL_CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/clang)
# Then pull in LLVM for building.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm EXCLUDE_FROM_ALL)
set(SPIRV_HEADERS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Headers)
set(SPIRV_HEADERS_INCLUDE_DIRS
${SPIRV_HEADERS_SOURCE_DIR}/include/
)
set(LLVM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm)
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm)
set(LLVM_INCLUDE_DIRS
${LLVM_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm/include
)
set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/clang)
set(CLANG_INCLUDE_DIRS
${CLANG_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm/tools/clang/include
)
# First tell SPIR-V Tools where to find SPIR-V Headers
set(SPIRV-Headers_SOURCE_DIR ${SPIRV_HEADERS_SOURCE_DIR})
# Bring in the SPIR-V Tools repository which we'll use for testing
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Tools EXCLUDE_FROM_ALL)
set(SPIRV_TOOLS_BINARY_DIR
${CMAKE_CURRENT_BINARY_DIR}/third_party/SPIRV-Tools/tools
)
if(NOT WIN32)
# Disable RTTI and exceptions (to match LLVM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
endif()
# Bring in our cmake folder
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Bring in our lib folder
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib)
# Bring in our tools folder
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools)
# Bring in our test folder
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
if(ENABLE_CLSPV_TOOLS_INSTALL)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/clspv/AddressSpace.h
${CMAKE_CURRENT_SOURCE_DIR}/include/clspv/Passes.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/clspv/)
endif(ENABLE_CLSPV_TOOLS_INSTALL)