Skip to content

Commit

Permalink
LLVM is only used by the C++ parser module, which should be reflected…
Browse files Browse the repository at this point in the history
… by the build system.

Based on the original work of Whisperity <whisperity@gmail.com>.
  • Loading branch information
mcserep committed Aug 5, 2019
1 parent ed8f58d commit e86b33b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
19 changes: 3 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,31 @@ include(Functions.cmake)
include(Testing.cmake)

find_package(Threads REQUIRED)
find_package(LLVM REQUIRED CONFIG)
find_package(Boost REQUIRED COMPONENTS filesystem log program_options regex system thread)
find_package(Odb REQUIRED)
find_package(Thrift REQUIRED)
find_package(Java REQUIRED)
find_package(GTest)

# Check whether RTTI is on for LLVM
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "Using ClangConfig.cmake in: ${Clang_DIR}")
message(STATUS "Using RTTI for LLVM: ${LLVM_ENABLE_RTTI}")
if(NOT LLVM_ENABLE_RTTI)
message(SEND_ERROR "RTTI is required for LLVM")
endif()

include(UseJava)

# Set the third-party libraries' path properly so the installation can find them.
include(Exports.cmake)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${RUNENV_LD_LIBRARY_PATH}")

# Modules
add_subdirectory(model)
add_subdirectory(util)
add_subdirectory(parser)
add_subdirectory(plugins)
add_subdirectory(webserver)
add_subdirectory(service)
add_subdirectory(logger)
add_subdirectory(scripts)
add_subdirectory(webgui)
# Plugins
add_subdirectory(plugins)

# Install java libraries
install(DIRECTORY
lib/java/
DESTINATION "${INSTALL_JAVA_LIB_DIR}")

# Install Clang additional files
install(DIRECTORY
${LLVM_LIBRARY_DIRS}/clang
DESTINATION "${INSTALL_LIB_DIR}")
3 changes: 0 additions & 3 deletions Exports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ endfunction(mark_as_run_env_path)
set(RUNENV_LD_LIBRARY_PATH ""
CACHE INTERNAL "Environment variable exported to install." FORCE)

# LLVM
mark_as_run_env_path(LD_LIBRARY_PATH "${LLVM_BUILD_LIBRARY_DIR}")

# ODB
filelist_to_dirlist_unique(_odbLibDirs "${ODB_LIBRARIES}")
mark_as_run_env_path(LD_LIBRARY_PATH "${_odbLibDirs}")
Expand Down
2 changes: 1 addition & 1 deletion Functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(generate_odb_files _src)
set(ODB_CXX_SOURCES ${SOURCES} PARENT_SCOPE)
endfunction(generate_odb_files)

# add new odb static library
# Add a new static library target that links against ODB.
function(add_odb_library _name)
add_library(${_name} STATIC ${ARGN})
target_compile_options(${_name} PUBLIC -Wno-unknown-pragmas -fPIC)
Expand Down
9 changes: 6 additions & 3 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ include_directories(SYSTEM

# Add all subdirectories to the build
file(GLOB plugins RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/*")
message(STATUS "Adding new plugins:")

# Set unique plugin directory variable for each plugin
message(STATUS "Found the following CodeCompass plugins:")
foreach(_plugin ${plugins})
set(${_plugin}_PLUGIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_plugin}")
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_plugin}")
set(${_plugin}_PLUGIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_plugin}")
message(STATUS " ${_plugin}")
endif()
endforeach(_plugin)

# Add plugins
foreach(_plugin ${plugins})
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_plugin}")
set(PLUGIN_NAME ${_plugin})
set(PLUGIN_DIR ${${_plugin}_PLUGIN_DIR})
message(STATUS " ${_plugin}")
fancy_message("Loading plugin ${_plugin}" "blue" TRUE)
add_subdirectory(${_plugin})
endif()
endforeach(_plugin)
21 changes: 19 additions & 2 deletions plugins/cpp/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
find_package(LLVM REQUIRED CONFIG)
find_package(Clang REQUIRED CONFIG)

# Check whether RTTI is on for LLVM
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "Using ClangConfig.cmake in: ${Clang_DIR}")
message(STATUS "Using RTTI for LLVM: ${LLVM_ENABLE_RTTI}")
if(NOT LLVM_ENABLE_RTTI)
message(SEND_ERROR "RTTI is required for LLVM")
endif()

# Add LLVM to the library path
mark_as_run_env_path(LD_LIBRARY_PATH "${LLVM_BUILD_LIBRARY_DIR}")

include_directories(
include
${CMAKE_SOURCE_DIR}/parser/include
Expand Down Expand Up @@ -38,9 +51,13 @@ target_link_libraries(cppparser
clangAST
clangLex
clangBasic
clang
)
clang)

target_compile_options(cppparser PUBLIC -Wno-unknown-pragmas)

install(TARGETS cppparser DESTINATION ${INSTALL_PARSER_DIR})

# Install Clang additional files
install(DIRECTORY
${LLVM_LIBRARY_DIRS}/clang
DESTINATION "${INSTALL_LIB_DIR}")
2 changes: 2 additions & 0 deletions plugins/git/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(Git REQUIRED)

add_subdirectory(parser)
add_subdirectory(service)

Expand Down
1 change: 0 additions & 1 deletion util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include_directories(
${PROJECT_SOURCE_DIR}/util/include
${PROJECT_SOURCE_DIR}/model/include
${LLVM_INCLUDE_DIRS}
${BOOST_INCLUDE_DIRS})

include_directories(SYSTEM
Expand Down

0 comments on commit e86b33b

Please sign in to comment.