2020-05-04 11:30:17 +08:00
|
|
|
|
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
|
2019-10-08 01:35:13 +08:00
|
|
|
|
|
2020-05-04 11:30:17 +08:00
|
|
|
|
vcpkg_from_github(
|
2019-10-08 01:35:13 +08:00
|
|
|
|
OUT_SOURCE_PATH SOURCE_PATH
|
2020-05-04 11:30:17 +08:00
|
|
|
|
REPO llvm/llvm-project
|
2023-05-27 06:36:20 +08:00
|
|
|
|
REF "llvmorg-${VERSION}"
|
2024-06-06 16:14:30 +08:00
|
|
|
|
SHA512 9e9ec501336127339347c01ffd47768d501a84ef415c6a72fe56d31e867f982baeb3c4659be8e9b8475848a460357f33a6b2aa0ee9f81150e363963b98387bc0
|
2022-06-15 00:07:45 +08:00
|
|
|
|
HEAD_REF main
|
2019-10-08 01:35:13 +08:00
|
|
|
|
PATCHES
|
2023-10-13 01:46:42 +08:00
|
|
|
|
0001-fix-install-package-dir.patch
|
|
|
|
|
0002-fix-tools-install-dir.patch
|
|
|
|
|
0003-fix-llvm-config.patch
|
|
|
|
|
0004-disable-libomp-aliases.patch
|
|
|
|
|
0005-remove-numpy.patch
|
|
|
|
|
0006-create-destination-mlir-directory.patch
|
2024-06-06 16:14:30 +08:00
|
|
|
|
75711.patch # [clang] Add intrin0.h header to mimic intrin0.h used by MSVC STL for clang-cl #75711
|
|
|
|
|
79694.patch # [SEH] Ignore EH pad check for internal intrinsics #79694
|
|
|
|
|
82407.patch # [Clang][Sema] Fix incorrect rejection default construction of union with nontrivial member #82407
|
2019-10-08 01:35:13 +08:00
|
|
|
|
)
|
|
|
|
|
|
2021-04-14 06:17:17 +08:00
|
|
|
|
vcpkg_check_features(
|
|
|
|
|
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
2021-03-30 00:39:04 +08:00
|
|
|
|
FEATURES
|
2021-04-14 06:17:17 +08:00
|
|
|
|
tools LLVM_BUILD_TOOLS
|
|
|
|
|
tools LLVM_INCLUDE_TOOLS
|
|
|
|
|
utils LLVM_BUILD_UTILS
|
|
|
|
|
utils LLVM_INCLUDE_UTILS
|
2022-03-12 03:33:51 +08:00
|
|
|
|
utils LLVM_INSTALL_UTILS
|
2023-10-13 01:46:42 +08:00
|
|
|
|
enable-assertions LLVM_ENABLE_ASSERTIONS
|
2021-04-14 06:17:17 +08:00
|
|
|
|
enable-rtti LLVM_ENABLE_RTTI
|
|
|
|
|
enable-ffi LLVM_ENABLE_FFI
|
|
|
|
|
enable-terminfo LLVM_ENABLE_TERMINFO
|
2023-04-12 14:20:09 +08:00
|
|
|
|
enable-ios COMPILER_RT_ENABLE_IOS
|
2021-04-14 06:17:17 +08:00
|
|
|
|
enable-eh LLVM_ENABLE_EH
|
|
|
|
|
enable-bindings LLVM_ENABLE_BINDINGS
|
2019-10-30 14:06:59 +08:00
|
|
|
|
)
|
|
|
|
|
|
2022-05-17 02:41:53 +08:00
|
|
|
|
vcpkg_cmake_get_vars(cmake_vars_file)
|
|
|
|
|
include("${cmake_vars_file}")
|
|
|
|
|
|
2020-12-01 01:56:22 +08:00
|
|
|
|
# LLVM generates CMake error due to Visual Studio version 16.4 is known to miscompile part of LLVM.
|
|
|
|
|
# LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON disables this error.
|
|
|
|
|
# See https://developercommunity.visualstudio.com/content/problem/845933/miscompile-boolean-condition-deduced-to-be-always.html
|
|
|
|
|
# and thread "[llvm-dev] Longstanding failing tests - clang-tidy, MachO, Polly" on llvm-dev Jan 21-23 2020.
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND VCPKG_DETECTED_MSVC_VERSION LESS "1925")
|
2023-04-12 14:20:09 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
|
2021-06-30 07:08:28 +08:00
|
|
|
|
# Force enable or disable external libraries
|
|
|
|
|
set(llvm_external_libraries
|
|
|
|
|
zlib
|
|
|
|
|
libxml2
|
2023-04-12 14:20:09 +08:00
|
|
|
|
zstd
|
2021-06-30 07:08:28 +08:00
|
|
|
|
)
|
|
|
|
|
foreach(external_library IN LISTS llvm_external_libraries)
|
|
|
|
|
string(TOLOWER "enable-${external_library}" feature_name)
|
|
|
|
|
string(TOUPPER "LLVM_ENABLE_${external_library}" define_name)
|
|
|
|
|
if(feature_name IN_LIST FEATURES)
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-D${define_name}=FORCE_ON
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-D${define_name}=OFF
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2020-05-04 11:30:17 +08:00
|
|
|
|
# LLVM_ABI_BREAKING_CHECKS can be WITH_ASSERTS (default), FORCE_ON or FORCE_OFF.
|
2022-04-22 00:02:13 +08:00
|
|
|
|
# By default in LLVM, abi-breaking checks are enabled if assertions are enabled.
|
|
|
|
|
# however, this breaks linking with the debug versions, since the option is
|
|
|
|
|
# baked into the header files; thus, we always turn off LLVM_ABI_BREAKING_CHECKS
|
|
|
|
|
# unless the user asks for it
|
2020-05-04 11:30:17 +08:00
|
|
|
|
if("enable-abi-breaking-checks" IN_LIST FEATURES)
|
|
|
|
|
# Force enable abi-breaking checks.
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLVM_ABI_BREAKING_CHECKS=FORCE_ON
|
|
|
|
|
)
|
2022-04-22 00:02:13 +08:00
|
|
|
|
else()
|
2020-05-04 11:30:17 +08:00
|
|
|
|
# Force disable abi-breaking checks.
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF
|
|
|
|
|
)
|
2019-10-08 01:35:13 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
2020-05-04 11:30:17 +08:00
|
|
|
|
set(LLVM_ENABLE_PROJECTS)
|
2022-05-17 02:41:53 +08:00
|
|
|
|
if("bolt" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "bolt")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DBOLT_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
|
|
|
|
)
|
2022-05-17 02:41:53 +08:00
|
|
|
|
endif()
|
2020-05-04 11:30:17 +08:00
|
|
|
|
if("clang" IN_LIST FEATURES OR "clang-tools-extra" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "clang")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DCLANG_INSTALL_PACKAGE_DIR:PATH=share/clang
|
|
|
|
|
-DCLANG_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
|
|
|
|
# Disable ARCMT
|
|
|
|
|
-DCLANG_ENABLE_ARCMT=OFF
|
|
|
|
|
# Disable static analyzer
|
|
|
|
|
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
|
|
|
|
|
)
|
|
|
|
|
# 1) LLVM/Clang tools are relocated from ./bin/ to ./tools/llvm/ (CLANG_TOOLS_INSTALL_DIR=tools/llvm)
|
|
|
|
|
# 2) Clang resource files should be relocated from lib/clang/<major_version> to ../tools/llvm/lib/clang/<major_version>
|
|
|
|
|
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${VERSION})
|
2023-11-02 05:24:36 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS -DCLANG_RESOURCE_DIR=lib/clang/${CLANG_VERSION_MAJOR})
|
2020-05-04 11:30:17 +08:00
|
|
|
|
endif()
|
|
|
|
|
if("clang-tools-extra" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "clang-tools-extra")
|
|
|
|
|
endif()
|
|
|
|
|
if("compiler-rt" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "compiler-rt")
|
|
|
|
|
endif()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
if("flang" IN_LIST FEATURES)
|
2022-05-17 02:41:53 +08:00
|
|
|
|
if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
message(FATAL_ERROR "Building Flang with MSVC is not supported on x86. Disable it until issues are fixed.")
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "flang")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DFLANG_INSTALL_PACKAGE_DIR:PATH=share/flang
|
|
|
|
|
-DFLANG_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
|
|
|
|
)
|
2020-12-01 01:56:22 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
# Flang requires C++17
|
|
|
|
|
-DCMAKE_CXX_STANDARD=17
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2021-04-14 06:17:17 +08:00
|
|
|
|
if("libclc" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "libclc")
|
|
|
|
|
endif()
|
2020-05-04 11:30:17 +08:00
|
|
|
|
if("lld" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "lld")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLD_INSTALL_PACKAGE_DIR:PATH=share/lld
|
|
|
|
|
-DLLD_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
|
|
|
|
)
|
2020-05-04 11:30:17 +08:00
|
|
|
|
endif()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
if("lldb" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "lldb")
|
2022-05-17 02:41:53 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLDB_ENABLE_CURSES=OFF
|
|
|
|
|
)
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
|
|
|
|
if("mlir" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "mlir")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DMLIR_INSTALL_PACKAGE_DIR:PATH=share/mlir
|
|
|
|
|
-DMLIR_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
|
|
|
|
-DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF # Disables installation of object files in lib/objects-{CMAKE_BUILD_TYPE}.
|
|
|
|
|
)
|
2023-09-08 04:09:08 +08:00
|
|
|
|
if("enable-mlir-python-bindings" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
|
|
|
|
|
"-Dpybind11_DIR=${CURRENT_INSTALLED_DIR}/share/pybind11"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
2020-05-04 11:30:17 +08:00
|
|
|
|
if("openmp" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "openmp")
|
2024-03-26 06:57:42 +08:00
|
|
|
|
# Perl is required for the OpenMP run-time
|
|
|
|
|
vcpkg_find_acquire_program(PERL)
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLIBOMP_INSTALL_ALIASES=OFF
|
|
|
|
|
-DOPENMP_ENABLE_LIBOMPTARGET=OFF # Currently libomptarget cannot be compiled on Windows or MacOS X.
|
|
|
|
|
-DOPENMP_ENABLE_OMPT_TOOLS=OFF # Currently tools are not tested well on Windows or MacOS X.
|
2024-03-26 06:57:42 +08:00
|
|
|
|
-DPERL_EXECUTABLE=${PERL}
|
2023-10-13 01:46:42 +08:00
|
|
|
|
)
|
2021-04-14 06:17:17 +08:00
|
|
|
|
endif()
|
2020-05-04 11:30:17 +08:00
|
|
|
|
if("polly" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_PROJECTS "polly")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DPOLLY_INSTALL_PACKAGE_DIR:PATH=share/polly
|
|
|
|
|
)
|
2021-02-23 02:49:55 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
2022-05-17 02:41:53 +08:00
|
|
|
|
set(LLVM_ENABLE_RUNTIMES)
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if("libc" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_RUNTIMES "libc")
|
|
|
|
|
endif()
|
2022-05-17 02:41:53 +08:00
|
|
|
|
if("libcxx" IN_LIST FEATURES)
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND VCPKG_DETECTED_MSVC_VERSION LESS "1914")
|
|
|
|
|
# libcxx supports being built with clang-cl, but not with MSVC’s cl.exe, as cl doesn’t support the #include_next extension.
|
|
|
|
|
# Furthermore, VS 2017 or newer (19.14) is required.
|
|
|
|
|
# More info: https://releases.llvm.org/17.0.1/projects/libcxx/docs/BuildingLibcxx.html#support-for-windows
|
|
|
|
|
message(FATAL_ERROR "libcxx requiries MSVC 19.14 or newer.")
|
2022-05-17 02:41:53 +08:00
|
|
|
|
endif()
|
|
|
|
|
list(APPEND LLVM_ENABLE_RUNTIMES "libcxx")
|
|
|
|
|
endif()
|
|
|
|
|
if("libcxxabi" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_RUNTIMES "libcxxabi")
|
|
|
|
|
endif()
|
|
|
|
|
if("libunwind" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_ENABLE_RUNTIMES "libunwind")
|
2024-07-13 22:16:54 +08:00
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLIBCXXABI_USE_LLVM_UNWINDER=ON
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
|
|
|
|
|
)
|
2022-05-17 02:41:53 +08:00
|
|
|
|
endif()
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if("pstl" IN_LIST FEATURES)
|
|
|
|
|
if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
|
|
|
message(FATAL_ERROR "Building pstl with MSVC is not supported.")
|
|
|
|
|
endif()
|
|
|
|
|
list(APPEND LLVM_ENABLE_RUNTIMES "pstl")
|
|
|
|
|
endif()
|
2022-05-17 02:41:53 +08:00
|
|
|
|
|
2022-06-15 00:07:45 +08:00
|
|
|
|
# this is for normal targets
|
2020-10-14 08:54:46 +08:00
|
|
|
|
set(known_llvm_targets
|
2020-12-01 01:56:22 +08:00
|
|
|
|
AArch64
|
|
|
|
|
AMDGPU
|
|
|
|
|
ARM
|
|
|
|
|
AVR
|
|
|
|
|
BPF
|
|
|
|
|
Hexagon
|
|
|
|
|
Lanai
|
2023-10-13 01:46:42 +08:00
|
|
|
|
LoongArch
|
2021-07-23 06:50:52 +08:00
|
|
|
|
Mips
|
2020-12-01 01:56:22 +08:00
|
|
|
|
MSP430
|
|
|
|
|
NVPTX
|
|
|
|
|
PowerPC
|
|
|
|
|
RISCV
|
|
|
|
|
Sparc
|
2021-07-23 06:50:52 +08:00
|
|
|
|
SystemZ
|
2022-05-17 02:41:53 +08:00
|
|
|
|
VE
|
2020-12-01 01:56:22 +08:00
|
|
|
|
WebAssembly
|
|
|
|
|
X86
|
|
|
|
|
XCore
|
|
|
|
|
)
|
2020-03-26 11:43:02 +08:00
|
|
|
|
|
2023-10-13 01:46:42 +08:00
|
|
|
|
set(LLVM_TARGETS_TO_BUILD)
|
2020-10-14 08:54:46 +08:00
|
|
|
|
foreach(llvm_target IN LISTS known_llvm_targets)
|
|
|
|
|
string(TOLOWER "target-${llvm_target}" feature_name)
|
|
|
|
|
if(feature_name IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_TARGETS_TO_BUILD "${llvm_target}")
|
2020-05-04 11:30:17 +08:00
|
|
|
|
endif()
|
2020-10-14 08:54:46 +08:00
|
|
|
|
endforeach()
|
2019-10-08 01:35:13 +08:00
|
|
|
|
|
2022-06-15 00:07:45 +08:00
|
|
|
|
# this is for experimental targets
|
|
|
|
|
set(known_llvm_experimental_targets
|
2023-10-13 01:46:42 +08:00
|
|
|
|
ARC
|
|
|
|
|
CSKY
|
|
|
|
|
DirectX
|
|
|
|
|
M68k
|
|
|
|
|
SPIRV
|
|
|
|
|
Xtensa
|
2022-06-15 00:07:45 +08:00
|
|
|
|
)
|
|
|
|
|
|
2023-10-13 01:46:42 +08:00
|
|
|
|
set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD)
|
2022-06-15 00:07:45 +08:00
|
|
|
|
foreach(llvm_target IN LISTS known_llvm_experimental_targets)
|
|
|
|
|
string(TOLOWER "target-${llvm_target}" feature_name)
|
|
|
|
|
if(feature_name IN_LIST FEATURES)
|
|
|
|
|
list(APPEND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "${llvm_target}")
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2020-05-04 11:30:17 +08:00
|
|
|
|
vcpkg_find_acquire_program(PYTHON3)
|
2020-12-01 01:56:22 +08:00
|
|
|
|
get_filename_component(PYTHON3_DIR ${PYTHON3} DIRECTORY)
|
2023-04-12 14:20:09 +08:00
|
|
|
|
vcpkg_add_to_path("${PYTHON3_DIR}")
|
2019-10-08 01:35:13 +08:00
|
|
|
|
|
2023-04-12 14:20:09 +08:00
|
|
|
|
file(REMOVE "${SOURCE_PATH}/llvm/cmake/modules/Findzstd.cmake")
|
|
|
|
|
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if("${LLVM_ENABLE_RUNTIMES}" STREQUAL "")
|
|
|
|
|
list(APPEND FEATURE_OPTIONS
|
|
|
|
|
-DLLVM_INCLUDE_RUNTIMES=OFF
|
|
|
|
|
-DLLVM_BUILD_RUNTIMES=OFF
|
|
|
|
|
-DLLVM_BUILD_RUNTIME=OFF
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# At least one target must be specified, otherwise default to "all".
|
|
|
|
|
if("${LLVM_TARGETS_TO_BUILD}" STREQUAL "")
|
|
|
|
|
set(LLVM_TARGETS_TO_BUILD "all")
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-21 00:21:15 +08:00
|
|
|
|
vcpkg_cmake_configure(
|
2023-04-12 14:20:09 +08:00
|
|
|
|
SOURCE_PATH "${SOURCE_PATH}/llvm"
|
2020-05-04 11:30:17 +08:00
|
|
|
|
OPTIONS
|
|
|
|
|
-DLLVM_INCLUDE_EXAMPLES=OFF
|
|
|
|
|
-DLLVM_BUILD_EXAMPLES=OFF
|
|
|
|
|
-DLLVM_INCLUDE_TESTS=OFF
|
|
|
|
|
-DLLVM_BUILD_TESTS=OFF
|
2022-05-17 02:41:53 +08:00
|
|
|
|
-DLLVM_INCLUDE_BENCHMARKS=OFF
|
|
|
|
|
-DLLVM_BUILD_BENCHMARKS=OFF
|
2020-05-04 11:30:17 +08:00
|
|
|
|
# Force TableGen to be built with optimization. This will significantly improve build time.
|
|
|
|
|
-DLLVM_OPTIMIZED_TABLEGEN=ON
|
2023-10-13 01:46:42 +08:00
|
|
|
|
-DPACKAGE_VERSION=${VERSION}
|
|
|
|
|
# Limit the maximum number of concurrent link jobs to 1. This should fix low amount of memory issue for link.
|
|
|
|
|
-DLLVM_PARALLEL_LINK_JOBS=1
|
|
|
|
|
-DLLVM_INSTALL_PACKAGE_DIR:PATH=share/llvm
|
|
|
|
|
-DLLVM_TOOLS_INSTALL_DIR:PATH=tools/llvm
|
2020-12-01 01:56:22 +08:00
|
|
|
|
"-DLLVM_ENABLE_PROJECTS=${LLVM_ENABLE_PROJECTS}"
|
2022-05-17 02:41:53 +08:00
|
|
|
|
"-DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES}"
|
2020-12-01 01:56:22 +08:00
|
|
|
|
"-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}"
|
2022-06-15 00:07:45 +08:00
|
|
|
|
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}"
|
2023-10-13 01:46:42 +08:00
|
|
|
|
${FEATURE_OPTIONS}
|
2023-04-12 14:20:09 +08:00
|
|
|
|
MAYBE_UNUSED_VARIABLES
|
|
|
|
|
COMPILER_RT_ENABLE_IOS
|
2019-10-08 01:35:13 +08:00
|
|
|
|
)
|
|
|
|
|
|
2021-12-21 00:21:15 +08:00
|
|
|
|
vcpkg_cmake_install(ADD_BIN_TO_PATH)
|
2020-05-04 11:30:17 +08:00
|
|
|
|
|
2021-12-21 00:21:15 +08:00
|
|
|
|
function(llvm_cmake_package_config_fixup package_name)
|
2023-01-19 03:42:07 +08:00
|
|
|
|
cmake_parse_arguments("arg" "DO_NOT_DELETE_PARENT_CONFIG_PATH" "FEATURE_NAME;CONFIG_PATH" "" ${ARGN})
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if(NOT DEFINED arg_FEATURE_NAME)
|
|
|
|
|
set(arg_FEATURE_NAME ${package_name})
|
2020-05-16 04:28:48 +08:00
|
|
|
|
endif()
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if("${arg_FEATURE_NAME}" STREQUAL "${PORT}" OR "${arg_FEATURE_NAME}" IN_LIST FEATURES)
|
|
|
|
|
set(args)
|
|
|
|
|
list(APPEND args PACKAGE_NAME "${package_name}")
|
|
|
|
|
if(arg_DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
|
|
|
|
list(APPEND args "DO_NOT_DELETE_PARENT_CONFIG_PATH")
|
|
|
|
|
endif()
|
2023-01-19 03:42:07 +08:00
|
|
|
|
if(arg_CONFIG_PATH)
|
|
|
|
|
list(APPEND args "CONFIG_PATH" "${arg_CONFIG_PATH}")
|
|
|
|
|
endif()
|
2021-12-21 00:21:15 +08:00
|
|
|
|
vcpkg_cmake_config_fixup(${args})
|
2023-01-19 03:42:07 +08:00
|
|
|
|
file(INSTALL "${SOURCE_PATH}/${arg_FEATURE_NAME}/LICENSE.TXT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${package_name}" RENAME copyright)
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${package_name}_usage")
|
|
|
|
|
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/${package_name}_usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${package_name}" RENAME usage)
|
|
|
|
|
endif()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
2021-12-21 00:21:15 +08:00
|
|
|
|
endfunction()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
|
2021-12-21 00:21:15 +08:00
|
|
|
|
llvm_cmake_package_config_fixup("clang" DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
|
|
|
|
llvm_cmake_package_config_fixup("flang" DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
|
|
|
|
llvm_cmake_package_config_fixup("lld" DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
|
|
|
|
llvm_cmake_package_config_fixup("mlir" DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
|
|
|
|
llvm_cmake_package_config_fixup("polly" DO_NOT_DELETE_PARENT_CONFIG_PATH)
|
2023-01-19 03:42:07 +08:00
|
|
|
|
llvm_cmake_package_config_fixup("ParallelSTL" FEATURE_NAME "pstl" DO_NOT_DELETE_PARENT_CONFIG_PATH CONFIG_PATH "lib/cmake/ParallelSTL")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
llvm_cmake_package_config_fixup("llvm")
|
2020-05-04 11:30:17 +08:00
|
|
|
|
|
2024-06-06 16:14:30 +08:00
|
|
|
|
if("mlir" IN_LIST FEATURES)
|
|
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mlir/MLIRConfig.cmake" "set(MLIR_MAIN_SRC_DIR \"${SOURCE_PATH}/mlir\")" "")
|
|
|
|
|
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mlir/MLIRConfig.cmake" "${CURRENT_BUILDTREES_DIR}" "\${MLIR_INCLUDE_DIRS}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
|
2024-06-06 16:14:30 +08:00
|
|
|
|
# Move Clang's runtime libraries from bin/lib to tools/${PORT}/lib
|
|
|
|
|
if(EXISTS "${CURRENT_PACKAGES_DIR}/bin/lib")
|
|
|
|
|
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
|
|
|
|
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/lib" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/lib")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/bin/lib")
|
|
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin/lib")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Remove empty directories to avoid vcpkg warning
|
|
|
|
|
set(empty_dirs)
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if("clang-tools-extra" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin")
|
2023-04-19 07:58:38 +08:00
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/clang-tidy/misc/ConfusableTable")
|
2020-11-13 09:31:34 +08:00
|
|
|
|
endif()
|
2023-01-19 03:42:07 +08:00
|
|
|
|
if("pstl" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/lib/cmake")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/debug/lib/cmake")
|
|
|
|
|
endif()
|
2023-01-19 03:42:07 +08:00
|
|
|
|
endif()
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if("flang" IN_LIST FEATURES)
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/CMakeFiles")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Config")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Optimizer/CMakeFiles")
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Optimizer/CodeGen/CMakeFiles")
|
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Optimizer/Dialect/CMakeFiles")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Optimizer/HLFIR/CMakeFiles")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
list(APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Optimizer/Transforms/CMakeFiles")
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
2021-12-21 00:21:15 +08:00
|
|
|
|
if(empty_dirs)
|
|
|
|
|
foreach(empty_dir IN LISTS empty_dirs)
|
|
|
|
|
if(NOT EXISTS "${empty_dir}")
|
2023-10-13 01:46:42 +08:00
|
|
|
|
message(WARNING "Directory '${empty_dir}' does not exist. Please remove it from the list of empty directories.")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
else()
|
|
|
|
|
file(GLOB_RECURSE files_in_dir "${empty_dir}/*")
|
|
|
|
|
if(files_in_dir)
|
2023-10-13 01:46:42 +08:00
|
|
|
|
message(WARNING "Directory '${empty_dir}' is not empty. Please remove it from the list of empty directories.")
|
2021-12-21 00:21:15 +08:00
|
|
|
|
else()
|
|
|
|
|
file(REMOVE_RECURSE "${empty_dir}")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
2020-12-01 01:56:22 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
2024-06-06 16:14:30 +08:00
|
|
|
|
# Remove debug headers and tools
|
2020-11-13 09:31:34 +08:00
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
2022-05-17 02:41:53 +08:00
|
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
|
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/share"
|
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/tools"
|
|
|
|
|
)
|
2020-05-04 11:30:17 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
2024-06-06 16:14:30 +08:00
|
|
|
|
# LLVM generates shared libraries in a static build (LLVM-C.dll, libclang.dll, LTO.dll, Remarks.dll, ...)
|
|
|
|
|
# for the corresponding export targets (used in LLVMExports-<config>.cmake files on the Windows platform)
|
2023-10-13 01:46:42 +08:00
|
|
|
|
if(VCPKG_TARGET_IS_WINDOWS)
|
|
|
|
|
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
|
|
|
|
|
else()
|
|
|
|
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin"
|
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/bin"
|
|
|
|
|
)
|
|
|
|
|
endif()
|