forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
103 lines (90 loc) · 4.63 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#---Define the way we want to build and what of llvm/clang/cling------------------------------------
set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
set(LLVM_BUILD_TOOLS OFF CACHE BOOL "")
set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON CACHE BOOL "")
# We only use llvm/clang through TCling which is (with the help of core/meta) already taking a lock
# to serialize access to llvm. We can later review how to make this finer grained by using llvm's own locking
# mechanism.
set(LLVM_ENABLE_THREADS OFF CACHE BOOL "")
if(cxx14)
set(LLVM_ENABLE_CXX1Y ON CACHE BOOL "")
endif()
set(CMAKE_REQUIRED_QUIET 1) # Make the configuration of LLVM quiet
if(ROOT_ARCHITECTURE MATCHES linuxarm64)
set(ROOT_CLING_TARGET "AArch64")
elseif(ROOT_ARCHITECTURE MATCHES linuxppc64gcc)
set(ROOT_CLING_TARGET "PowerPC")
elseif(ROOT_ARCHITECTURE MATCHES linux)
set(ROOT_CLING_TARGET "X86")
elseif(ROOT_ARCHITECTURE MATCHES macosx)
set(ROOT_CLING_TARGET "X86")
else()
set(ROOT_CLING_TARGET "all")
endif()
set(LLVM_TARGETS_TO_BUILD ${ROOT_CLING_TARGET} CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
#---Protect against warnings clang/gcc would fire----------------------------------------------------
set(INTERP_COMMON_ADDITIONAL_FLAGS "-Wno-comment -Wno-unused-parameter")
if(CMAKE_COMPILER_IS_GNUCXX)
set(INTERP_ADDITIONAL_FLAGS "${INTERP_COMMON_ADDITIONAL_FLAGS} -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-missing-field-initializers")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(INTERP_ADDITIONAL_FLAGS "${INTERP_COMMON_ADDITIONAL_FLAGS} -Wno-conditional-uninitialized -Wno-parentheses-equality -Wno-unused-private-field")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INTERP_ADDITIONAL_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INTERP_ADDITIONAL_FLAGS}")
#---Do not transform warnings in errors-------------------------------------------------------------
string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
#---Build LLVM/Clang with symbol visibility=hidden--------------------------------------------------
ROOT_ADD_CXX_FLAG(CMAKE_CXX_FLAGS -fvisibility=hidden)
#---Build type--------------------------------------------------------------------------------------
if(NOT DEFINED LLVM_BUILD_TYPE)
set(LLVM_BUILD_TYPE Release CACHE STRING "Build type for LLVM (used to set CMAKE_BUILD_TYPE)")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LLVM_ENABLE_ASSERTIONS "YES")
else()
if(LLVM_BUILD_TYPE STREQUAL "Debug")
set(LLVM_ENABLE_ASSERTIONS "YES")
else()
set(LLVM_ENABLE_ASSERTIONS "NO")
endif()
endif()
set(CMAKE_BUILD_TYPE ${LLVM_BUILD_TYPE})
#--- Do not build cling as part of llvm.
set(LLVM_NOCLING "YES")
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_COMPILER OFF CACHE BOOL "")
set(CLANG_ENABLE_FORMAT OFF CACHE BOOL "")
#---Add the sub-directory excluding all the targets from all-----------------------------------------
if(CMAKE_GENERATOR MATCHES "Xcode")
add_subdirectory(llvm/src)
else()
add_subdirectory(llvm/src EXCLUDE_FROM_ALL)
endif()
#---Avoid to dependencies to system (e.g. atomic) libraries without modifying the LLVM code----------
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
get_target_property(__libs LLVMSupport INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM __libs atomic)
set_target_properties(LLVMSupport PROPERTIES INTERFACE_LINK_LIBRARIES "${__libs}")
endif()
#---Mark the LLVM/CLANG variables as advanced--------------------------------------------------------
get_cmake_property(variables CACHE_VARIABLES)
foreach(var ${variables})
if(var MATCHES "^(CLANG|LLVM|CLING)_")
mark_as_advanced(FORCE ${var})
endif()
endforeach()
mark_as_advanced(FORCE BUG_REPORT_URL BUILD_CLANG_FORMAT_VS_PLUGIN BUILD_SHARED_LIBS BUILD_TESTING
C_INCLUDE_DIRS DEFAULT_SYSROOT FFI_INCLUDE_DIR FFI_LIBRARY_DIR
GCC_INSTALL_PREFIX LIBCLANG_BUILD_STATIC TOOL_INFO_PLIST)
mark_as_advanced(CLEAR LLVM_ENABLE_ASSERTIONS LLVM_BUILD_TYPE)
#---Set into parent scope LLVM_VERSION --------------------------------------------------------------
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/llvm/src/configure _filestr)
string(REGEX REPLACE ".*PACKAGE_VERSION='([0-9]+[.][0-9]+[.][0-9]+).*" "\\1" _llvm_version ${_filestr})
set(LLVM_VERSION ${_llvm_version} PARENT_SCOPE)
#---Added some missing dependencies------------------------------------------------------------------
add_dependencies(clingUtils clangCodeGen)
add_dependencies(clingInterpreter clangBasic clangAST ClangDriverOptions)
add_dependencies(clingMetaProcessor clangAST ClangDriverOptions)