-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathCMakeLists.txt
99 lines (85 loc) · 3.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
project(CU2CL)
cmake_minimum_required(VERSION 2.8)
set(CU2CL_PATH_TO_LLVM_SRC "" CACHE PATH
"Path to LLVM source code. Not necessary if using an installed LLVM.")
set(CU2CL_PATH_TO_LLVM_BUILD "" CACHE PATH
"Path to the directory where LLVM was built or installed.")
set(CU2CL_PATH_TO_CLANG_SRC "" CACHE PATH
"Path to Clang source code. Not necessary if using an installed Clang.")
set(CU2CL_PATH_TO_CLANG_BUILD "" CACHE PATH
"Path to the directory where Clang was built or installed.")
if(CU2CL_PATH_TO_LLVM_SRC)
if(NOT EXISTS "${CU2CL_PATH_TO_LLVM_SRC}/cmake/config-ix.cmake")
message(FATAL_ERROR
"Please set CU2CL_PATH_TO_LLVM_SRC to the root directory of LLVM source code.")
else()
get_filename_component(LLVM_SRC_DIR ${CU2CL_PATH_TO_LLVM_SRC}
ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${LLVM_SRC_DIR}/cmake/modules")
endif()
endif()
if(CU2CL_PATH_TO_CLANG_SRC)
if(NOT EXISTS "${CU2CL_PATH_TO_CLANG_SRC}/CMakeLists.txt")
message(FATAL_ERROR
"Please set CU2CL_PATH_TO_CLANG_SRC to the root directory of Clang source code.")
else()
get_filename_component(CLANG_SRC_DIR ${CU2CL_PATH_TO_CLANG_SRC}
ABSOLUTE)
endif()
endif()
#if installing from combined LLVM/Clang SVN source tree, use /bin/llvm-tblgen
#otherwise, use /bin/tblgen
if(NOT EXISTS "${CU2CL_PATH_TO_LLVM_BUILD}/bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}" )
message(FATAL_ERROR
"Please set CU2CL_PATH_TO_LLVM_BUILD to a directory containing an LLVM build.")
endif()
get_filename_component(LLVM_BUILD_DIR ${CU2CL_PATH_TO_LLVM_BUILD}
ABSOLUTE)
if(NOT EXISTS "${CU2CL_PATH_TO_CLANG_BUILD}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}" )
message(FATAL_ERROR
"Please set CU2CL_PATH_TO_CLANG_BUILD to a directory containing a Clang build.")
endif()
get_filename_component(CLANG_BUILD_DIR ${CU2CL_PATH_TO_CLANG_BUILD}
ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${LLVM_BUILD_DIR}/share/llvm/cmake")
include(AddLLVM)
include(HandleLLVMOptions)
#if building from combined LLVM/Clang SVN source tree, use /share/llvm/cmkae/LLVMConfig.cmake
#otherwise use LLVM.cmake
include("${LLVM_BUILD_DIR}/share/llvm/cmake/LLVMConfig.cmake")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${LLVM_BUILD_DIR}/include" "${LLVM_SRC_DIR}/include")
include_directories("${CLANG_BUILD_DIR}/include" "${CLANG_SRC_DIR}/include")
link_directories("${LLVM_BUILD_DIR}/lib")
link_directories("${CLANG_BUILD_DIR}/lib")
#Paul - added cu2cl_libTooling.cpp
llvm_process_sources(srcs cu2cl_libTooling.cpp)
#Paul - added clangTooling as a dependency during the libTooling conversion
set(LLVM_USED_LIBS
clangFrontend
clangRewriteCore
clangAST
clangLex
clangBasic
clangTooling
clangDriver
clangSerialization
clangParse
clangSema
clangAnalysis
clangEdit
clang
LLVMCore
)
add_executable(cu2cl-tool
cu2cl_libTooling.cpp
)
foreach(lib ${LLVM_USED_LIBS})
target_link_libraries(cu2cl-tool ${lib})
endforeach(lib)
set_target_properties(cu2cl-tool
PROPERTIES
LINKER_LANGUAGE CXX
PREFIX ""
)