Brenden Blanco | 246b942 | 2015-06-05 11:15:27 -0700 | [diff] [blame] | 1 | # Copyright (c) PLUMgrid, Inc. |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License") |
Brenden Blanco | a94bd93 | 2015-04-26 00:56:42 -0700 | [diff] [blame] | 3 | cmake_minimum_required(VERSION 2.8.7) |
| 4 | |
Brenden Blanco | f275d3d | 2015-07-06 23:41:23 -0700 | [diff] [blame] | 5 | project(bcc) |
| 6 | set(CMAKE_BUILD_TYPE Release) |
Brenden Blanco | cd5cb41 | 2015-04-26 09:41:58 -0700 | [diff] [blame] | 7 | |
| 8 | enable_testing() |
Brenden Blanco | a94bd93 | 2015-04-26 00:56:42 -0700 | [diff] [blame] | 9 | |
Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 10 | include(scripts/GetGitRevisionDescription.cmake) |
Brenden Blanco | 3c8c6de | 2015-07-02 17:48:41 -0700 | [diff] [blame] | 11 | get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) |
| 12 | if(LIB64) |
| 13 | set(LIBSUFFIX 64) |
| 14 | endif() |
Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 15 | |
Brenden Blanco | 439a9f3 | 2015-07-03 16:10:29 -0700 | [diff] [blame] | 16 | if(NOT PYTHON_ONLY) |
Brenden Blanco | a94bd93 | 2015-04-26 00:56:42 -0700 | [diff] [blame] | 17 | find_package(BISON) |
| 18 | find_package(FLEX) |
| 19 | find_package(LLVM REQUIRED CONFIG) |
Brenden Blanco | cd5cb41 | 2015-04-26 09:41:58 -0700 | [diff] [blame] | 20 | message(STATUS "Found LLVM: ${LLVM_INCLUDE_DIRS}") |
Brenden Blanco | 25245bf | 2015-05-10 12:15:06 -0700 | [diff] [blame] | 21 | |
| 22 | # clang is linked as a library, but the library path searching is |
| 23 | # primitively supported, unlike libLLVM |
Brenden Blanco | f275d3d | 2015-07-06 23:41:23 -0700 | [diff] [blame] | 24 | set(CLANG_SEARCH "/opt/local/llvm/lib;/usr/lib/llvm-3.7/lib;${LLVM_LIBRARY_DIRS}") |
Brenden Blanco | 25245bf | 2015-05-10 12:15:06 -0700 | [diff] [blame] | 25 | find_library(libclangAnalysis NAMES clangAnalysis HINTS ${CLANG_SEARCH}) |
| 26 | find_library(libclangAST NAMES clangAST HINTS ${CLANG_SEARCH}) |
| 27 | find_library(libclangBasic NAMES clangBasic HINTS ${CLANG_SEARCH}) |
| 28 | find_library(libclangCodeGen NAMES clangCodeGen HINTS ${CLANG_SEARCH}) |
| 29 | find_library(libclangDriver NAMES clangDriver HINTS ${CLANG_SEARCH}) |
| 30 | find_library(libclangEdit NAMES clangEdit HINTS ${CLANG_SEARCH}) |
| 31 | find_library(libclangFrontend NAMES clangFrontend HINTS ${CLANG_SEARCH}) |
| 32 | find_library(libclangLex NAMES clangLex HINTS ${CLANG_SEARCH}) |
| 33 | find_library(libclangParse NAMES clangParse HINTS ${CLANG_SEARCH}) |
Brenden Blanco | 7009b55 | 2015-05-26 11:48:17 -0700 | [diff] [blame] | 34 | find_library(libclangRewrite NAMES clangRewrite HINTS ${CLANG_SEARCH}) |
Brenden Blanco | 25245bf | 2015-05-10 12:15:06 -0700 | [diff] [blame] | 35 | find_library(libclangSema NAMES clangSema HINTS ${CLANG_SEARCH}) |
| 36 | find_library(libclangSerialization NAMES clangSerialization HINTS ${CLANG_SEARCH}) |
Brenden Blanco | 8310291 | 2015-06-09 17:43:27 -0700 | [diff] [blame] | 37 | if(libclangBasic STREQUAL "libclangBasic-NOTFOUND") |
| 38 | message(FATAL_ERROR "Unable to find clang libraries") |
| 39 | endif() |
Alexei Starovoitov | 955f3b6 | 2015-06-09 19:37:38 -0700 | [diff] [blame] | 40 | FOREACH(DIR ${LLVM_INCLUDE_DIRS}) |
| 41 | include_directories("${DIR}/../tools/clang/include") |
| 42 | ENDFOREACH() |
Brenden Blanco | a94bd93 | 2015-04-26 00:56:42 -0700 | [diff] [blame] | 43 | |
| 44 | set(CMAKE_C_FLAGS "-Wall") |
| 45 | set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") |
Brenden Blanco | 439a9f3 | 2015-07-03 16:10:29 -0700 | [diff] [blame] | 46 | endif() |
Brenden Blanco | a94bd93 | 2015-04-26 00:56:42 -0700 | [diff] [blame] | 47 | |
Brenden Blanco | d8acf6f | 2015-06-07 22:32:33 -0700 | [diff] [blame] | 48 | add_subdirectory(scripts) |
Brenden Blanco | 46176a1 | 2015-07-07 13:05:22 -0700 | [diff] [blame] | 49 | add_subdirectory(examples) |
Brenden Blanco | cd5cb41 | 2015-04-26 09:41:58 -0700 | [diff] [blame] | 50 | add_subdirectory(src) |
| 51 | add_subdirectory(tests) |