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
O U T _ S O U R C E _ P A T H S O U R C E _ P A T H
2020-05-04 11:30:17 +08:00
R E P O l l v m / l l v m - p r o j e c t
2023-01-25 12:21:30 +08:00
R E F l l v m o r g - $ { V E R S I O N }
S H A 5 1 2 d 6 4 f 9 7 7 5 4 c 2 4 f 3 2 d e b 5 f 2 8 4 e b b d 4 8 6 b 3 a 4 6 7 9 7 8 b 7 4 6 3 d 6 2 2 f 5 0 d 5 2 3 7 f f f 9 1 1 0 8 6 1 6 1 3 7 b 4 3 9 4 f 1 d 1 c e 8 3 6 e f a 5 9 b f 7 b e c 6 7 5 b 6 d e e 2 5 7 a 7 9 b 2 4 1 c 1 5 b e 5 2 d 4 6 9 7 4 6 0
2022-06-15 00:07:45 +08:00
H E A D _ R E F m a i n
2019-10-08 01:35:13 +08:00
P A T C H E S
2020-12-01 01:56:22 +08:00
0 0 0 2 - f i x - i n s t a l l - p a t h s . p a t c h # This patch fixes paths in ClangConfig.cmake, LLVMConfig.cmake, LLDConfig.cmake etc.
2020-08-28 03:27:39 +08:00
0 0 0 4 - f i x - d r - 1 7 3 4 . p a t c h
2020-11-13 09:31:34 +08:00
0 0 0 5 - f i x - t o o l s - p a t h . p a t c h
2021-04-14 06:17:17 +08:00
0 0 0 7 - f i x - c o m p i l e r - r t - i n s t a l l - p a t h . p a t c h
0 0 0 9 - f i x - t o o l s - i n s t a l l - p a t h . p a t c h
2021-06-30 07:08:28 +08:00
0 0 1 0 - f i x - l i b f f i . p a t c h
2022-05-17 02:41:53 +08:00
0 0 1 1 - f i x - i n s t a l l - b o l t . p a t c h
2019-10-08 01:35:13 +08:00
)
2021-04-14 06:17:17 +08:00
vcpkg_check_features (
O U T _ F E A T U R E _ O P T I O N S F E A T U R E _ O P T I O N S
2021-03-30 00:39:04 +08:00
F E A T U R E S
2021-04-14 06:17:17 +08:00
t o o l s L L V M _ B U I L D _ T O O L S
t o o l s L L V M _ I N C L U D E _ T O O L S
u t i l s L L V M _ B U I L D _ U T I L S
u t i l s L L V M _ I N C L U D E _ U T I L S
2022-03-12 03:33:51 +08:00
u t i l s L L V M _ I N S T A L L _ U T I L S
2021-04-14 06:17:17 +08:00
e n a b l e - r t t i L L V M _ E N A B L E _ R T T I
e n a b l e - f f i L L V M _ E N A B L E _ F F I
e n a b l e - t e r m i n f o L L V M _ E N A B L E _ T E R M I N F O
e n a b l e - t h r e a d s L L V M _ E N A B L E _ T H R E A D S
e n a b l e - e h L L V M _ E N A B L E _ E H
e n a b l e - b i n d i n g s L L V M _ E N A B L E _ B I N D I N G S
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.
list ( APPEND FEATURE_OPTIONS
- D L L V M _ T E M P O R A R I L Y _ A L L O W _ O L D _ T O O L C H A I N = O N
)
2021-06-30 07:08:28 +08:00
# Force enable or disable external libraries
set ( llvm_external_libraries
z l i b
l i b x m l 2
)
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 $ { d e f i n e _ n a m e } = F O R C E _ O N
)
else ( )
list ( APPEND FEATURE_OPTIONS
- D $ { d e f i n e _ n a m e } = O F F
)
endif ( )
endforeach ( )
2020-05-04 11:30:17 +08:00
# By default assertions are enabled for Debug configuration only.
if ( "enable-assertions" IN_LIST FEATURES )
# Force enable assertions for all configurations.
list ( APPEND FEATURE_OPTIONS
- D L L V M _ E N A B L E _ A S S E R T I O N S = O N
)
elseif ( "disable-assertions" IN_LIST FEATURES )
# Force disable assertions for all configurations.
list ( APPEND FEATURE_OPTIONS
- D L L V M _ E N A B L E _ A S S E R T I O N S = O F F
)
2019-10-08 01:35:13 +08:00
endif ( )
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
- D L L V M _ A B I _ B R E A K I N G _ C H E C K S = F O R C E _ O N
)
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
- D L L V M _ A B I _ B R E A K I N G _ C H E C K S = F O R C E _ O F F
)
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" )
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" )
if ( "disable-clang-static-analyzer" IN_LIST FEATURES )
list ( APPEND FEATURE_OPTIONS
# Disable ARCMT
- D C L A N G _ E N A B L E _ A R C M T = O F F
# Disable static analyzer
- D C L A N G _ E N A B L E _ S T A T I C _ A N A L Y Z E R = O F F
)
endif ( )
2021-04-14 06:17:17 +08:00
# 1) LLVM/Clang tools are relocated from ./bin/ to ./tools/llvm/ (LLVM_TOOLS_INSTALL_DIR=tools/llvm)
# 2) Clang resource files are relocated from ./lib/clang/<version> to ./tools/llvm/lib/clang/<version> (see patch 0007-fix-compiler-rt-install-path.patch)
# So, the relative path should be changed from ../lib/clang/<version> to ./lib/clang/<version>
2023-01-25 12:21:30 +08:00
list ( APPEND FEATURE_OPTIONS -DCLANG_RESOURCE_DIR=lib/clang/ ${ VERSION } )
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" )
list ( APPEND FEATURE_OPTIONS
# Flang requires C++17
- D C M A K E _ C X X _ S T A N D A R D = 1 7
)
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" )
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
- D L L D B _ E N A B L E _ C U R S E S = O F F
)
2020-12-01 01:56:22 +08:00
endif ( )
if ( "mlir" IN_LIST FEATURES )
list ( APPEND LLVM_ENABLE_PROJECTS "mlir" )
endif ( )
2020-05-04 11:30:17 +08:00
if ( "openmp" IN_LIST FEATURES )
list ( APPEND LLVM_ENABLE_PROJECTS "openmp" )
# Perl is required for the OpenMP run-time
vcpkg_find_acquire_program ( PERL )
2021-12-21 00:21:15 +08:00
get_filename_component ( PERL_PATH ${ PERL } DIRECTORY )
vcpkg_add_to_path ( ${ PERL_PATH } )
2022-05-17 02:41:53 +08:00
# Skip post-build check
set ( VCPKG_POLICY_SKIP_DUMPBIN_CHECKS enabled )
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" )
endif ( )
2021-04-14 06:17:17 +08:00
if ( "pstl" IN_LIST FEATURES )
2022-05-17 02:41:53 +08:00
if ( VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
2021-04-14 06:17:17 +08:00
message ( FATAL_ERROR "Building pstl with MSVC is not supported. Disable it until issues are fixed." )
endif ( )
list ( APPEND LLVM_ENABLE_PROJECTS "pstl" )
2021-02-23 02:49:55 +08:00
endif ( )
2022-05-17 02:41:53 +08:00
set ( LLVM_ENABLE_RUNTIMES )
if ( "libcxx" IN_LIST FEATURES )
if ( VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
message ( FATAL_ERROR "Building libcxx with MSVC is not supported, as cl doesn't support the #include_next extension." )
endif ( )
list ( APPEND LLVM_ENABLE_RUNTIMES "libcxx" )
endif ( )
if ( "libcxxabi" IN_LIST FEATURES )
if ( VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
message ( FATAL_ERROR "Building libcxxabi with MSVC is not supported. Disable it until issues are fixed." )
endif ( )
list ( APPEND LLVM_ENABLE_RUNTIMES "libcxxabi" )
endif ( )
if ( "libunwind" IN_LIST FEATURES )
list ( APPEND LLVM_ENABLE_RUNTIMES "libunwind" )
endif ( )
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
A A r c h 6 4
A M D G P U
A R M
A V R
B P F
H e x a g o n
L a n a i
2021-07-23 06:50:52 +08:00
M i p s
2020-12-01 01:56:22 +08:00
M S P 4 3 0
N V P T X
P o w e r P C
R I S C V
S p a r c
2021-07-23 06:50:52 +08:00
S y s t e m Z
2022-05-17 02:41:53 +08:00
V E
2020-12-01 01:56:22 +08:00
W e b A s s e m b l y
X 8 6
X C o r e
)
2020-03-26 11:43:02 +08:00
2020-10-14 08:54:46 +08:00
set ( LLVM_TARGETS_TO_BUILD "" )
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
S P R I V
)
set ( LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "" )
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 )
vcpkg_add_to_path ( ${ PYTHON3_DIR } )
2019-10-08 01:35:13 +08:00
2022-06-15 00:07:45 +08:00
set ( LLVM_LINK_JOBS 1 )
2021-12-21 00:21:15 +08:00
vcpkg_cmake_configure (
2020-05-04 11:30:17 +08:00
S O U R C E _ P A T H $ { S O U R C E _ P A T H } / l l v m
O P T I O N S
$ { F E A T U R E _ O P T I O N S }
- D L L V M _ I N C L U D E _ E X A M P L E S = O F F
- D L L V M _ B U I L D _ E X A M P L E S = O F F
- D L L V M _ I N C L U D E _ T E S T S = O F F
- D L L V M _ B U I L D _ T E S T S = O F F
2022-05-17 02:41:53 +08:00
- D L L V M _ I N C L U D E _ B E N C H M A R K S = O F F
- D L L V M _ B U I L D _ B E N C H M A R K S = O F F
2020-05-04 11:30:17 +08:00
# Force TableGen to be built with optimization. This will significantly improve build time.
- D L L V M _ O P T I M I Z E D _ T A B L E G E N = O N
2020-12-01 01:56:22 +08:00
" - D L L V M _ E N A B L E _ P R O J E C T S = $ { L L V M _ E N A B L E _ P R O J E C T S } "
2022-05-17 02:41:53 +08:00
" - D L L V M _ E N A B L E _ R U N T I M E S = $ { L L V M _ E N A B L E _ R U N T I M E S } "
2020-12-01 01:56:22 +08:00
" - D L L V M _ T A R G E T S _ T O _ B U I L D = $ { L L V M _ T A R G E T S _ T O _ B U I L D } "
2022-06-15 00:07:45 +08:00
" - D L L V M _ E X P E R I M E N T A L _ T A R G E T S _ T O _ B U I L D = $ { L L V M _ E X P E R I M E N T A L _ T A R G E T S _ T O _ B U I L D } "
2023-01-25 12:21:30 +08:00
- D P A C K A G E _ V E R S I O N = $ { V E R S I O N }
2020-05-04 11:30:17 +08:00
# Limit the maximum number of concurrent link jobs to 1. This should fix low amount of memory issue for link.
2022-06-15 00:07:45 +08:00
" - D L L V M _ P A R A L L E L _ L I N K _ J O B S = $ { L L V M _ L I N K _ J O B S } "
2020-12-01 01:56:22 +08:00
- D L L V M _ T O O L S _ I N S T A L L _ D I R = t o o l s / l l v m
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
2021-12-21 00:21:15 +08:00
set ( empty_dirs )
if ( "clang-tools-extra" IN_LIST FEATURES )
list ( APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin" )
2020-11-13 09:31:34 +08:00
endif ( )
2020-05-04 11:30:17 +08:00
2023-01-19 03:42:07 +08:00
if ( "pstl" IN_LIST FEATURES )
list ( APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/lib/cmake" )
list ( APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/debug/lib/cmake" )
endif ( )
2021-12-21 00:21:15 +08:00
if ( "flang" IN_LIST FEATURES )
list ( APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/Config" )
list ( APPEND empty_dirs "${CURRENT_PACKAGES_DIR}/include/flang/CMakeFiles" )
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" )
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}" )
message ( SEND_ERROR "Directory '${empty_dir}' is not exist. Please remove it from the checking." )
else ( )
file ( GLOB_RECURSE files_in_dir "${empty_dir}/*" )
if ( files_in_dir )
message ( SEND_ERROR "Directory '${empty_dir}' is not empty. Please remove it from the checking." )
else ( )
file ( REMOVE_RECURSE "${empty_dir}" )
endif ( )
endif ( )
endforeach ( )
2020-12-01 01:56:22 +08:00
endif ( )
2021-04-14 06:17:17 +08:00
vcpkg_copy_tool_dependencies ( ${ CURRENT_PACKAGES_DIR } /tools/ ${ PORT } )
2020-12-01 01:56:22 +08:00
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"
" $ { C U R R E N T _ P A C K A G E S _ D I R } / d e b u g / s h a r e "
" $ { C U R R E N T _ P A C K A G E S _ D I R } / d e b u g / t o o l s "
)
2020-05-04 11:30:17 +08:00
endif ( )
2022-05-25 07:10:34 +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 ( )
2020-11-13 09:31:34 +08:00
# LLVM still generates a few DLLs in the static build:
2022-05-17 02:41:53 +08:00
# * LLVM-C.dll
2020-11-13 09:31:34 +08:00
# * libclang.dll
# * LTO.dll
# * Remarks.dll
set ( VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled )