-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Dependendency Installation (#707)
* Do not install phasar's dependencies to the global namespace anymore * fix for in-tree build * out-factor the inclusion of LLVM and clang to a separate cmake file * Make PHASAR_CONFIG_INSTALL_DIR respect the CMAKE_INSTALL_PREFIX, even if that is not set at configure time * Fix in-tree build
- Loading branch information
1 parent
866ec8f
commit 8052296
Showing
4 changed files
with
180 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
macro(add_llvm) | ||
|
||
if (NOT PHASAR_IN_TREE) | ||
# Only search for LLVM if we build out of tree | ||
find_package(LLVM 14 REQUIRED CONFIG) | ||
find_library(LLVM_LIBRARY NAMES LLVM PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) | ||
|
||
if(USE_LLVM_FAT_LIB AND ${LLVM_LIBRARY} STREQUAL "LLVM_LIBRARY-NOTFOUND") | ||
message(WARNING "Did not find requested libLLVM.so. Link against individual modules instead") | ||
set(USE_LLVM_FAT_LIB OFF) | ||
elseif(BUILD_SHARED_LIBS AND NOT ${LLVM_LIBRARY} STREQUAL "LLVM_LIBRARY-NOTFOUND") | ||
message(STATUS "Found consolidated shared LLVM lib ${LLVM_LIBRARY} that will be linked against.") | ||
set(USE_LLVM_FAT_LIB ON) | ||
endif() | ||
|
||
if (NOT USE_LLVM_FAT_LIB) | ||
message(STATUS "Link against individual LLVM modules") | ||
set(LLVM_REQUIRED_LIBRARIES | ||
Core | ||
Support | ||
BitWriter | ||
Analysis | ||
Passes | ||
Demangle | ||
Analysis | ||
IRReader | ||
Linker | ||
) | ||
foreach(lib ${LLVM_REQUIRED_LIBRARIES}) | ||
find_library(LLVM_SMALL_LIB${lib} NAMES LLVM${lib} PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) | ||
if(LLVM_SMALL_LIB${lib} MATCHES "NOTFOUND$") | ||
list(APPEND LLVM_SMALL_LIB_NOTFOUND "LLVM${lib}") | ||
endif() | ||
endforeach() | ||
|
||
if(DEFINED LLVM_SMALL_LIB_NOTFOUND) | ||
if(${LLVM_LIBRARY} STREQUAL "LLVM_LIBRARY-NOTFOUND") | ||
message(FATAL_ERROR "Did not find a complete version of LLVM: Did not find the fat lib libLLVM.so, but also did not find the individual modules ${LLVM_SMALL_LIB_NOTFOUND}.") | ||
else() | ||
set(USE_LLVM_FAT_LIB ON) | ||
list(JOIN LLVM_SMALL_LIB_NOTFOUND ", " LLVM_SMALL_LIB_NOTFOUND_PRETTY) | ||
message(WARNING "Did not find the LLVM modules ${LLVM_SMALL_LIB_NOTFOUND_PRETTY}. Fallback to link against ${LLVM_LIBRARY}. To silence this warning, set -DUSE_LLVM_FAT_LIB=ON in the cmake invocation.") | ||
endif() | ||
endif(DEFINED LLVM_SMALL_LIB_NOTFOUND) | ||
endif(NOT USE_LLVM_FAT_LIB) | ||
endif(NOT PHASAR_IN_TREE) | ||
|
||
if(NOT LLVM_ENABLE_RTTI AND NOT PHASAR_IN_TREE) | ||
message(FATAL_ERROR "PhASAR requires a LLVM version that is built with RTTI") | ||
endif() | ||
|
||
endmacro() | ||
|
||
macro(add_clang) | ||
# The clang-cpp shared library is now the preferred way to link dynamically against libclang if we build out of tree. | ||
if(NOT PHASAR_IN_TREE) | ||
find_library(CLANG_LIBRARY NAMES clang-cpp libclang-cpp HINTS ${LLVM_LIBRARY_DIRS}) | ||
if(${CLANG_LIBRARY} STREQUAL "CLANG_LIBRARY-NOTFOUND") | ||
set(NEED_LIBCLANG_COMPONENT_LIBS ON) | ||
endif() | ||
endif() | ||
# As fallback, look for the small clang libraries | ||
if(PHASAR_IN_TREE OR NEED_LIBCLANG_COMPONENT_LIBS) | ||
set(CLANG_LIBRARY | ||
clangTooling | ||
clangFrontendTool | ||
clangFrontend | ||
clangDriver | ||
clangSerialization | ||
clangCodeGen | ||
clangParse | ||
clangSema | ||
clangStaticAnalyzerFrontend | ||
clangStaticAnalyzerCheckers | ||
clangStaticAnalyzerCore | ||
clangAnalysis | ||
clangARCMigrate | ||
clangRewrite | ||
clangRewriteFrontend | ||
clangEdit | ||
clangAST | ||
clangASTMatchers | ||
clangLex | ||
clangBasic | ||
LLVMFrontendOpenMP) | ||
endif() | ||
|
||
if (PHASAR_IN_TREE) | ||
# Phasar needs clang headers, specificaly some that are generated by clangs table-gen | ||
include_directories( | ||
${CLANG_INCLUDE_DIR} | ||
${PHASAR_SRC_DIR}/../clang/include | ||
${PROJECT_BINARY_DIR}/tools/clang/include | ||
) | ||
endif() | ||
endmacro(add_clang) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
function(add_nlohmann_json) | ||
set(JSON_BuildTests OFF) | ||
set(JSON_Install OFF) | ||
|
||
if (PHASAR_IN_TREE) | ||
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json) | ||
endif() | ||
|
||
add_subdirectory(external/json EXCLUDE_FROM_ALL) | ||
set_property(TARGET nlohmann_json APPEND PROPERTY | ||
INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> | ||
) | ||
|
||
install(TARGETS nlohmann_json | ||
EXPORT ${PHASAR_DEPS_EXPORT_SET} | ||
LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib | ||
ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib | ||
RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin | ||
) | ||
install(DIRECTORY external/json/include/ | ||
DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include | ||
) | ||
endfunction() | ||
|
||
function(add_json_schema_validator) | ||
# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here | ||
# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator | ||
# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as | ||
# in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs | ||
# to be installed. | ||
# The following workaround may collapse or become unnecessary once the issue is | ||
# changed or fixed in nlohmann_json_schema_validator. | ||
if (PHASAR_IN_TREE) | ||
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator) | ||
endif() | ||
|
||
set(JSON_VALIDATOR_INSTALL OFF) | ||
|
||
add_subdirectory(external/json-schema-validator EXCLUDE_FROM_ALL) | ||
set_property(TARGET nlohmann_json_schema_validator APPEND PROPERTY | ||
INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> | ||
) | ||
|
||
install(TARGETS nlohmann_json_schema_validator | ||
EXPORT ${PHASAR_DEPS_EXPORT_SET} | ||
LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib | ||
ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib | ||
RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin | ||
) | ||
install(FILES external/json-schema-validator/src/nlohmann/json-schema.hpp | ||
DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann | ||
) | ||
endfunction() |