forked from google/gapid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
113 lines (96 loc) · 4.15 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
# Copyright (C) 2017 Google Inc.
#
# 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.2)
cmake_policy(SET CMP0009 NEW) # GLOB_RECURSE does not recurse symlinks
cmake_policy(SET CMP0053 NEW) # Simplify variable reference
cmake_policy(SET CMP0003 NEW) # Link by full path
cmake_policy(SET CMP0058 NEW) # Custom command DEPENDS on files that are not specified as OUTPUT or BYPRODUCTS
set(GAPID_CMAKE_VERSION "1")
set(GAPID_CMAKE_VERSION_STORE ${GAPID_CMAKE_VERSION} CACHE STRING "Version of the gapid cmake build system")
if(NOT ${GAPID_CMAKE_VERSION} STREQUAL ${GAPID_CMAKE_VERSION_STORE})
message(FATAL_ERROR "
Output directory version is ${GAPID_CMAKE_VERSION_STORE}, required version is ${GAPID_CMAKE_VERSION}
The cmake output directory needs to be deleted and regenerated...
")
endif()
include(version.cmake)
add_compile_options("-DGAPID_VERSION_AND_BUILD=\"${GAPID_VERSION_AND_BUILD}\"")
set(CMAKE_HOST_EXECUTABLE_SUFFIX "")
if(CMAKE_HOST_WIN32)
set(CMAKE_HOST_EXECUTABLE_SUFFIX ".exe")
endif()
file(LOCK ${CMAKE_BINARY_DIR} DIRECTORY GUARD PROCESS RESULT_VARIABLE locked)
# Basic selection controls
option(DISABLE_CXX "Disable all c++ building steps")
option(DISABLE_GO "Disable all go building steps")
option(DISABLE_PROTOC "Disable all proto building steps")
option(DISABLE_CODE_GENERATION "Disable all code generation building steps")
option(ONLY_HOST "Disable non host build steps")
include(cmake/Init.cmake)
project(GAPID
LANGUAGES ${languages}
VERSION ${GAPID_VERSION_MAJOR}.${GAPID_VERSION_MINOR}.${GAPID_VERSION_POINT}
)
include(Config)
if(MSVC_GAPIR AND WIN32)
find_package(MSVC)
add_cmake("gapir-msvc" ${CMAKE_SOURCE_DIR} "-DMSVC_PATH:STRING=${MSVC_PATH}" "-DCMAKE_C_COMPILER:STRING=${MSVC_CL}" "-DCMAKE_CXX_COMPILER:STRING=${MSVC_CL}")
endif()
if(MSVC)
# turn off msvc specific warnings, define platform, turn on pdb generation
# warning C4996: This function may be unsafe, use the _s version instead.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /D__x86_64 /Zi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /D__x86_64 /Zi")
# linktime pdb generation is ignored unless /DEBUG is specified, /OPT:REF turns linker optimizations back on.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /OPT:REF")
include(third_party/breakpad.cmake)
include(third_party/cityhash.cmake)
build_subdirectory(core/cc)
build_subdirectory(core/vulkan/cc)
build_subdirectory(gapir/cc)
build_subdirectory(cmd/gapir)
else()
foreach(abi ${ANDROID_ACTIVE_ABI_LIST})
# Build a cmake output directory for the specific abi
add_cmake(${abi} ${CMAKE_SOURCE_DIR} "-DANDROID_ABI:STRING=${abi}")
endforeach()
if(ARMLINUX_GAPII)
set(GAPII_TOOLCHAIN "ArmLinux")
string(TOLOWER "${GAPII_TOOLCHAIN}" GAPII_PROJECT)
add_cmake(${GAPII_PROJECT} ${CMAKE_SOURCE_DIR} "-DGAPII_TARGET:STRING=${GAPII_TOOLCHAIN}")
endif()
# Third party libraries
include(third_party/astc-encoder.cmake)
include(third_party/breakpad.cmake)
include(third_party/cityhash.cmake)
include(third_party/khronos.cmake)
include(third_party/protobuf.cmake)
include(third_party/grpc-java.cmake)
# Must come first (declares rules like apic).
build_subdirectory(cmd)
build_subdirectory(core)
build_subdirectory(gapic)
build_subdirectory(gapii)
if(NOT GAPII_TARGET)
build_subdirectory(gapil)
build_subdirectory(gapir)
build_subdirectory(gapis)
build_subdirectory(gapidapk)
build_subdirectory(test)
endif()
scan_for_protos()
endif()
# Add root as include path for all c includes.
include_directories(${CMAKE_SOURCE_DIR})
include(Package)