[PATCH] D57406: build: remove use of llvm-config
Saleem Abdulrasool via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 31 10:34:54 PST 2019
compnerd updated this revision to Diff 184545.
compnerd added a comment.
Fixes
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57406/new/
https://reviews.llvm.org/D57406
Files:
CMakeLists.txt
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -6,50 +6,44 @@
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"
- "--cmakedir"
- "--src-root"
- 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)
- list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH)
- list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_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")
- set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-
- file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR)
-
- if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
- message(FATAL_ERROR "LLVMConfig.cmake not found")
- endif()
- include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
+ find_package(LLVM REQUIRED CONFIG NO_CMAKE_FIND_ROOT_PATH)
+ list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
- list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+ set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+ set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
- include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS})
+ include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
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)
+
+ if(CMAKE_CROSSCOMPILING)
+ set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
+ if(NOT EXISTS "${LLVM_NATIVE_BUILD}")
+ message(FATAL_ERROR
+ "Attempting to cross-compiling lld standalone but no native LLVM build
+ found. Please cross-compile LLVM as well.")
+ endif()
+
+ if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
+ set(HOST_EXECUTABLE_SUFFIX ".exe")
+ endif()
+
+ if(NOT CMAKE_CONFIGURATION_TYPES)
+ set(LLVM_TABLEGEN_EXE
+ "${LLVM_NATIVE_BUILD_DIR}/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
+ else()
+ # NOTE: LLVM NATIVE build is always built Release, as is specified in
+ # CrossCompile.cmake
+ set(LLVM_TABLEGEN_EXE
+ "${LLVM_NATIVE_BUILD_DIR}/Release/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
+ endif()
+ else()
+ find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+ NO_DEFAULT_PATH)
+ endif()
include(AddLLVM)
include(TableGen)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57406.184545.patch
Type: text/x-patch
Size: 3445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/93eac4e1/attachment.bin>
More information about the llvm-commits
mailing list