From add8e916534933a0d68398a2ce9f3533c8daac01 Mon Sep 17 00:00:00 2001 From: kai Date: Thu, 18 Oct 2012 07:12:13 +0200 Subject: [PATCH] Locate Intrinsics.td in CMakeLists.txt. The LLVM_INCLUDE_DIR is not always defined (e.g. missing in Windows). We simply locate the file and pass the folder path to the tool. --- CMakeLists.txt | 10 ++++++++++ utils/gen_gccbuiltins.cpp | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa5f512105..64aa156533 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,16 @@ get_target_property(LDC_LOC ${LDC_EXE} LOCATION) # # Intrinsics module generation tools. # + +# The LLVM_INCLUDE_DIR definition is not always set, e.g. on Windows. +find_path(LLVM_INTRINSIC_TD_PATH "llvm/Intrinsics.td" PATHS ${LLVM_INCLUDE_DIRS} NO_DEFAULT_PATH) +if (${LLVM_INTRINSIC_TD_PATH} STREQUAL "LLVM_INTRINSIC_TD_PATH-NOTFOUND") + message(SEND_ERROR "File llvm/Intrinsics.td not found") +else() + message(STATUS "Using path for llvm/Intrinsics.td: ${LLVM_INTRINSIC_TD_PATH}") +endif() +add_definitions(-DLLVM_INTRINSIC_TD_PATH="${LLVM_INTRINSIC_TD_PATH}") + add_executable(gen_gccbuiltins utils/gen_gccbuiltins.cpp) # Prior to LLVM 3.2, TableGen still uses RTTI, contrary to the rest of LLVM. diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index c1948938a4..0380bf322f 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #if LDC_LLVM_VER < 302 #include @@ -148,11 +147,11 @@ int main(int argc, char** argv) return 1; } - sys::Path file(LLVM_INCLUDEDIR); + sys::Path file(LLVM_INTRINSIC_TD_PATH); file.appendComponent("llvm"); file.appendComponent("Intrinsics.td"); - string iStr = string("-I=") + string(LLVM_INCLUDEDIR); + string iStr = string("-I=") + string(LLVM_INTRINSIC_TD_PATH); string oStr = string("-o=") + argv[1]; vector args2(argv, argv + 1);