diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -2,7 +2,7 @@ # If we are not building as a part of LLVM, build Clang as an # standalone project, using LLVM as an external library: -if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(Clang) set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") @@ -10,7 +10,7 @@ set(CMAKE_CXX_EXTENSIONS NO) # Rely on llvm-config. - set(CONFIG_OUTPUT) + set(LLVM_CONFIG_OUTPUT) if(LLVM_CONFIG) set (LLVM_CONFIG_FOUND 1) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") @@ -20,35 +20,36 @@ automatically, but you can also use LLVM_DIR to specify \ the path containing LLVMConfig.cmake.") set(CONFIG_COMMAND ${LLVM_CONFIG} - "--assertion-mode" - "--bindir" - "--libdir" "--includedir" "--prefix" "--src-root" - "--cmakedir") + "--cmakedir" + "--bindir" + "--libdir" + "--assertion-mode" + ) execute_process( COMMAND ${CONFIG_COMMAND} RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE CONFIG_OUTPUT + OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT ) if(NOT HAD_ERROR) string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" - CONFIG_OUTPUT ${CONFIG_OUTPUT}) + LLVM_CONFIG_OUTPUT ${LLVM_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() - list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) - list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) - list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) - list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) - list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) - list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) - list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_DIR) + list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR) + list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT) + list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR) + list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR) + list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR) + list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR) + list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS) # Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes. # CMake assumes slashes as PATH. @@ -71,17 +72,17 @@ if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. + set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR}) + set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR}) set(LIBRARY_DIR ${LLVM_LIBRARY_DIR}) - set(INCLUDE_DIR ${LLVM_INCLUDE_DIR}) - set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) endif() - set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") - set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") - set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") 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") + set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") + set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) @@ -184,11 +185,12 @@ endif() endif() - set( CLANG_BUILT_STANDALONE 1 ) + set(CLANG_BUILT_STANDALONE TRUE) + set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}") else() set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") -endif() +endif() # standalone # Make sure that our source directory is on the current cmake module path so that # we can include cmake files from this directory.