blob: 664a649ec7bf61c1d26df6067fe05cef30b07b12 [file] [log] [blame]
Brenden Blanco246b9422015-06-05 11:15:27 -07001# Copyright (c) PLUMgrid, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License")
Brenden Blancoa94bd932015-04-26 00:56:42 -07003cmake_minimum_required(VERSION 2.8.7)
4
Brenden Blancof275d3d2015-07-06 23:41:23 -07005project(bcc)
6set(CMAKE_BUILD_TYPE Release)
Brenden Blancocd5cb412015-04-26 09:41:58 -07007
8enable_testing()
Brenden Blancoa94bd932015-04-26 00:56:42 -07009
Brenden Blancod8acf6f2015-06-07 22:32:33 -070010include(scripts/GetGitRevisionDescription.cmake)
Brenden Blanco3c8c6de2015-07-02 17:48:41 -070011get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
12if(LIB64)
13 set(LIBSUFFIX 64)
14endif()
Brenden Blancod8acf6f2015-06-07 22:32:33 -070015
Brenden Blanco439a9f32015-07-03 16:10:29 -070016if(NOT PYTHON_ONLY)
Brenden Blancoa94bd932015-04-26 00:56:42 -070017find_package(BISON)
18find_package(FLEX)
19find_package(LLVM REQUIRED CONFIG)
Brenden Blancocd5cb412015-04-26 09:41:58 -070020message(STATUS "Found LLVM: ${LLVM_INCLUDE_DIRS}")
Brenden Blanco25245bf2015-05-10 12:15:06 -070021
22# clang is linked as a library, but the library path searching is
23# primitively supported, unlike libLLVM
Brenden Blancof275d3d2015-07-06 23:41:23 -070024set(CLANG_SEARCH "/opt/local/llvm/lib;/usr/lib/llvm-3.7/lib;${LLVM_LIBRARY_DIRS}")
Brenden Blanco25245bf2015-05-10 12:15:06 -070025find_library(libclangAnalysis NAMES clangAnalysis HINTS ${CLANG_SEARCH})
26find_library(libclangAST NAMES clangAST HINTS ${CLANG_SEARCH})
27find_library(libclangBasic NAMES clangBasic HINTS ${CLANG_SEARCH})
28find_library(libclangCodeGen NAMES clangCodeGen HINTS ${CLANG_SEARCH})
29find_library(libclangDriver NAMES clangDriver HINTS ${CLANG_SEARCH})
30find_library(libclangEdit NAMES clangEdit HINTS ${CLANG_SEARCH})
31find_library(libclangFrontend NAMES clangFrontend HINTS ${CLANG_SEARCH})
32find_library(libclangLex NAMES clangLex HINTS ${CLANG_SEARCH})
33find_library(libclangParse NAMES clangParse HINTS ${CLANG_SEARCH})
Brenden Blanco7009b552015-05-26 11:48:17 -070034find_library(libclangRewrite NAMES clangRewrite HINTS ${CLANG_SEARCH})
Brenden Blanco25245bf2015-05-10 12:15:06 -070035find_library(libclangSema NAMES clangSema HINTS ${CLANG_SEARCH})
36find_library(libclangSerialization NAMES clangSerialization HINTS ${CLANG_SEARCH})
Brenden Blanco83102912015-06-09 17:43:27 -070037if(libclangBasic STREQUAL "libclangBasic-NOTFOUND")
38 message(FATAL_ERROR "Unable to find clang libraries")
39endif()
Alexei Starovoitov955f3b62015-06-09 19:37:38 -070040FOREACH(DIR ${LLVM_INCLUDE_DIRS})
41 include_directories("${DIR}/../tools/clang/include")
42ENDFOREACH()
Brenden Blancoa94bd932015-04-26 00:56:42 -070043
44set(CMAKE_C_FLAGS "-Wall")
45set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
Brenden Blanco439a9f32015-07-03 16:10:29 -070046endif()
Brenden Blancoa94bd932015-04-26 00:56:42 -070047
Brenden Blancod8acf6f2015-06-07 22:32:33 -070048add_subdirectory(scripts)
Brenden Blanco46176a12015-07-07 13:05:22 -070049add_subdirectory(examples)
Brenden Blancocd5cb412015-04-26 09:41:58 -070050add_subdirectory(src)
51add_subdirectory(tests)