2020-10-02 05:35:28 +08:00
|
|
|
include(LLVMDistributionSupport)
|
|
|
|
|
2016-07-10 05:58:40 +08:00
|
|
|
function(clang_tablegen)
|
|
|
|
# Syntax:
|
|
|
|
# clang_tablegen output-file [tablegen-arg ...] SOURCE source-file
|
|
|
|
# [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]]
|
|
|
|
#
|
|
|
|
# Generates a custom command for invoking tblgen as
|
|
|
|
#
|
|
|
|
# tblgen source-file -o=output-file tablegen-arg ...
|
|
|
|
#
|
|
|
|
# and, if cmake-target-name is provided, creates a custom target for
|
|
|
|
# executing the custom command depending on output-file. It is
|
|
|
|
# possible to list more files to depend after DEPENDS.
|
|
|
|
|
|
|
|
cmake_parse_arguments(CTG "" "SOURCE;TARGET" "" ${ARGN})
|
|
|
|
|
|
|
|
if( NOT CTG_SOURCE )
|
|
|
|
message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")
|
|
|
|
endif()
|
|
|
|
|
2020-04-01 02:45:59 +08:00
|
|
|
set( CLANG_TABLEGEN_ARGUMENTS "" )
|
2016-07-10 05:58:40 +08:00
|
|
|
set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
|
2019-12-15 15:27:27 +08:00
|
|
|
tablegen(CLANG ${CTG_UNPARSED_ARGUMENTS} ${CLANG_TABLEGEN_ARGUMENTS})
|
2016-07-10 05:58:40 +08:00
|
|
|
|
|
|
|
if(CTG_TARGET)
|
|
|
|
add_public_tablegen_target(${CTG_TARGET})
|
|
|
|
set_target_properties( ${CTG_TARGET} PROPERTIES FOLDER "Clang tablegenning")
|
|
|
|
set_property(GLOBAL APPEND PROPERTY CLANG_TABLEGEN_TARGETS ${CTG_TARGET})
|
|
|
|
endif()
|
|
|
|
endfunction(clang_tablegen)
|
|
|
|
|
|
|
|
macro(set_clang_windows_version_resource_properties name)
|
|
|
|
if(DEFINED windows_resource_file)
|
|
|
|
set_windows_version_resource_properties(${name} ${windows_resource_file}
|
|
|
|
VERSION_MAJOR ${CLANG_VERSION_MAJOR}
|
|
|
|
VERSION_MINOR ${CLANG_VERSION_MINOR}
|
|
|
|
VERSION_PATCHLEVEL ${CLANG_VERSION_PATCHLEVEL}
|
|
|
|
VERSION_STRING "${CLANG_VERSION} (${BACKEND_PACKAGE_STRING})"
|
|
|
|
PRODUCT_NAME "clang")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_clang_subdirectory name)
|
|
|
|
add_llvm_subdirectory(CLANG TOOL ${name})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_clang_library name)
|
|
|
|
cmake_parse_arguments(ARG
|
2020-05-07 10:31:46 +08:00
|
|
|
"SHARED;STATIC;INSTALL_WITH_TOOLCHAIN"
|
2016-07-10 05:58:40 +08:00
|
|
|
""
|
|
|
|
"ADDITIONAL_HEADERS"
|
|
|
|
${ARGN})
|
|
|
|
set(srcs)
|
|
|
|
if(MSVC_IDE OR XCODE)
|
|
|
|
# Add public headers
|
|
|
|
file(RELATIVE_PATH lib_path
|
|
|
|
${CLANG_SOURCE_DIR}/lib/
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
if(NOT lib_path MATCHES "^[.][.]")
|
|
|
|
file( GLOB_RECURSE headers
|
|
|
|
${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.h
|
|
|
|
${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.def
|
|
|
|
)
|
|
|
|
set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
|
|
|
|
file( GLOB_RECURSE tds
|
|
|
|
${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.td
|
|
|
|
)
|
|
|
|
source_group("TableGen descriptions" FILES ${tds})
|
|
|
|
set_source_files_properties(${tds}} PROPERTIES HEADER_FILE_ONLY ON)
|
|
|
|
|
|
|
|
if(headers OR tds)
|
|
|
|
set(srcs ${headers} ${tds})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif(MSVC_IDE OR XCODE)
|
|
|
|
if(srcs OR ARG_ADDITIONAL_HEADERS)
|
|
|
|
set(srcs
|
|
|
|
ADDITIONAL_HEADERS
|
|
|
|
${srcs}
|
|
|
|
${ARG_ADDITIONAL_HEADERS} # It may contain unparsed unknown args.
|
|
|
|
)
|
|
|
|
endif()
|
2020-05-07 10:31:46 +08:00
|
|
|
|
|
|
|
if(ARG_SHARED AND ARG_STATIC)
|
|
|
|
set(LIBTYPE SHARED STATIC)
|
|
|
|
elseif(ARG_SHARED)
|
2019-05-17 12:20:01 +08:00
|
|
|
set(LIBTYPE SHARED)
|
|
|
|
else()
|
2019-05-21 23:56:17 +08:00
|
|
|
# llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
|
|
|
|
# so we need to handle it here.
|
|
|
|
if(BUILD_SHARED_LIBS)
|
2019-10-05 02:17:58 +08:00
|
|
|
set(LIBTYPE SHARED)
|
2019-05-21 23:56:17 +08:00
|
|
|
else()
|
2019-10-05 02:17:58 +08:00
|
|
|
set(LIBTYPE STATIC)
|
|
|
|
endif()
|
|
|
|
if(NOT XCODE)
|
|
|
|
# The Xcode generator doesn't handle object libraries correctly.
|
|
|
|
list(APPEND LIBTYPE OBJECT)
|
2019-05-21 23:56:17 +08:00
|
|
|
endif()
|
2019-05-17 12:20:01 +08:00
|
|
|
set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
|
2016-07-10 05:58:40 +08:00
|
|
|
endif()
|
2019-05-17 12:20:01 +08:00
|
|
|
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
|
2016-07-10 05:58:40 +08:00
|
|
|
|
2020-05-07 10:31:46 +08:00
|
|
|
set(libs ${name})
|
|
|
|
if(ARG_SHARED AND ARG_STATIC)
|
|
|
|
list(APPEND libs ${name}_static)
|
|
|
|
endif()
|
2020-04-28 16:10:33 +08:00
|
|
|
|
2020-05-07 10:31:46 +08:00
|
|
|
foreach(lib ${libs})
|
|
|
|
if(TARGET ${lib})
|
|
|
|
target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
|
|
|
|
|
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
|
2020-10-02 05:35:28 +08:00
|
|
|
get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries)
|
2020-05-07 10:31:46 +08:00
|
|
|
install(TARGETS ${lib}
|
|
|
|
COMPONENT ${lib}
|
|
|
|
${export_to_clangtargets}
|
|
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-${lib}
|
|
|
|
DEPENDS ${lib}
|
|
|
|
COMPONENT ${lib})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${lib})
|
2020-04-28 16:10:33 +08:00
|
|
|
endif()
|
2020-05-07 10:31:46 +08:00
|
|
|
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${lib})
|
|
|
|
else()
|
|
|
|
# Add empty "phony" target
|
|
|
|
add_custom_target(${lib})
|
2016-07-10 05:58:40 +08:00
|
|
|
endif()
|
2020-05-07 10:31:46 +08:00
|
|
|
endforeach()
|
2016-07-10 05:58:40 +08:00
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
|
|
|
|
set_clang_windows_version_resource_properties(${name})
|
|
|
|
endmacro(add_clang_library)
|
|
|
|
|
|
|
|
macro(add_clang_executable name)
|
|
|
|
add_llvm_executable( ${name} ${ARGN} )
|
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "Clang executables")
|
|
|
|
set_clang_windows_version_resource_properties(${name})
|
|
|
|
endmacro(add_clang_executable)
|
|
|
|
|
|
|
|
macro(add_clang_tool name)
|
2016-07-10 09:44:00 +08:00
|
|
|
if (NOT CLANG_BUILD_TOOLS)
|
|
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
|
|
endif()
|
|
|
|
|
2016-07-10 05:58:40 +08:00
|
|
|
add_clang_executable(${name} ${ARGN})
|
[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].
I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.
[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html
Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille
Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits
Tags: #clang, #sanitizers, #lldb, #openmp, #llvm
Differential Revision: https://reviews.llvm.org/D58791
llvm-svn: 355340
2019-03-05 05:19:53 +08:00
|
|
|
add_dependencies(${name} clang-resource-headers)
|
2016-07-10 09:44:00 +08:00
|
|
|
|
|
|
|
if (CLANG_BUILD_TOOLS)
|
2020-10-02 05:35:28 +08:00
|
|
|
get_target_export_arg(${name} Clang export_to_clangtargets)
|
2016-07-10 09:44:00 +08:00
|
|
|
install(TARGETS ${name}
|
2016-11-08 07:46:05 +08:00
|
|
|
${export_to_clangtargets}
|
2016-07-10 09:44:00 +08:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
COMPONENT ${name})
|
|
|
|
|
2019-02-21 07:08:43 +08:00
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
2017-12-01 06:35:02 +08:00
|
|
|
add_llvm_install_targets(install-${name}
|
|
|
|
DEPENDS ${name}
|
|
|
|
COMPONENT ${name})
|
2016-07-10 09:44:00 +08:00
|
|
|
endif()
|
2016-10-20 06:46:06 +08:00
|
|
|
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
|
2016-07-10 05:58:40 +08:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(add_clang_symlink name dest)
|
|
|
|
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
|
|
|
|
# Always generate install targets
|
|
|
|
llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
|
|
|
|
endmacro()
|
2019-07-04 06:45:55 +08:00
|
|
|
|
|
|
|
function(clang_target_link_libraries target type)
|
|
|
|
if (CLANG_LINK_CLANG_DYLIB)
|
2019-07-12 05:42:55 +08:00
|
|
|
target_link_libraries(${target} ${type} clang-cpp)
|
2019-07-04 06:45:55 +08:00
|
|
|
else()
|
|
|
|
target_link_libraries(${target} ${type} ${ARGN})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endfunction()
|