vcpkg/ports/llvm/portfile.cmake

124 lines
5.3 KiB
CMake
Raw Normal View History

2018-04-20 01:43:10 +08:00
# LLVM documentation recommends always using static library linkage when
# building with Microsoft toolchain; it's also the default on other platforms
set(VCPKG_LIBRARY_LINKAGE static)
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(FATAL_ERROR "llvm cannot currently be built for UWP")
endif()
include(vcpkg_common_functions)
2019-07-10 01:59:47 +08:00
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/llvm-8.0.0.src)
2018-04-20 01:43:10 +08:00
vcpkg_download_distfile(ARCHIVE
2019-07-10 01:59:47 +08:00
URLS "http://releases.llvm.org/8.0.0/llvm-8.0.0.src.tar.xz"
FILENAME "llvm-8.0.0.src.tar.xz"
SHA512 1602343b451b964f5d8c2d6b0654d89384c80d45883498c5f0e2f4196168dd4a1ed2a4dadb752076020243df42ffe46cb31d82ffc145d8e5874163cbb9686a1f
2018-04-20 01:43:10 +08:00
)
vcpkg_extract_source_archive(${ARCHIVE})
vcpkg_download_distfile(CLANG_ARCHIVE
2019-07-10 01:59:47 +08:00
URLS "http://releases.llvm.org/8.0.0/cfe-8.0.0.src.tar.xz"
FILENAME "cfe-8.0.0.src.tar.xz"
SHA512 98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3
2018-04-20 01:43:10 +08:00
)
vcpkg_extract_source_archive(${CLANG_ARCHIVE} ${SOURCE_PATH}/tools)
if(NOT EXISTS ${SOURCE_PATH}/tools/clang)
2019-07-10 01:59:47 +08:00
file(RENAME ${SOURCE_PATH}/tools/cfe-8.0.0.src ${SOURCE_PATH}/tools/clang)
2018-04-20 01:43:10 +08:00
endif()
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
install-cmake-modules-to-share.patch
fix-build-error.patch
fix-linux-build.patch
2018-04-20 01:43:10 +08:00
)
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${PYTHON3_DIR}")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_INCLUDE_TOOLS=ON
-DLLVM_INCLUDE_UTILS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF
-DLLVM_TOOLS_INSTALL_DIR=tools/llvm
-DLLVM_PARALLEL_LINK_JOBS=1
2018-04-20 01:43:10 +08:00
)
vcpkg_install_cmake()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(GLOB EXE ${CURRENT_PACKAGES_DIR}/bin/*)
file(COPY ${EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/llvm)
file(REMOVE ${EXE})
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(GLOB DEBUG_EXE ${CURRENT_PACKAGES_DIR}/debug/bin/*)
file(COPY ${DEBUG_EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/tools/llvm)
file(REMOVE ${DEBUG_EXE})
endif()
2018-04-20 01:43:10 +08:00
vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
2018-04-20 01:43:10 +08:00
vcpkg_fixup_cmake_targets(CONFIG_PATH share/llvm)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/llvm)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(READ ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-release.cmake RELEASE_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/tools/llvm" RELEASE_MODULE "${RELEASE_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-release.cmake "${RELEASE_MODULE}")
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-release.cmake RELEASE_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/tools/llvm" RELEASE_MODULE "${RELEASE_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-release.cmake "${RELEASE_MODULE}")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(READ ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-debug.cmake DEBUG_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/debug/bin" "\${_IMPORT_PREFIX}/tools/llvm" DEBUG_MODULE "${DEBUG_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-debug.cmake "${DEBUG_MODULE}")
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-debug.cmake DEBUG_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/debug/bin" "\${_IMPORT_PREFIX}/tools/llvm" DEBUG_MODULE "${DEBUG_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-debug.cmake "${DEBUG_MODULE}")
endif()
if (EXISTS ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake)
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake LLVM_TOOLS_MODULE)
string(REPLACE "\${LLVM_INSTALL_PREFIX}/bin" "\${LLVM_INSTALL_PREFIX}/tools/llvm" LLVM_TOOLS_MODULE "${LLVM_TOOLS_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake "${LLVM_TOOLS_MODULE}")
endif()
2018-04-20 01:43:10 +08:00
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/tools
${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/debug/bin
${CURRENT_PACKAGES_DIR}/debug/msbuild-bin
${CURRENT_PACKAGES_DIR}/bin
${CURRENT_PACKAGES_DIR}/msbuild-bin
${CURRENT_PACKAGES_DIR}/tools/msbuild-bin
2018-04-27 05:52:57 +08:00
${CURRENT_PACKAGES_DIR}/include/llvm/BinaryFormat/WasmRelocs
2018-04-20 01:43:10 +08:00
)
2019-07-10 01:59:47 +08:00
# Remove two empty include subdirectorys if they are indeed empty
2018-04-20 01:43:10 +08:00
file(GLOB MCANALYSISFILES ${CURRENT_PACKAGES_DIR}/include/llvm/MC/MCAnalysis/*)
if(NOT MCANALYSISFILES)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/llvm/MC/MCAnalysis)
endif()
2019-07-10 01:59:47 +08:00
file(GLOB MACHOFILES ${CURRENT_PACKAGES_DIR}/include/llvm/TextAPI/MachO/*)
if(NOT MACHOFILES)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/llvm/TextAPI/MachO)
endif()
2018-04-20 01:43:10 +08:00
# Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/llvm RENAME copyright)