r197714 - [CMake] Tweak r197697 to handle CMake finding the wrong llvm-config/tblgen.

Jordan Rose jordan_rose at apple.com
Thu Dec 19 10:39:05 PST 2013


Author: jrose
Date: Thu Dec 19 12:39:05 2013
New Revision: 197714

URL: http://llvm.org/viewvc/llvm-project?rev=197714&view=rev
Log:
[CMake] Tweak r197697 to handle CMake finding the wrong llvm-config/tblgen.

- If llvm-config fails, output an error to the user rather than allowing
  errors to cascade.
- Always get llvm-tblgen from llvm-config's bindir.

Turns out my PATH points to a really old version of LLVM; both of these
fell out of trying to make this experience nicer.

Modified:
    cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=197714&r1=197713&r2=197714&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Dec 19 12:39:05 2013
@@ -9,19 +9,27 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   find_program(LLVM_CONFIG "llvm-config")
   if(LLVM_CONFIG)
     message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-    execute_process(
-      COMMAND ${LLVM_CONFIG}
+    set(CONFIG_COMMAND ${LLVM_CONFIG}
       "--assertion-mode"
       "--bindir"
       "--libdir"
       "--includedir"
       "--prefix"
-      "--src-root"
+      "--src-root")
+    execute_process(
+      COMMAND ${CONFIG_COMMAND}
+      RESULT_VARIABLE HAD_ERROR
       OUTPUT_VARIABLE CONFIG_OUTPUT
-      )
-    string(REGEX REPLACE
-      "[ \t]*[\r\n]+[ \t]*" ";"
-      CONFIG_OUTPUT ${CONFIG_OUTPUT})
+    )
+    if(NOT HAD_ERROR)
+      string(REGEX REPLACE
+        "[ \t]*[\r\n]+[ \t]*" ";"
+        CONFIG_OUTPUT ${CONFIG_OUTPUT})
+    else()
+      string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+      message(STATUS "${CONFIG_COMMAND_STR}")
+      message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
+    endif()
   else()
     message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
   endif()
@@ -46,7 +54,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
   set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
-  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR})
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+    NO_DEFAULT_PATH)
 
   set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
   set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")





More information about the cfe-commits mailing list