|
1 | 1 | cmake_minimum_required(VERSION 3.9) |
2 | 2 | project(scala-native-bindgen) |
3 | 3 |
|
4 | | -# Locate $LLVM_PATH/lib/cmake/clang/ClangConfig.cmake |
5 | | -find_package(Clang REQUIRED CONFIG) |
| 4 | +set(USE_SHARED OFF) |
| 5 | + |
| 6 | +# Locate LLVMConfig.cmake |
| 7 | +find_package(LLVM REQUIRED CONFIG) |
6 | 8 | message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") |
7 | 9 | message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") |
8 | 10 |
|
| 11 | +message(STATUS "Using LLVM include dirs: ${LLVM_INCLUDE_DIRS}") |
9 | 12 | include_directories(SYSTEM ${LLVM_INCLUDE_DIRS}) |
| 13 | + |
| 14 | +message(STATUS "Using LLVM defs: ${LLVM_DEFINITIONS}") |
10 | 15 | add_definitions(${LLVM_DEFINITIONS}) |
11 | 16 |
|
12 | 17 | add_compile_options(-fexceptions -std=c++11 -Wall -Wconversion -Werror) |
13 | 18 |
|
| 19 | +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 20 | + # macOS does not guarantee backwards compatible system calls and therefore |
| 21 | + # discourages statically linked binaries. Instead add -L/usr/lib before the |
| 22 | + # LLVM LDFLAGS to link against the dynamic system libc++ instead of the one |
| 23 | + # from LLVM. |
| 24 | + set(BINDGEN_LINK_FLAG "-L/usr/lib") |
| 25 | +else() |
| 26 | + set(BINDGEN_LINK_FLAG "-static") |
| 27 | +endif() |
| 28 | +message(STATUS "Using link flag: ${BINDGEN_LINK_FLAG}") |
| 29 | + |
| 30 | +message(STATUS "Using LLVM library directories: ${LLVM_LIBRARY_DIRS}") |
| 31 | +link_directories(${LLVM_LIBRARY_DIRS}) |
| 32 | + |
14 | 33 | add_executable(bindgen |
15 | 34 | Main.cpp |
16 | 35 | visitor/ScalaFrontendAction.h |
@@ -69,10 +88,23 @@ add_executable(bindgen |
69 | 88 | set_target_properties(bindgen |
70 | 89 | PROPERTIES |
71 | 90 | OUTPUT_NAME scala-native-bindgen |
| 91 | + LINK_FLAGS "${BINDGEN_LINK_FLAG}" |
72 | 92 | ) |
73 | 93 |
|
| 94 | +llvm_map_components_to_libnames(LLVM_LIBS support core irreader object option profiledata) |
| 95 | + |
74 | 96 | target_link_libraries(bindgen |
75 | 97 | PRIVATE |
76 | 98 | clangFrontend |
77 | 99 | clangTooling |
| 100 | + clangSerialization |
| 101 | + clangDriver |
| 102 | + clangParse |
| 103 | + clangSema |
| 104 | + clangAnalysis |
| 105 | + clangEdit |
| 106 | + clangAST |
| 107 | + clangLex |
| 108 | + clangBasic |
| 109 | + ${LLVM_LIBS} |
78 | 110 | ) |
0 commit comments