-
Notifications
You must be signed in to change notification settings - Fork 33
/
CMakeLists.txt
46 lines (34 loc) · 1.36 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
cmake_minimum_required(VERSION 2.8)
project(llvm_passes C CXX)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -fdiagnostics-color -g -UNDEBUG")
endif()
# where cmake extension lies
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(Python)
# LLVM detection part
set(LLVM_ROOT "" CACHE PATH "Root of LLVM install.")
# A bit of a sanity check:
if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
endif()
# Incorporate the CMake features provided by LLVM:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
# only needed for multi target build?
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CFG_INTDIR})
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CFG_INTDIR})
# get regular includes
include(LLVMConfig)
include(HandleLLVMOptions)
include(AddLLVM)
# Now set the header and library paths:
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# generate config-dependent files
configure_file("${CMAKE_SOURCE_DIR}/tests/lit.cfg.in" "${CMAKE_BINARY_DIR}/tests/lit.cfg")
# testing part relies on lit
find_python_module(lit REQUIRED)
add_custom_target(check COMMAND ${PYTHON_EXECUTABLE} -m lit.main ${CMAKE_BINARY_DIR}/tests)
# Finally load appropriate config from subdirs
add_subdirectory(llvm-passes)