2021-04-14 06:17:17 +08:00
set ( LLVM_VERSION "11.1.0" )
2019-10-08 01:35:13 +08:00
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
2020-12-01 01:56:22 +08:00
R E F l l v m o r g - $ { L L V M _ V E R S I O N }
2021-04-14 06:17:17 +08:00
S H A 5 1 2 9 a 8 c e 0 2 2 a 9 3 5 e e d 4 2 f a 7 1 a 2 2 4 f 2 a 2 0 7 1 2 2 a a d c b e f 5 8 e e 8 5 5 f d b 4 8 2 5 f 8 7 9 e 7 d 0 2 8 e 4 d c f f 2 2 c 1 9 b 9 d 3 3 6 d b 1 c 8 b f 6 3 f b 8 4 3 7 2 d 4 4 9 8 1 a c f 8 4 6 1 5 f 7 5 7 e 5 4 3 0 6 c 9 2 b 8 1
2020-05-04 11:30:17 +08:00
H E A D _ R E F m a s t e r
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 1 - a d d - m s v c - o p t i o n s . p a t c h # Fixed in LLVM 12.0.0
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.
0 0 0 3 - f i x - o p e n m p - d e b u g . p a t c h
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
2020-12-01 01:56:22 +08:00
0 0 0 6 - w o r k a r o u n d - m s v c - b u g . p a t c h # Fixed in LLVM 12.0.0
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 8 - f i x - l i b c x x - i n s t a l l . 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
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
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
)
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
)
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.
# By default abi-breaking checks are enabled if assertions are enabled.
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
)
elseif ( "disable-abi-breaking-checks" IN_LIST FEATURES )
# 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 )
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>
list ( APPEND FEATURE_OPTIONS -DCLANG_RESOURCE_DIR=lib/clang/ ${ LLVM_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 )
# Disable Flang on Windows (see http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html).
if ( VCPKG_TARGET_IS_WINDOWS )
2021-04-14 06:17:17 +08:00
message ( FATAL_ERROR "Building Flang with MSVC is not supported. 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 ( )
if ( "libcxx" IN_LIST FEATURES )
if ( VCPKG_TARGET_IS_WINDOWS )
message ( FATAL_ERROR "Building libcxx with MSVC is not supported. Disable it until issues are fixed." )
endif ( )
list ( APPEND LLVM_ENABLE_PROJECTS "libcxx" )
endif ( )
if ( "libcxxabi" IN_LIST FEATURES )
if ( VCPKG_TARGET_IS_WINDOWS )
message ( FATAL_ERROR "Building libcxxabi with MSVC is not supported. Disable it until issues are fixed." )
endif ( )
list ( APPEND LLVM_ENABLE_PROJECTS "libcxxabi" )
endif ( )
if ( "libunwind" IN_LIST FEATURES )
if ( VCPKG_TARGET_IS_WINDOWS )
message ( FATAL_ERROR "Building libunwind with MSVC is not supported. Disable it until issues are fixed." )
endif ( )
list ( APPEND LLVM_ENABLE_PROJECTS "libunwind" )
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" )
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 )
2020-12-01 01:56:22 +08:00
# Disable OpenMP on Windows (see https://bugs.llvm.org/show_bug.cgi?id=45074).
if ( VCPKG_TARGET_IS_WINDOWS )
2021-04-14 06:17:17 +08:00
message ( FATAL_ERROR "Building OpenMP with MSVC is not supported. Disable it until issues are fixed." )
2020-12-01 01:56:22 +08:00
endif ( )
2020-05-04 11:30:17 +08:00
list ( APPEND LLVM_ENABLE_PROJECTS "openmp" )
# Perl is required for the OpenMP run-time
vcpkg_find_acquire_program ( PERL )
list ( APPEND FEATURE_OPTIONS
2020-12-01 01:56:22 +08:00
" - D P E R L _ E X E C U T A B L E = $ { P E R L } "
2020-05-04 11:30:17 +08:00
)
2020-12-01 01:56:22 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
list ( APPEND FEATURE_OPTIONS
- D L I B O M P _ D E F A U L T _ L I B _ N A M E = l i b o m p d
)
endif ( )
2020-05-04 11:30:17 +08:00
endif ( )
2021-04-14 06:17:17 +08:00
if ( "parallel-libs" IN_LIST FEATURES )
list ( APPEND LLVM_ENABLE_PROJECTS "parallel-libs" )
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 )
if ( VCPKG_TARGET_IS_WINDOWS )
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 ( )
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
M i p s
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
S y s t e m Z
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
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
2020-05-04 11:30:17 +08:00
vcpkg_configure_cmake (
S O U R C E _ P A T H $ { S O U R C E _ P A T H } / l l v m
P R E F E R _ N I N J A
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
2020-12-01 01:56:22 +08:00
# Disable optional dependencies to libxml2 and zlib.
2020-05-11 06:17:27 +08:00
- D L L V M _ E N A B L E _ L I B X M L 2 = O F F
- D L L V M _ E N A B L E _ Z L I B = 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 } "
" - 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 } "
- D P A C K A G E _ V E R S I O N = $ { L L V M _ 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.
- D L L V M _ P A R A L L E L _ L I N K _ J O B S = 1
# Disable build LLVM-C.dll (Windows only) due to doesn't compile with CMAKE_DEBUG_POSTFIX
- D L L V M _ B U I L D _ L L V M _ C _ D Y L I B = O F F
2020-12-01 01:56:22 +08:00
# Path for binary subdirectory (defaults to 'bin')
- 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
O P T I O N S _ D E B U G
2020-05-04 11:30:17 +08:00
- D C M A K E _ D E B U G _ P O S T F I X = d
2019-10-08 01:35:13 +08:00
)
2020-05-04 11:30:17 +08:00
vcpkg_install_cmake ( )
2020-12-01 01:56:22 +08:00
2021-04-14 06:17:17 +08:00
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/llvm" TARGET_PATH "share/llvm" )
file ( INSTALL ${ SOURCE_PATH } /llvm/LICENSE.TXT DESTINATION ${ CURRENT_PACKAGES_DIR } /share/llvm RENAME copyright )
file ( INSTALL ${ CMAKE_CURRENT_LIST_DIR } /llvm_usage DESTINATION ${ CURRENT_PACKAGES_DIR } /share/llvm RENAME usage )
2020-06-24 04:39:52 +08:00
if ( "clang" IN_LIST FEATURES )
2020-12-01 01:56:22 +08:00
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/clang" TARGET_PATH "share/clang" DO_NOT_DELETE_PARENT_CONFIG_PATH )
file ( INSTALL ${ SOURCE_PATH } /clang/LICENSE.TXT DESTINATION ${ CURRENT_PACKAGES_DIR } /share/clang RENAME copyright )
2021-04-14 06:17:17 +08:00
file ( INSTALL ${ CMAKE_CURRENT_LIST_DIR } /clang_usage DESTINATION ${ CURRENT_PACKAGES_DIR } /share/clang RENAME usage )
2020-12-01 01:56:22 +08:00
endif ( )
2020-05-04 11:30:17 +08:00
2020-12-01 01:56:22 +08:00
if ( "clang-tools-extra" IN_LIST FEATURES )
# Remove empty include directory include/clang-tidy/plugin
file ( GLOB_RECURSE INCLUDE_CLANG_TIDY_PLUGIN_FILES "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin/*" )
if ( NOT INCLUDE_CLANG_TIDY_PLUGIN_FILES )
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin" )
2020-05-16 04:28:48 +08:00
endif ( )
2020-12-01 01:56:22 +08:00
endif ( )
2019-10-08 01:35:13 +08:00
2020-12-01 01:56:22 +08:00
if ( "flang" IN_LIST FEATURES )
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/flang" TARGET_PATH "share/flang" DO_NOT_DELETE_PARENT_CONFIG_PATH )
2021-04-14 06:17:17 +08:00
file ( INSTALL ${ SOURCE_PATH } /flang/LICENSE.txt DESTINATION ${ CURRENT_PACKAGES_DIR } /share/flang RENAME copyright )
file ( INSTALL ${ CMAKE_CURRENT_LIST_DIR } /flang_usage DESTINATION ${ CURRENT_PACKAGES_DIR } /share/flang RENAME usage )
2020-12-01 01:56:22 +08:00
# Remove empty include directory /include/flang/Config
file ( GLOB_RECURSE INCLUDE_FLANG_CONFIG_FILES "${CURRENT_PACKAGES_DIR}/include/flang/Config/*" )
if ( NOT INCLUDE_FLANG_CONFIG_FILES )
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/flang/Config" )
endif ( )
endif ( )
if ( "lld" IN_LIST FEATURES )
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/lld" TARGET_PATH "share/lld" DO_NOT_DELETE_PARENT_CONFIG_PATH )
file ( INSTALL ${ SOURCE_PATH } /lld/LICENSE.TXT DESTINATION ${ CURRENT_PACKAGES_DIR } /share/lld RENAME copyright )
2021-04-14 06:17:17 +08:00
file ( INSTALL ${ CMAKE_CURRENT_LIST_DIR } /lld_usage DESTINATION ${ CURRENT_PACKAGES_DIR } /share/lld RENAME usage )
2020-12-01 01:56:22 +08:00
endif ( )
2020-05-04 11:30:17 +08:00
2020-12-01 01:56:22 +08:00
if ( "mlir" IN_LIST FEATURES )
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/mlir" TARGET_PATH "share/mlir" DO_NOT_DELETE_PARENT_CONFIG_PATH )
file ( INSTALL ${ SOURCE_PATH } /mlir/LICENSE.TXT DESTINATION ${ CURRENT_PACKAGES_DIR } /share/mlir RENAME copyright )
2021-04-14 06:17:17 +08:00
file ( INSTALL ${ CMAKE_CURRENT_LIST_DIR } /mlir_usage DESTINATION ${ CURRENT_PACKAGES_DIR } /share/mlir RENAME usage )
2020-11-13 09:31:34 +08:00
endif ( )
2020-05-04 11:30:17 +08:00
2020-12-01 01:56:22 +08:00
if ( "polly" IN_LIST FEATURES )
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/polly" TARGET_PATH "share/polly" DO_NOT_DELETE_PARENT_CONFIG_PATH )
2021-04-14 06:17:17 +08:00
file ( INSTALL ${ SOURCE_PATH } /polly/LICENSE.txt DESTINATION ${ CURRENT_PACKAGES_DIR } /share/polly RENAME copyright )
2020-12-01 01:56:22 +08:00
endif ( )
2021-04-14 06:17:17 +08:00
if ( "pstl" IN_LIST FEATURES )
vcpkg_fixup_cmake_targets ( CONFIG_PATH "share/ParallelSTL" TARGET_PATH "share/ParallelSTL" DO_NOT_DELETE_PARENT_CONFIG_PATH )
file ( INSTALL ${ SOURCE_PATH } /pstl/LICENSE.txt DESTINATION ${ CURRENT_PACKAGES_DIR } /share/ParallelSTL RENAME copyright )
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" )
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/include )
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/share )
2020-12-01 01:56:22 +08:00
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/tools )
2020-05-04 11:30:17 +08:00
endif ( )
2020-11-13 09:31:34 +08:00
# LLVM still generates a few DLLs in the static build:
# * libclang.dll
# * LTO.dll
# * Remarks.dll
set ( VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled )