mirror-llvm-project/clang/cmake/modules/ClangConfig.cmake.in
Haowei a04f87fdd9
Reapply "Skipping host target exports during cross-compilation" (#210… (#210496)
This reverts commit 42eb7db188. This
reland 3fbb037d03 (#209922).

Under CMake 4+, calling add_library(... SHARED IMPORTED) on a target
platform that lacks dynamic linking support triggers a fatal error. This
becomes an issue when building LLVM and runtimes for baremetal targets
like armv6m-none-eabi. This patch adds the option
"LLVM_OMIT_EXPORTS_FROM_CONFIG" in LLVM. When used in sub builds like
LLVM runtimes, it makes CMake to skip including the LLVM and Clang
exports. This mitigates the CMake 4 errors on baremetal runtimes.

42eb7db188 originally
apply this flag on all runtimes build and causing issues on runtimes
like intel-sycl-gpu, amdgpu-offload-ubuntu-22-cmake-build-only.
This PR only set this flag when the target platform lacks shared library
support.
2026-07-20 10:47:59 -07:00

26 lines
1,000 B
CMake

# This file allows users to call find_package(Clang) and pick up our targets.
@CLANG_CONFIG_CODE@
set(LLVM_VERSION @LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@.@LLVM_VERSION_PATCH@)
find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG
HINTS "@CLANG_CONFIG_LLVM_CMAKE_DIR@")
set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
set(CLANG_INCLUDE_DIRS "@CLANG_CONFIG_INCLUDE_DIRS@")
set(CLANG_LINK_CLANG_DYLIB "@CLANG_LINK_CLANG_DYLIB@")
set(CLANG_DEFAULT_LINKER "@CLANG_DEFAULT_LINKER@")
# Provide all our library targets to users. Skip when
# LLVM_OMIT_EXPORTS_FROM_CONFIG flag is set.
if(NOT LLVM_OMIT_EXPORTS_FROM_CONFIG)
@CLANG_CONFIG_INCLUDE_EXPORTS@
endif()
# By creating clang-tablegen-targets here, subprojects that depend on Clang's
# tablegen-generated headers can always depend on this target whether building
# in-tree with Clang or not.
if(NOT TARGET clang-tablegen-targets)
add_custom_target(clang-tablegen-targets)
endif()