diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a32768f6abe..b04ee5fce9d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,11 @@ include(GNUInstallDirs) include(CheckCXXCompilerFlag) include(cmake/FindCompilerFlag.cmake) + +option(ENABLE_INTROSPECTIONS "Enable introspection tool" OFF) +option(ENABLE_LUA "Enable lua bindings" OFF) +option(ENABLE_PYTHON "Enable python binding" OFF) +option(ENABLE_SHARED "Enable shared libraries" OFF) option(ENABLE_LLVM_NATIVECODEGEN "Enable use of llvm nativecodegen module (needed by rw-engine)" ON) option(ENABLE_RTTI "Enable compiling with real time type information" OFF) option(ENABLE_LLVM_SHARED "Enable linking LLVM as a shared library" OFF) @@ -179,16 +184,23 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ${CXX_ISYSTEM_DIRS}") add_subdirectory(src) -add_subdirectory(introspection) + +if(ENABLE_INTROSPECTIONS) + add_subdirectory(introspection) +endif(ENABLE_INTROSPECTIONS) + if(ENABLE_CLANG_JIT) -if(ENABLE_EXAMPLES) -add_subdirectory(examples) -endif(ENABLE_EXAMPLES) -if(ENABLE_MAN) -add_subdirectory(man) -endif(ENABLE_MAN) -if(ENABLE_TESTS) -add_subdirectory(tests) -endif(ENABLE_TESTS) -add_subdirectory(tools) + if(ENABLE_EXAMPLES) + add_subdirectory(examples) + endif(ENABLE_EXAMPLES) + + if(ENABLE_MAN) + add_subdirectory(man) + endif(ENABLE_MAN) + + if(ENABLE_TESTS) + add_subdirectory(tests) + endif(ENABLE_TESTS) + + add_subdirectory(tools) endif(ENABLE_CLANG_JIT) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37b7e2896e34..7acd57eb6cf6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,18 +4,24 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") if (ENABLE_RTTI) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti") else() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) if(NOT PYTHON_ONLY) -add_subdirectory(cc) + add_subdirectory(cc) endif() + if(ENABLE_CLANG_JIT) -add_subdirectory(python) -add_subdirectory(lua) + if(ENABLE_PYTHON) + add_subdirectory(python) + endif(ENABLE_PYTHON) + + if(ENABLE_LUA) + add_subdirectory(lua) + endif(ENABLE_LUA) endif() diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt index ffe8feec2592..b558eb7a5773 100644 --- a/src/cc/CMakeLists.txt +++ b/src/cc/CMakeLists.txt @@ -3,15 +3,15 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -# to be removed -include_directories(${CMAKE_CURRENT_BINARY_DIR}/frontends/b) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/b) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/clang) include_directories(${LLVM_INCLUDE_DIRS}) include_directories(${LIBELF_INCLUDE_DIRS}) + if (LIBDEBUGINFOD_FOUND) include_directories(${LIBDEBUGINFOD_INCLUDE_DIRS}) endif (LIBDEBUGINFOD_FOUND) + # todo: if check for kernel version if (CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND) include_directories(${LIBBPF_INCLUDE_DIRS}) @@ -38,8 +38,6 @@ endif() string(REGEX MATCH "^([0-9]+).*" _ ${LLVM_PACKAGE_VERSION}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_MAJOR_VERSION=${CMAKE_MATCH_1}") -include(static_libstdc++) - if(LIBBPF_INCLUDE_DIR) # Add user libbpf include and notify compilation # that we are using external libbpf. It's checked @@ -82,11 +80,13 @@ if(LIBBPF_FOUND) endif() if(ENABLE_CLANG_JIT) -add_library(bcc-shared SHARED - link_all.cc ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} - ${bcc_util_sources}) -set_target_properties(bcc-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0) -set_target_properties(bcc-shared PROPERTIES OUTPUT_NAME bcc) + if(ENABLE_SHARED) + add_library(bcc-shared SHARED + link_all.cc ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} + ${bcc_util_sources}) + set_target_properties(bcc-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0) + set_target_properties(bcc-shared PROPERTIES OUTPUT_NAME bcc) + endif(ENABLE_SHARED) if(ENABLE_USDT) add_definitions(-DEXPORT_USDT) @@ -106,16 +106,19 @@ set(bpf_sources libbpf.c perf_reader.c ${libbpf_sources} ${bcc_sym_sources} ${bc add_library(bpf-static STATIC ${bpf_sources}) set_target_properties(bpf-static PROPERTIES OUTPUT_NAME bcc_bpf) target_link_libraries(bpf-static elf z) -add_library(bpf-shared SHARED ${bpf_sources}) -set_target_properties(bpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0) -set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bcc_bpf) -target_link_libraries(bpf-shared elf z) -if(LIBDEBUGINFOD_FOUND) - target_link_libraries(bpf-shared ${LIBDEBUGINFOD_LIBRARIES}) -endif(LIBDEBUGINFOD_FOUND) -if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND) - target_link_libraries(bpf-shared ${LIBBPF_LIBRARIES}) -endif() + +if(ENABLE_SHARED) + add_library(bpf-shared SHARED ${bpf_sources}) + set_target_properties(bpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0) + set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bcc_bpf) + target_link_libraries(bpf-shared elf z) + if(LIBDEBUGINFOD_FOUND) + target_link_libraries(bpf-shared ${LIBDEBUGINFOD_LIBRARIES}) + endif(LIBDEBUGINFOD_FOUND) + if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND) + target_link_libraries(bpf-shared ${LIBBPF_LIBRARIES}) + endif() +endif(ENABLE_SHARED) include(clang_libs) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${clang_lib_exclude_flags}") @@ -161,15 +164,25 @@ endif() add_subdirectory(frontends) # Link against LLVM libraries -target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) +if(ENABLE_SHARED) + target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) +endif(ENABLE_SHARED) + target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static) set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua}) -install(TARGETS bcc-shared bcc-static bcc-loader-static bpf-static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS bcc-static bcc-loader-static bpf-static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${bcc_table_headers} DESTINATION include/bcc) install(FILES ${bcc_api_headers} DESTINATION include/bcc) install(DIRECTORY ${libbpf_uapi} DESTINATION include/bcc/compat/linux FILES_MATCHING PATTERN "*.h") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +if(ENABLE_SHARED) + install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif(ENABLE_SHARED) + endif(ENABLE_CLANG_JIT) install(FILES ${bcc_common_headers} DESTINATION include/bcc) -install(TARGETS bpf-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(ENABLE_SHARED) + install(TARGETS bpf-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif(ENABLE_SHARED)