-
Notifications
You must be signed in to change notification settings - Fork 129
/
CMakeLists.txt
97 lines (78 loc) · 2.86 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
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.20)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds are unsupported. Please, build out of the source tree."
)
endif()
project(compiler_gym ASM C CXX)
set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)
set(CMAKE_C_STANDARD 11 CACHE STRING "C standard to be used.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used.")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake)
# Project features.
set(COMPILER_GYM_BUILD_TESTS OFF CACHE BOOL "Enable Compiler Gym tests.")
set(COMPILER_GYM_BUILD_EXAMPLES OFF CACHE BOOL "Enable Comiler Gym examples.")
# Toolchain configuration.
include(build_tools/cmake/FindAndEnableLld.cmake)
include(build_tools/cmake/cg_macros.cmake)
include(build_tools/cmake/cg_copts.cmake)
include(build_tools/cmake/cg_genrule.cmake)
include(build_tools/cmake/cg_cc_binary.cmake)
include(build_tools/cmake/cg_cc_library.cmake)
include(build_tools/cmake/cg_cc_test.cmake)
include(build_tools/cmake/cg_py_binary.cmake)
include(build_tools/cmake/cg_py_library.cmake)
include(build_tools/cmake/cg_py_test.cmake)
include(build_tools/cmake/cg_python.cmake)
include(build_tools/cmake/cg_add_all_subdirs.cmake)
include(build_tools/cmake/cg_filegroup.cmake)
include(build_tools/cmake/grpc.cmake)
include(build_tools/cmake/protobuf.cmake)
# Set up the build Python path.
set(COMPILER_GYM_BUILD_PYTHONPATH "$ENV{PYTHONPATH}"
CACHE STRING "PYTHONPATH environment variable during build step."
)
if(COMPILER_GYM_BUILD_PYTHONPATH)
string(PREPEND COMPILER_GYM_BUILD_PYTHONPATH ":")
endif()
string(PREPEND COMPILER_GYM_BUILD_PYTHONPATH "${CMAKE_BINARY_DIR}")
include(build_tools/cmake/set_command_pythonpath.cmake)
set(DEFAULT_CMAKE_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(
STATUS
"No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}"
)
set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}"
CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})"
FORCE
)
endif()
option(
COMPILER_GYM_ENABLE_MLIR_ENV
"Whether or not to include the MLIR environment"
OFF
)
option(
COMPILER_GYM_ENABLE_LLVM_ENV
"Whether or not to include the LLVM environment"
ON
)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
include(external/external.cmake)
add_subdirectory(compiler_gym)
if(COMPILER_GYM_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(COMPILER_GYM_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()