forked from OSchip/llvm-project
build: add support for standalone lld build
Enable building lld as a standalone project. This is motivated by the desire to package lld for inclusion in a linux distribution. This allows building lld against an existing paired llvm installation. Now that lld is usable on x86_64, it makes sense to revive this configuration to allow distributions to package it. llvm-svn: 289421
This commit is contained in:
parent
627f686ffc
commit
f1af26ddf2
|
@ -1,3 +1,54 @@
|
||||||
|
# Check if lld is built as a standalone project.
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
project(lld)
|
||||||
|
cmake_minimum_required(VERSION 3.4.3)
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(LLD_BUILT_STANDALONE TRUE)
|
||||||
|
|
||||||
|
find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary")
|
||||||
|
if(NOT LLVM_CONFIG_PATH)
|
||||||
|
message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(COMMAND "${LLVM_CONFIG_PATH}" "--obj-root" "--includedir"
|
||||||
|
RESULT_VARIABLE HAD_ERROR
|
||||||
|
OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(HAD_ERROR)
|
||||||
|
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" LLVM_CONFIG_OUTPUT "${LLVM_CONFIG_OUTPUT}")
|
||||||
|
|
||||||
|
list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
|
||||||
|
list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
|
||||||
|
|
||||||
|
set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
|
||||||
|
set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include")
|
||||||
|
|
||||||
|
file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR)
|
||||||
|
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
|
||||||
|
message(FATAL_ERROR "LLVMConfig.cmake not found")
|
||||||
|
endif()
|
||||||
|
include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
|
||||||
|
|
||||||
|
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
|
||||||
|
include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS})
|
||||||
|
link_directories(${LLVM_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
|
||||||
|
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
include(AddLLVM)
|
||||||
|
include(TableGen)
|
||||||
|
include(HandleLLVMOptions)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
|
set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
|
||||||
set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
|
@ -2,6 +2,10 @@ set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||||
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||||
add_public_tablegen_target(COFFOptionsTableGen)
|
add_public_tablegen_target(COFFOptionsTableGen)
|
||||||
|
|
||||||
|
if(NOT LLD_BUILT_STANDALONE)
|
||||||
|
set(tablegen_deps intrinsics_gen)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_lld_library(lldCOFF
|
add_lld_library(lldCOFF
|
||||||
Chunks.cpp
|
Chunks.cpp
|
||||||
DLL.cpp
|
DLL.cpp
|
||||||
|
@ -41,5 +45,5 @@ add_lld_library(lldCOFF
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
COFFOptionsTableGen
|
COFFOptionsTableGen
|
||||||
intrinsics_gen
|
${tablegen_deps}
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,10 @@ set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||||
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||||
add_public_tablegen_target(ELFOptionsTableGen)
|
add_public_tablegen_target(ELFOptionsTableGen)
|
||||||
|
|
||||||
|
if(NOT LLD_BUILT_STANDALONE)
|
||||||
|
set(tablegen_deps intrinsics_gen)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_lld_library(lldELF
|
add_lld_library(lldELF
|
||||||
Driver.cpp
|
Driver.cpp
|
||||||
DriverUtils.cpp
|
DriverUtils.cpp
|
||||||
|
@ -54,5 +58,5 @@ add_lld_library(lldELF
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
ELFOptionsTableGen
|
ELFOptionsTableGen
|
||||||
intrinsics_gen
|
${tablegen_deps}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue