Mercurial > hg > CbC > CbC_llvm
comparison lld/CMakeLists.txt @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
1 # Check if lld is built as a standalone project. | 1 # Check if lld is built as a standalone project. |
2 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) | 2 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
3 project(lld) | 3 project(lld) |
4 cmake_minimum_required(VERSION 3.4.3) | 4 cmake_minimum_required(VERSION 3.13.4) |
5 | 5 |
6 set(CMAKE_INCLUDE_CURRENT_DIR ON) | 6 set(CMAKE_INCLUDE_CURRENT_DIR ON) |
7 set(LLD_BUILT_STANDALONE TRUE) | 7 set(LLD_BUILT_STANDALONE TRUE) |
8 | 8 |
9 find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary") | 9 find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary") |
33 set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree") | 33 set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree") |
34 set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include") | 34 set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include") |
35 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") | 35 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") |
36 | 36 |
37 file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR) | 37 file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR) |
38 file(TO_CMAKE_PATH ${LLVM_CMAKE_PATH} LLVM_CMAKE_PATH) | |
38 | 39 |
39 if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") | 40 if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") |
40 message(FATAL_ERROR "LLVMConfig.cmake not found") | 41 message(FATAL_ERROR "LLVMConfig.cmake not found") |
41 endif() | 42 endif() |
42 include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") | 43 include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") |
52 find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) | 53 find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) |
53 | 54 |
54 include(AddLLVM) | 55 include(AddLLVM) |
55 include(TableGen) | 56 include(TableGen) |
56 include(HandleLLVMOptions) | 57 include(HandleLLVMOptions) |
58 include(GetErrcMessages) | |
59 include(CheckAtomic) | |
57 | 60 |
58 if(LLVM_INCLUDE_TESTS) | 61 if(LLVM_INCLUDE_TESTS) |
59 if(CMAKE_VERSION VERSION_LESS 3.12) | 62 find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED |
60 include(FindPythonInterp) | 63 COMPONENTS Interpreter) |
61 if(NOT PYTHONINTERP_FOUND) | |
62 message(FATAL_ERROR | |
63 "Unable to find Python interpreter, required for testing. | |
64 | |
65 Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") | |
66 endif() | |
67 | |
68 if(${PYTHON_VERSION_STRING} VERSION_LESS 2.7) | |
69 message(FATAL_ERROR "Python 2.7 or newer is required") | |
70 endif() | |
71 | |
72 add_executable(Python3::Interpeter IMPORTED) | |
73 set_target_properties(Python3::Interpreter PROPERTIES | |
74 IMPORTED_LOCATION ${PYTHON_EXECUTABLE}) | |
75 set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) | |
76 else() | |
77 find_package(Python3 COMPONENTS Interpreter) | |
78 if(NOT Python3_Interpreter_FOUND) | |
79 message(WARNING "Python3 not found, using python2 as a fallback") | |
80 find_package(Python2 COMPONENTS Interpreter REQUIRED) | |
81 if(Python2_VERSION VERSION_LESS 2.7) | |
82 message(SEND_ERROR "Python 2.7 or newer is required") | |
83 endif() | |
84 | |
85 # Treat python2 as python3 | |
86 add_executable(Python3::Interpreter IMPORTED) | |
87 set_target_properties(Python3::Interpreter PROPERTIES | |
88 IMPORTED_LOCATION ${Python2_EXECUTABLE}) | |
89 set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) | |
90 endif() | |
91 endif() | |
92 | 64 |
93 # Check prebuilt llvm/utils. | 65 # Check prebuilt llvm/utils. |
94 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX} | 66 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX} |
95 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}) | 67 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}) |
96 set(LLVM_UTILS_PROVIDED ON) | 68 set(LLVM_UTILS_PROVIDED ON) |
126 if (MSVC OR XCODE) | 98 if (MSVC OR XCODE) |
127 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") | 99 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") |
128 endif() | 100 endif() |
129 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") | 101 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") |
130 | 102 |
103 get_errc_messages(LLVM_LIT_ERRC_MESSAGES) | |
104 | |
131 # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. | 105 # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. |
132 if(WIN32 AND NOT CYGWIN) | 106 if(WIN32 AND NOT CYGWIN) |
133 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") | 107 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") |
134 endif() | 108 endif() |
135 else() | 109 else() |
136 set(LLVM_INCLUDE_TESTS OFF) | 110 set(LLVM_INCLUDE_TESTS OFF) |
137 endif() | 111 endif() |
112 endif() | |
113 | |
114 if(LLVM_HAVE_LIBXAR) | |
115 set(XAR_LIB xar) | |
138 endif() | 116 endif() |
139 endif() | 117 endif() |
140 | 118 |
141 set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | 119 set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
142 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include ) | 120 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include ) |
190 endif() | 168 endif() |
191 | 169 |
192 option(LLD_BUILD_TOOLS | 170 option(LLD_BUILD_TOOLS |
193 "Build the lld tools. If OFF, just generate build targets." ON) | 171 "Build the lld tools. If OFF, just generate build targets." ON) |
194 | 172 |
173 option(LLD_DEFAULT_LD_LLD_IS_MINGW | |
174 "Use MinGW as the default backend for ld.lld. If OFF, ELF will be used." OFF) | |
175 if (LLD_DEFAULT_LD_LLD_IS_MINGW) | |
176 add_definitions("-DLLD_DEFAULT_LD_LLD_IS_MINGW=1") | |
177 endif() | |
178 | |
195 if (MSVC) | 179 if (MSVC) |
196 add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.' | 180 add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.' |
197 add_definitions(-wd4062) # Suppress 'warning C4062: enumerator X in switch of enum Y is not handled' from system header. | 181 add_definitions(-wd4062) # Suppress 'warning C4062: enumerator X in switch of enum Y is not handled' from system header. |
198 endif() | 182 endif() |
199 | 183 |
205 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) | 189 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) |
206 install(DIRECTORY include/ | 190 install(DIRECTORY include/ |
207 DESTINATION include | 191 DESTINATION include |
208 FILES_MATCHING | 192 FILES_MATCHING |
209 PATTERN "*.h" | 193 PATTERN "*.h" |
210 PATTERN ".svn" EXCLUDE | |
211 ) | 194 ) |
212 endif() | 195 endif() |
213 | 196 |
214 add_subdirectory(Common) | 197 add_subdirectory(Common) |
215 add_subdirectory(lib) | 198 add_subdirectory(lib) |