[cfe-dev] [PATCHv2] Add support for LLVM_LIBDIR_SUFFIX.
Johannes Obermayr
johannesobermayr at gmx.de
Tue Sep 20 09:11:52 PDT 2011
---
CMakeLists.txt | 32 +++++++++++++++++++++++++++++---
include/clang/Basic/Version.inc.in | 1 +
lib/Driver/Driver.cpp | 2 +-
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2be3c9c..f36a367 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,9 +42,35 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
+ # If LLVM_LIBDIR_SUFFIX is not defined determine it via
+ # llvm-config --libdir | sed -r "s:.*[^0-9]([0-9]*):\1:g"
+ # It is defined in LLVMConfig.cmake or via -DLLVM_LIBDIR_SUFFIX=""
+ if(NOT DEFINED LLVM_LIBDIR_SUFFIX)
+ find_program(LLVM_CONFIG_EXE llvm-config
+ PATHS
+ /opt/local/bin
+ /opt/llvm/*/bin
+ /opt/llvm/bin
+ /usr/lib/llvm-*/bin
+ /usr/lib/llvm-*/bin
+ )
+ if(LLVM_CONFIG_EXE)
+ execute_process(COMMAND ${LLVM_CONFIG_EXE} --libdir
+ COMMAND sed -r "s:.*[^0-9]([0-9]*):\1:g"
+ OUTPUT_VARIABLE LLVM_LIBDIR_SUFFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif()
+ endif()
+ if(LLVM_LIBDIR_SUFFIX)
+ message(STATUS "LLVM_LIBDIR_SUFFIX: ${LLVM_LIBDIR_SUFFIX}")
+ else()
+ message(STATUS "LLVM_LIBDIR_SUFFIX: none")
+ endif()
+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${PATH_TO_LLVM_BUILD}/include" "${LLVM_MAIN_INCLUDE_DIR}")
- link_directories("${PATH_TO_LLVM_BUILD}/lib")
+ link_directories("${PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}")
if( EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/tblgen${CMAKE_EXECUTABLE_SUFFIX}" )
set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/tblgen")
@@ -54,8 +80,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
endif()
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
- set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
- set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
+ set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
+ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
set( CLANG_BUILT_STANDALONE 1 )
endif()
diff --git a/include/clang/Basic/Version.inc.in b/include/clang/Basic/Version.inc.in
index ccf8430..4d924db 100644
--- a/include/clang/Basic/Version.inc.in
+++ b/include/clang/Basic/Version.inc.in
@@ -1,6 +1,7 @@
#define CLANG_VERSION @CLANG_VERSION@
#define CLANG_VERSION_MAJOR @CLANG_VERSION_MAJOR@
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
+#define CLANG_LIB "lib at LLVM_LIBDIR_SUFFIX@"
#if @CLANG_HAS_VERSION_PATCHLEVEL@
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
#endif
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index d77ae92..0bceca8 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -86,7 +86,7 @@ Driver::Driver(StringRef ClangExecutable,
if (ClangResourceDir != "")
llvm::sys::path::append(P, ClangResourceDir);
else
- llvm::sys::path::append(P, "..", "lib", "clang", CLANG_VERSION_STRING);
+ llvm::sys::path::append(P, "..", CLANG_LIB, "clang", CLANG_VERSION_STRING);
ResourceDir = P.str();
}
--
1.7.3.4
More information about the cfe-dev
mailing list