summarylogtreecommitdiffstats
path: root/0002-Use-llvm-from-cling.patch
blob: d23a03be72941a1270acca041878f3089a308edb (plain)
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
diff --unified --recursive --text xeus-cling-0.10.0/CMakeLists.txt xeus-cling-0.10.0-fixed/CMakeLists.txt
--- xeus-cling-0.10.0/CMakeLists.txt	2020-08-29 00:08:47.000000000 +0200
+++ xeus-cling-0.10.0-fixed/CMakeLists.txt	2020-09-23 17:00:45.525608638 +0200
@@ -46,58 +46,6 @@
     "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp17/kernel.json"
 )
 
-#######################
-# Rely on llvm-config #
-#######################
-
-set(CONFIG_OUTPUT)
-find_program(LLVM_CONFIG "llvm-config")
-if(LLVM_CONFIG)
-    message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-    set(CONFIG_COMMAND ${LLVM_CONFIG}
-        "--assertion-mode"
-        "--bindir"
-        "--libdir"
-        "--includedir"
-        "--prefix"
-        "--src-root")
-    execute_process(COMMAND ${CONFIG_COMMAND}
-                    RESULT_VARIABLE HAD_ERROR
-                    OUTPUT_VARIABLE CONFIG_OUTPUT)
-    if(NOT HAD_ERROR)
-        string(REGEX REPLACE
-               "[ \t]*[\r\n]+[ \t]*" ";"
-               CONFIG_OUTPUT ${CONFIG_OUTPUT})
-    else()
-        string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-        message(STATUS "${CONFIG_COMMAND_STR}")
-        message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-    endif()
-else()
-    message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
-endif()
-
-list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
-list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
-list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
-list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
-list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
-list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
-
-if(NOT MSVC_IDE)
-    set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} CACHE BOOL "Enable assertions")
-    mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
-endif()
-
-set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
-set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
-set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-
-include_directories(${LLVM_MAIN_INCLUDE_DIR})
-link_directories(${LLVM_LIBRARY_DIR})
-add_definitions(-DLLVM_DIR="${LLVM_BINARY_DIR}")
 
 ################
 # Dependencies #
@@ -110,8 +58,10 @@
 find_package(cppzmq ${cppzmq_REQUIRED_VERSION} REQUIRED)
 find_package(pugixml REQUIRED)
 
-find_package(Clang REQUIRED)
 find_package(Cling REQUIRED)
+find_package(Clang REQUIRED)
+find_package(LLVM REQUIRED)
+add_definitions(-DLLVM_DIR="${LLVM_INSTALL_PREFIX}")
 find_package(cxxopts REQUIRED)
 
 #########
@@ -228,6 +178,7 @@
 
 target_include_directories(xeus-cling
                            PUBLIC
+                           $<BUILD_INTERFACE:${LLVM_INCLUDE_DIR}>
                            $<BUILD_INTERFACE:${XEUS_CLING_INCLUDE_DIR}>
                            $<INSTALL_INTERFACE:include>)
 target_link_libraries(xeus-cling PUBLIC clingInterpreter clingMetaProcessor clingUtils xeus pugixml cxxopts::cxxopts)