forked from manojgudi/sandhi
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1897808
commit a23bf59
Showing
13 changed files
with
550 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Find Clang | ||
# | ||
# It defines the following variables | ||
# CLANG_FOUND - True if Clang found. | ||
# CLANG_INCLUDE_DIRS - where to find Clang include files | ||
# CLANG_LIBS - list of clang libs | ||
|
||
if (NOT LLVM_INCLUDE_DIRS OR NOT LLVM_LIBRARY_DIRS) | ||
message(FATAL_ERROR "No LLVM and Clang support requires LLVM") | ||
else (NOT LLVM_INCLUDE_DIRS OR NOT LLVM_LIBRARY_DIRS) | ||
|
||
MACRO(FIND_AND_ADD_CLANG_LIB _libname_) | ||
find_library(CLANG_${_libname_}_LIB ${_libname_} ${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS}) | ||
if (CLANG_${_libname_}_LIB) | ||
set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_libname_}_LIB}) | ||
endif (CLANG_${_libname_}_LIB) | ||
ENDMACRO(FIND_AND_ADD_CLANG_LIB) | ||
|
||
# Clang shared library provides just the limited C interface, so it | ||
# can not be used. We look for the static libraries. | ||
FIND_AND_ADD_CLANG_LIB(clangFrontend) | ||
FIND_AND_ADD_CLANG_LIB(clangDriver) | ||
FIND_AND_ADD_CLANG_LIB(clangCodeGen) | ||
FIND_AND_ADD_CLANG_LIB(clangEdit) | ||
FIND_AND_ADD_CLANG_LIB(clangSema) | ||
FIND_AND_ADD_CLANG_LIB(clangChecker) | ||
FIND_AND_ADD_CLANG_LIB(clangAnalysis) | ||
FIND_AND_ADD_CLANG_LIB(clangRewrite) | ||
FIND_AND_ADD_CLANG_LIB(clangAST) | ||
FIND_AND_ADD_CLANG_LIB(clangParse) | ||
FIND_AND_ADD_CLANG_LIB(clangLex) | ||
FIND_AND_ADD_CLANG_LIB(clangBasic) | ||
FIND_AND_ADD_CLANG_LIB(clang) | ||
|
||
find_path(CLANG_INCLUDE_DIRS clang/Basic/Version.h HINTS ${LLVM_INCLUDE_DIRS}) | ||
|
||
if (CLANG_LIBS AND CLANG_INCLUDE_DIRS) | ||
MESSAGE(STATUS "Clang libs: " ${CLANG_LIBS}) | ||
set(CLANG_FOUND TRUE) | ||
endif (CLANG_LIBS AND CLANG_INCLUDE_DIRS) | ||
|
||
if (CLANG_FOUND) | ||
message(STATUS "Found Clang: ${CLANG_INCLUDE_DIRS}") | ||
else (CLANG_FOUND) | ||
if (CLANG_FIND_REQUIRED) | ||
message(FATAL_ERROR "Could NOT find Clang") | ||
endif (CLANG_FIND_REQUIRED) | ||
endif (CLANG_FOUND) | ||
|
||
endif (NOT LLVM_INCLUDE_DIRS OR NOT LLVM_LIBRARY_DIRS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Find LLVM | ||
# | ||
# It defines the following variables | ||
# LLVM_FOUND - True if llvm found. | ||
# LLVM_INCLUDE_DIRS - where to find llvm include files | ||
# LLVM_LIBRARY_DIRS - where to find llvm libs | ||
# LLVM_CFLAGS - llvm compiler flags | ||
# LLVM_LDFLAGS - llvm linker flags | ||
# LLVM_MODULE_LIBS - list of llvm libs for working with modules. | ||
|
||
find_program(LLVM_CONFIG_EXECUTABLE llvm-config DOC "llvm-config executable") | ||
|
||
if (LLVM_CONFIG_EXECUTABLE) | ||
message(STATUS "LLVM llvm-config found at: ${LLVM_CONFIG_EXECUTABLE}") | ||
else (LLVM_CONFIG_EXECUTABLE) | ||
message(FATAL_ERROR "Could NOT find LLVM executable") | ||
endif (LLVM_CONFIG_EXECUTABLE) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --version | ||
OUTPUT_VARIABLE LLVM_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\1" LLVM_VERSION_MAJOR | ||
"${LLVM_VERSION}") | ||
|
||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\2" LLVM_VERSION_MINOR | ||
"${LLVM_VERSION}") | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir | ||
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir | ||
OUTPUT_VARIABLE LLVM_LIBRARY_DIRS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags | ||
OUTPUT_VARIABLE LLVM_CFLAGS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if (LLVM_CFLAGS MATCHES "\\-DNDEBUG") | ||
set(LLVM_WITH_NDEBUG TRUE) | ||
else (LLVM_CFLAGS MATCHES "\\-DNDEBUG") | ||
set(LLVM_WITH_NDEBUG FALSE) | ||
endif (LLVM_CFLAGS MATCHES "\\-DNDEBUG") | ||
|
||
|
||
find_library(LLVM_MODULE_LIBS LLVM-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} ${LLVM_LIBRARY_DIRS}) | ||
if (NOT LLVM_MODULE_LIBS) | ||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs | ||
OUTPUT_VARIABLE LLVM_MODULE_LIBS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif (NOT LLVM_MODULE_LIBS) | ||
|
||
execute_process( | ||
COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags | ||
OUTPUT_VARIABLE LLVM_LDFLAGS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if (LLVM_CONFIG_EXECUTABLE) | ||
set(LLVM_FOUND TRUE) | ||
endif (LLVM_CONFIG_EXECUTABLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.