From e90340a7e34067a474317c7f03c109b7c0d0ef66 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 23 Aug 2013 18:05:24 +0000 Subject: [PATCH] CMake: Don't look for llvm-tblgen when building outside LLVM tree Previously, the CMake build would look for llvm-tblgen to determine if a directory is an LLVM build or install directory. Since we don't want to include llvm-tblgen in the install, look for llvm-config instead, and use that to find llvm-tblgen. Differential Revision: http://llvm-reviews.chandlerc.com/D1483 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189127 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb0b0a7737..386f3e7142 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,12 +19,14 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) endif() endif() - if( NOT EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}" ) - # Looking for bin/Debug/llvm-tblgen is a complete hack. How can we get + if (EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") + set (PATH_TO_LLVM_CONFIG "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") + elseif (EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") + # Looking for bin/Debug/llvm-config is a complete hack. How can we get # around this? - if( NOT EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}" ) - message(FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_BUILD to a directory containing a LLVM build.") - endif() + set (PATH_TO_LLVM_CONFIG "${CLANG_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") + else() + message(FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_BUILD to a directory containing a LLVM build.") endif() list(APPEND CMAKE_MODULE_PATH "${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake") @@ -46,12 +48,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) include_directories("${PATH_TO_LLVM_BUILD}/include" "${LLVM_MAIN_INCLUDE_DIR}") link_directories("${PATH_TO_LLVM_BUILD}/lib") - if( EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}" ) - set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}") - else() - # FIXME: This is an utter hack. - set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/Debug/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}") - endif() + exec_program("${PATH_TO_LLVM_CONFIG} --bindir" OUTPUT_VARIABLE LLVM_TABLEGEN_EXE) + set(LLVM_TABLEGEN_EXE "${LLVM_TABLEGEN_EXE}/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}") # Define the default arguments to use with 'lit', and an option for the user # to override. -- 2.40.0