Skip to content

Instantly share code, notes, and snippets.

@elliottslaughter
Last active February 12, 2019 18:31
Show Gist options
  • Save elliottslaughter/64d5d5d9d9e5cbfc853bac1d32cdc131 to your computer and use it in GitHub Desktop.
Save elliottslaughter/64d5d5d9d9e5cbfc853bac1d32cdc131 to your computer and use it in GitHub Desktop.

Install prefix from LLVM 3.8.0 build.

include(LLVMProcessSources)
include(LLVM-Config)
include(DetermineGCCCompatible)
function(llvm_update_compile_flags name)
get_property(sources TARGET ${name} PROPERTY SOURCES)
if("${sources}" MATCHES "\\.c(;|$)")
set(update_src_props ON)
endif()
# LLVM_REQUIRES_EH is an internal flag that individual
# targets can use to force EH
if((LLVM_REQUIRES_EH OR LLVM_ENABLE_EH) AND NOT CLANG_CL)
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
endif()
else()
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
elseif(MSVC)
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")
endif()
endif()
# LLVM_REQUIRES_RTTI is an internal flag that individual
# targets can use to force RTTI
set(LLVM_CONFIG_HAS_RTTI YES CACHE INTERNAL "")
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
set(LLVM_CONFIG_HAS_RTTI NO CACHE INTERNAL "")
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")
elseif (MSVC)
list(APPEND LLVM_COMPILE_FLAGS "/GR-")
endif ()
endif()
# Assume that;
# - LLVM_COMPILE_FLAGS is list.
# - PROPERTY COMPILE_FLAGS is string.
string(REPLACE ";" " " target_compile_flags " ${LLVM_COMPILE_FLAGS}")
if(update_src_props)
foreach(fn ${sources})
get_filename_component(suf ${fn} EXT)
if("${suf}" STREQUAL ".cpp")
set_property(SOURCE ${fn} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_flags}")
endif()
endforeach()
else()
# Update target props, since all sources are C++.
set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_flags}")
endif()
set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LLVM_COMPILE_DEFINITIONS})
endfunction()
function(add_llvm_symbol_exports target_name export_file)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(native_export_file "${target_name}.exports")
add_custom_command(OUTPUT ${native_export_file}
COMMAND sed -e "s/^/_/" < ${export_file} > ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
elseif(LLVM_HAVE_LINK_VERSION_SCRIPT)
# Gold and BFD ld require a version script rather than a plain list.
set(native_export_file "${target_name}.exports")
# FIXME: Don't write the "local:" line on OpenBSD.
add_custom_command(OUTPUT ${native_export_file}
COMMAND echo "{" > ${native_export_file}
COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || :
COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file}
COMMAND echo " local: *;" >> ${native_export_file}
COMMAND echo "};" >> ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
endif()
else()
set(native_export_file "${target_name}.def")
add_custom_command(OUTPUT ${native_export_file}
COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
< ${export_file} > ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
if(MSVC)
set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
endif()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " ${export_file_linker_flag}")
endif()
add_custom_target(${target_name}_exports DEPENDS ${native_export_file})
set_target_properties(${target_name}_exports PROPERTIES FOLDER "Misc")
get_property(srcs TARGET ${target_name} PROPERTY SOURCES)
foreach(src ${srcs})
get_filename_component(extension ${src} EXT)
if(extension STREQUAL ".cpp")
set(first_source_file ${src})
break()
endif()
endforeach()
# Force re-linking when the exports file changes. Actually, it
# forces recompilation of the source file. The LINK_DEPENDS target
# property only works for makefile-based generators.
# FIXME: This is not safe because this will create the same target
# ${native_export_file} in several different file:
# - One where we emitted ${target_name}_exports
# - One where we emitted the build command for the following object.
# set_property(SOURCE ${first_source_file} APPEND PROPERTY
# OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${native_export_file})
set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${native_export_file})
add_dependencies(${target_name} ${target_name}_exports)
# Add dependency to *_exports later -- CMake issue 14747
list(APPEND LLVM_COMMON_DEPENDS ${target_name}_exports)
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
endfunction(add_llvm_symbol_exports)
if(NOT WIN32 AND NOT APPLE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -Wl,--version
OUTPUT_VARIABLE stdout
ERROR_QUIET
)
if("${stdout}" MATCHES "GNU gold")
set(LLVM_LINKER_IS_GOLD ON)
endif()
endif()
function(add_link_opts target_name)
# Don't use linker optimizations in debug builds since it slows down the
# linker in a context where the optimizations are not important.
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
# Pass -O3 to the linker. This enabled different optimizations on different
# linkers.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|SunOS" OR WIN32))
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-O3")
endif()
if(LLVM_LINKER_IS_GOLD)
# With gold gc-sections is always safe.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
# Note that there is a bug with -Wl,--icf=safe so it is not safe
# to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
endif()
if(NOT LLVM_NO_DEAD_STRIP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# ld64's implementation of -dead_strip breaks tools that use plugins.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-dead_strip")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
# tools that use plugins. Always pass --gc-sections once we require
# a newer linker.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
endif()
endif()
endif()
endfunction(add_link_opts)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
# Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more,
# or a certain builder, for eaxample, msbuild.exe, would be confused.
function(set_output_directory target)
cmake_parse_arguments(ARG "" "BINARY_DIR;LIBRARY_DIR" "" ${ARGN})
# module_dir -- corresponding to LIBRARY_OUTPUT_DIRECTORY.
# It affects output of add_library(MODULE).
if(WIN32 OR CYGWIN)
# DLL platform
set(module_dir ${ARG_BINARY_DIR})
else()
set(module_dir ${ARG_LIBRARY_DIR})
endif()
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
if(ARG_BINARY_DIR)
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${ARG_BINARY_DIR})
set_target_properties(${target} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${bi})
endif()
if(ARG_LIBRARY_DIR)
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${ARG_LIBRARY_DIR})
set_target_properties(${target} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li})
endif()
if(module_dir)
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} mi ${module_dir})
set_target_properties(${target} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${mi})
endif()
endforeach()
else()
if(ARG_BINARY_DIR)
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ARG_BINARY_DIR})
endif()
if(ARG_LIBRARY_DIR)
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${ARG_LIBRARY_DIR})
endif()
if(module_dir)
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${module_dir})
endif()
endif()
endfunction()
# If on Windows and building with MSVC, add the resource script containing the
# VERSIONINFO data to the project. This embeds version resource information
# into the output .exe or .dll.
# TODO: Enable for MinGW Windows builds too.
#
function(add_windows_version_resource_file OUT_VAR)
set(sources ${ARGN})
if (MSVC)
set(resource_file ${LLVM_SOURCE_DIR}/resources/windows_version_resource.rc)
if(EXISTS ${resource_file})
set(sources ${sources} ${resource_file})
source_group("Resource Files" ${resource_file})
set(windows_resource_file ${resource_file} PARENT_SCOPE)
endif()
endif(MSVC)
set(${OUT_VAR} ${sources} PARENT_SCOPE)
endfunction(add_windows_version_resource_file)
# set_windows_version_resource_properties(name resource_file...
# VERSION_MAJOR int
# Optional major version number (defaults to LLVM_VERSION_MAJOR)
# VERSION_MINOR int
# Optional minor version number (defaults to LLVM_VERSION_MINOR)
# VERSION_PATCHLEVEL int
# Optional patchlevel version number (defaults to LLVM_VERSION_PATCH)
# VERSION_STRING
# Optional version string (defaults to PACKAGE_VERSION)
# PRODUCT_NAME
# Optional product name string (defaults to "LLVM")
# )
function(set_windows_version_resource_properties name resource_file)
cmake_parse_arguments(ARG
""
"VERSION_MAJOR;VERSION_MINOR;VERSION_PATCHLEVEL;VERSION_STRING;PRODUCT_NAME"
""
${ARGN})
if (NOT DEFINED ARG_VERSION_MAJOR)
set(ARG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
endif()
if (NOT DEFINED ARG_VERSION_MINOR)
set(ARG_VERSION_MINOR ${LLVM_VERSION_MINOR})
endif()
if (NOT DEFINED ARG_VERSION_PATCHLEVEL)
set(ARG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
endif()
if (NOT DEFINED ARG_VERSION_STRING)
set(ARG_VERSION_STRING ${PACKAGE_VERSION})
endif()
if (NOT DEFINED ARG_PRODUCT_NAME)
set(ARG_PRODUCT_NAME "LLVM")
endif()
set_property(SOURCE ${resource_file}
PROPERTY COMPILE_FLAGS /nologo)
set_property(SOURCE ${resource_file}
PROPERTY COMPILE_DEFINITIONS
"RC_VERSION_FIELD_1=${ARG_VERSION_MAJOR}"
"RC_VERSION_FIELD_2=${ARG_VERSION_MINOR}"
"RC_VERSION_FIELD_3=${ARG_VERSION_PATCHLEVEL}"
"RC_VERSION_FIELD_4=0"
"RC_FILE_VERSION=\"${ARG_VERSION_STRING}\""
"RC_INTERNAL_NAME=\"${name}\""
"RC_PRODUCT_NAME=\"${ARG_PRODUCT_NAME}\""
"RC_PRODUCT_VERSION=\"${ARG_VERSION_STRING}\"")
endfunction(set_windows_version_resource_properties)
# llvm_add_library(name sources...
# SHARED;STATIC
# STATIC by default w/o BUILD_SHARED_LIBS.
# SHARED by default w/ BUILD_SHARED_LIBS.
# OBJECT
# Also create an OBJECT library target. Default if STATIC && SHARED.
# MODULE
# Target ${name} might not be created on unsupported platforms.
# Check with "if(TARGET ${name})".
# DISABLE_LLVM_LINK_LLVM_DYLIB
# Do not link this library to libLLVM, even if
# LLVM_LINK_LLVM_DYLIB is enabled.
# OUTPUT_NAME name
# Corresponds to OUTPUT_NAME in target properties.
# DEPENDS targets...
# Same semantics as add_dependencies().
# LINK_COMPONENTS components...
# Same as the variable LLVM_LINK_COMPONENTS.
# LINK_LIBS lib_targets...
# Same semantics as target_link_libraries().
# ADDITIONAL_HEADERS
# May specify header files for IDE generators.
# SONAME
# Should set SONAME link flags and create symlinks
# )
function(llvm_add_library name)
cmake_parse_arguments(ARG
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
"OUTPUT_NAME"
"ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
${ARGN})
list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
if(ARG_ADDITIONAL_HEADERS)
# Pass through ADDITIONAL_HEADERS.
set(ARG_ADDITIONAL_HEADERS ADDITIONAL_HEADERS ${ARG_ADDITIONAL_HEADERS})
endif()
if(ARG_OBJLIBS)
set(ALL_FILES ${ARG_OBJLIBS})
else()
llvm_process_sources(ALL_FILES ${ARG_UNPARSED_ARGUMENTS} ${ARG_ADDITIONAL_HEADERS})
endif()
if(ARG_MODULE)
if(ARG_SHARED OR ARG_STATIC)
message(WARNING "MODULE with SHARED|STATIC doesn't make sense.")
endif()
if(NOT LLVM_ENABLE_PLUGINS)
message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
return()
endif()
else()
if(BUILD_SHARED_LIBS AND NOT ARG_STATIC)
set(ARG_SHARED TRUE)
endif()
if(NOT ARG_SHARED)
set(ARG_STATIC TRUE)
endif()
endif()
# Generate objlib
if((ARG_SHARED AND ARG_STATIC) OR ARG_OBJECT)
# Generate an obj library for both targets.
set(obj_name "obj.${name}")
add_library(${obj_name} OBJECT EXCLUDE_FROM_ALL
${ALL_FILES}
)
llvm_update_compile_flags(${obj_name})
set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>")
# Do add_dependencies(obj) later due to CMake issue 14747.
list(APPEND objlibs ${obj_name})
set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
endif()
if(ARG_SHARED AND ARG_STATIC)
# static
set(name_static "${name}_static")
if(ARG_OUTPUT_NAME)
set(output_name OUTPUT_NAME "${ARG_OUTPUT_NAME}")
endif()
# DEPENDS has been appended to LLVM_COMMON_LIBS.
llvm_add_library(${name_static} STATIC
${output_name}
OBJLIBS ${ALL_FILES} # objlib
LINK_LIBS ${ARG_LINK_LIBS}
LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
)
# FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
set(ARG_STATIC)
endif()
if(ARG_MODULE)
add_library(${name} MODULE ${ALL_FILES})
elseif(ARG_SHARED)
add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
add_library(${name} SHARED ${ALL_FILES})
else()
add_library(${name} STATIC ${ALL_FILES})
endif()
if(DEFINED windows_resource_file)
set_windows_version_resource_properties(${name} ${windows_resource_file})
set(windows_resource_file ${windows_resource_file} PARENT_SCOPE)
endif()
set_output_directory(${name} BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR} LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
# $<TARGET_OBJECTS> doesn't require compile flags.
if(NOT obj_name)
llvm_update_compile_flags(${name})
endif()
add_link_opts( ${name} )
if(ARG_OUTPUT_NAME)
set_target_properties(${name}
PROPERTIES
OUTPUT_NAME ${ARG_OUTPUT_NAME}
)
endif()
if(ARG_MODULE)
set_target_properties(${name} PROPERTIES
PREFIX ""
SUFFIX ${LLVM_PLUGIN_EXT}
)
endif()
if(ARG_SHARED)
if(WIN32)
set_target_properties(${name} PROPERTIES
PREFIX ""
)
endif()
endif()
if(ARG_MODULE OR ARG_SHARED)
# Do not add -Dname_EXPORTS to the command-line when building files in this
# target. Doing so is actively harmful for the modules build because it
# creates extra module variants, and not useful because we don't use these
# macros.
set_target_properties( ${name} PROPERTIES DEFINE_SYMBOL "" )
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif()
endif()
if(ARG_SHARED AND UNIX)
if(NOT APPLE AND ARG_SONAME)
get_target_property(output_name ${name} OUTPUT_NAME)
if(${output_name} STREQUAL "output_name-NOTFOUND")
set(output_name ${name})
endif()
set(library_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX})
set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name})
llvm_install_library_symlink(${api_name} ${library_name} SHARED
COMPONENT ${name}
ALWAYS_GENERATE)
llvm_install_library_symlink(${output_name} ${library_name} SHARED
COMPONENT ${name}
ALWAYS_GENERATE)
endif()
endif()
if (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS)
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
llvm_map_components_to_libnames(llvm_libs
${ARG_LINK_COMPONENTS}
${LLVM_LINK_COMPONENTS}
)
endif()
else()
# Components have not been defined explicitly in CMake, so add the
# dependency information for this library as defined by LLVMBuild.
#
# It would be nice to verify that we have the dependencies for this library
# name, but using get_property(... SET) doesn't suffice to determine if a
# property has been set to an empty value.
get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
endif()
if(CMAKE_VERSION VERSION_LESS 2.8.12)
# Link libs w/o keywords, assuming PUBLIC.
target_link_libraries(${name}
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
elseif(ARG_STATIC)
target_link_libraries(${name} INTERFACE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
else()
# We can use PRIVATE since SO knows its dependent libs.
target_link_libraries(${name} PRIVATE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
endif()
if(LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
# Add dependencies also to objlibs.
# CMake issue 14747 -- add_dependencies() might be ignored to objlib's user.
foreach(objlib ${objlibs})
add_dependencies(${objlib} ${LLVM_COMMON_DEPENDS})
endforeach()
endif()
if(ARG_SHARED OR ARG_MODULE)
llvm_externalize_debuginfo(${name})
endif()
endfunction()
macro(add_llvm_library name)
cmake_parse_arguments(ARG
"SHARED"
""
""
${ARGN})
if( BUILD_SHARED_LIBS )
llvm_add_library(${name} SHARED ${ARGN})
else()
llvm_add_library(${name} ${ARGN})
endif()
# The gtest libraries should not be installed or exported as a target
if ("${name}" STREQUAL gtest OR "${name}" STREQUAL gtest_main)
set(_is_gtest TRUE)
else()
set(_is_gtest FALSE)
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
endif()
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
elseif(NOT _is_gtest)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
set(install_dir lib${LLVM_LIBDIR_SUFFIX})
if(ARG_SHARED OR BUILD_SHARED_LIBS)
if(WIN32 OR CYGWIN OR MINGW)
set(install_type RUNTIME)
set(install_dir bin)
else()
set(install_type LIBRARY)
endif()
else()
set(install_type ARCHIVE)
endif()
install(TARGETS ${name}
EXPORT LLVMExports
${install_type} DESTINATION ${install_dir}
COMPONENT ${name})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_custom_target(install-${name}
DEPENDS ${name}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Libraries")
endmacro(add_llvm_library name)
macro(add_llvm_loadable_module name)
llvm_add_library(${name} MODULE ${ARGN})
if(NOT TARGET ${name})
# Add empty "phony" target
add_custom_target(${name})
else()
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if(WIN32 OR CYGWIN)
# DLL platform
set(dlldir "bin")
else()
set(dlldir "lib${LLVM_LIBDIR_SUFFIX}")
endif()
install(TARGETS ${name}
EXPORT LLVMExports
LIBRARY DESTINATION ${dlldir}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
endif()
set_target_properties(${name} PROPERTIES FOLDER "Loadable modules")
endmacro(add_llvm_loadable_module name)
macro(add_llvm_executable name)
cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO" "" "" ${ARGN})
llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
# Generate objlib
if(LLVM_ENABLE_OBJLIB)
# Generate an obj library for both targets.
set(obj_name "obj.${name}")
add_library(${obj_name} OBJECT EXCLUDE_FROM_ALL
${ALL_FILES}
)
llvm_update_compile_flags(${obj_name})
set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>")
set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
endif()
add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
if(XCODE)
# Note: the dummy.cpp source file provides no definitions. However,
# it forces Xcode to properly link the static library.
list(APPEND ALL_FILES "${LLVM_MAIN_SRC_DIR}/cmake/dummy.cpp")
endif()
if( EXCLUDE_FROM_ALL )
add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
else()
add_executable(${name} ${ALL_FILES})
endif()
if(DEFINED windows_resource_file)
set_windows_version_resource_properties(${name} ${windows_resource_file})
endif()
# $<TARGET_OBJECTS> doesn't require compile flags.
if(NOT LLVM_ENABLE_OBJLIB)
llvm_update_compile_flags(${name})
endif()
add_link_opts( ${name} )
# Do not add -Dname_EXPORTS to the command-line when building files in this
# target. Doing so is actively harmful for the modules build because it
# creates extra module variants, and not useful because we don't use these
# macros.
set_target_properties( ${name} PROPERTIES DEFINE_SYMBOL "" )
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif(LLVM_EXPORTED_SYMBOL_FILE)
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
set(USE_SHARED USE_SHARED)
endif()
set(EXCLUDE_FROM_ALL OFF)
set_output_directory(${name} BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR} LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
llvm_config( ${name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO)
llvm_externalize_debuginfo(${name})
endif()
endmacro(add_llvm_executable name)
function(export_executable_symbols target)
if (NOT MSVC) # MSVC's linker doesn't support exporting all symbols.
set_target_properties(${target} PROPERTIES ENABLE_EXPORTS 1)
if (APPLE)
set_property(TARGET ${target} APPEND_STRING PROPERTY
LINK_FLAGS " -rdynamic")
endif()
endif()
endfunction()
if(NOT LLVM_TOOLCHAIN_TOOLS)
set (LLVM_TOOLCHAIN_TOOLS
llvm-ar
llvm-ranlib
llvm-lib
llvm-objdump
)
endif()
macro(add_llvm_tool name)
if( NOT LLVM_BUILD_TOOLS )
set(EXCLUDE_FROM_ALL ON)
endif()
add_llvm_executable(${name} ${ARGN})
list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
install(TARGETS ${name}
EXPORT LLVMExports
RUNTIME DESTINATION bin
COMPONENT ${name})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_custom_target(install-${name}
DEPENDS ${name}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endif()
endif()
if( LLVM_BUILD_TOOLS )
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Tools")
endmacro(add_llvm_tool name)
macro(add_llvm_example name)
if( NOT LLVM_BUILD_EXAMPLES )
set(EXCLUDE_FROM_ALL ON)
endif()
add_llvm_executable(${name} ${ARGN})
if( LLVM_BUILD_EXAMPLES )
install(TARGETS ${name} RUNTIME DESTINATION examples)
endif()
set_target_properties(${name} PROPERTIES FOLDER "Examples")
endmacro(add_llvm_example name)
macro(add_llvm_utility name)
add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
set_target_properties(${name} PROPERTIES FOLDER "Utils")
if( LLVM_INSTALL_UTILS )
install (TARGETS ${name}
RUNTIME DESTINATION bin
COMPONENT ${name})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_custom_target(install-${name}
DEPENDS ${name}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endif()
endmacro(add_llvm_utility name)
macro(add_llvm_target target_name)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
add_llvm_library(LLVM${target_name} ${ARGN})
set( CURRENT_LLVM_TARGET LLVM${target_name} )
endmacro(add_llvm_target)
function(canonicalize_tool_name name output)
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" nameStrip ${name})
string(REPLACE "-" "_" nameUNDERSCORE ${nameStrip})
string(TOUPPER ${nameUNDERSCORE} nameUPPER)
set(${output} "${nameUPPER}" PARENT_SCOPE)
endfunction(canonicalize_tool_name)
# Custom add_subdirectory wrapper
# Takes in a project name (i.e. LLVM), the the subdirectory name, and an
# and an optional path if it differs from the name.
macro(add_llvm_subdirectory project type name)
set(add_llvm_external_dir "${ARGN}")
if("${add_llvm_external_dir}" STREQUAL "")
set(add_llvm_external_dir ${name})
endif()
canonicalize_tool_name(${name} nameUPPER)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}/CMakeLists.txt)
# Treat it as in-tree subproject.
option(${project}_${type}_${nameUPPER}_BUILD
"Whether to build ${name} as part of ${project}" On)
mark_as_advanced(${project}_${type}_${name}_BUILD)
if(${project}_${type}_${nameUPPER}_BUILD)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
# Don't process it in add_llvm_implicit_projects().
set(${project}_${type}_${nameUPPER}_BUILD OFF)
endif()
else()
set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR
"${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}"
CACHE PATH "Path to ${name} source directory")
set(${project}_${type}_${nameUPPER}_BUILD_DEFAULT ON)
if(NOT LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR OR NOT EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR})
set(${project}_${type}_${nameUPPER}_BUILD_DEFAULT OFF)
endif()
if("${LLVM_EXTERNAL_${nameUPPER}_BUILD}" STREQUAL "OFF")
set(${project}_${type}_${nameUPPER}_BUILD_DEFAULT OFF)
endif()
option(${project}_${type}_${nameUPPER}_BUILD
"Whether to build ${name} as part of LLVM"
${${project}_${type}_${nameUPPER}_BUILD_DEFAULT})
if (${project}_${type}_${nameUPPER}_BUILD)
if(EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR})
add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
elseif(NOT "${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}" STREQUAL "")
message(WARNING "Nonexistent directory for ${name}: ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}")
endif()
# FIXME: It'd be redundant.
set(${project}_${type}_${nameUPPER}_BUILD Off)
endif()
endif()
endmacro()
# Add external project that may want to be built as part of llvm such as Clang,
# lld, and Polly. This adds two options. One for the source directory of the
# project, which defaults to ${CMAKE_CURRENT_SOURCE_DIR}/${name}. Another to
# enable or disable building it with everything else.
# Additional parameter can be specified as the name of directory.
macro(add_llvm_external_project name)
add_llvm_subdirectory(LLVM TOOL ${name} ${ARGN})
endmacro()
macro(add_llvm_tool_subdirectory name)
add_llvm_external_project(${name})
endmacro(add_llvm_tool_subdirectory)
function(get_project_name_from_src_var var output)
string(REGEX MATCH "LLVM_EXTERNAL_(.*)_SOURCE_DIR"
MACHED_TOOL "${var}")
if(MACHED_TOOL)
set(${output} ${CMAKE_MATCH_1} PARENT_SCOPE)
else()
set(${output} PARENT_SCOPE)
endif()
endfunction()
function(create_subdirectory_options project type)
file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
foreach(dir ${sub-dirs})
if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
canonicalize_tool_name(${dir} name)
option(${project}_${type}_${name}_BUILD
"Whether to build ${name} as part of ${project}" On)
mark_as_advanced(${project}_${type}_${name}_BUILD)
endif()
endforeach()
endfunction(create_subdirectory_options)
function(create_llvm_tool_options)
create_subdirectory_options(LLVM TOOL)
endfunction(create_llvm_tool_options)
function(add_llvm_implicit_projects)
set(list_of_implicit_subdirs "")
file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
foreach(dir ${sub-dirs})
if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
canonicalize_tool_name(${dir} name)
if (LLVM_TOOL_${name}_BUILD)
get_filename_component(fn "${dir}" NAME)
list(APPEND list_of_implicit_subdirs "${fn}")
endif()
endif()
endforeach()
foreach(external_proj ${list_of_implicit_subdirs})
add_llvm_external_project("${external_proj}")
endforeach()
endfunction(add_llvm_implicit_projects)
# Generic support for adding a unittest.
function(add_unittest test_suite test_name)
if( NOT LLVM_BUILD_TESTS )
set(EXCLUDE_FROM_ALL ON)
endif()
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
if (NOT LLVM_ENABLE_THREADS)
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
endif ()
if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
endif ()
set(LLVM_REQUIRES_RTTI OFF)
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO ${ARGN})
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
target_link_libraries(${test_name} gtest_main gtest)
add_dependencies(${test_suite} ${test_name})
get_target_property(test_suite_folder ${test_suite} FOLDER)
if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
endif ()
endfunction()
function(llvm_add_go_executable binary pkgpath)
cmake_parse_arguments(ARG "ALL" "" "DEPENDS;GOFLAGS" ${ARGN})
if(LLVM_BINDINGS MATCHES "go")
# FIXME: This should depend only on the libraries Go needs.
get_property(llvmlibs GLOBAL PROPERTY LLVM_LIBS)
set(binpath ${CMAKE_BINARY_DIR}/bin/${binary}${CMAKE_EXECUTABLE_SUFFIX})
set(cc "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}")
set(cxx "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
set(cppflags "")
get_property(include_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
foreach(d ${include_dirs})
set(cppflags "${cppflags} -I${d}")
endforeach(d)
set(ldflags "${CMAKE_EXE_LINKER_FLAGS}")
if (LLVM_LINK_LLVM_DYLIB)
set(linkmode "dylib")
else()
set(linkmode "component-libs")
endif()
add_custom_command(OUTPUT ${binpath}
COMMAND ${CMAKE_BINARY_DIR}/bin/llvm-go "go=${GO_EXECUTABLE}" "cc=${cc}" "cxx=${cxx}" "cppflags=${cppflags}" "ldflags=${ldflags}" "linkmode=${linkmode}"
${ARG_GOFLAGS} build -o ${binpath} ${pkgpath}
DEPENDS llvm-config ${CMAKE_BINARY_DIR}/bin/llvm-go${CMAKE_EXECUTABLE_SUFFIX}
${llvmlibs} ${ARG_DEPENDS}
COMMENT "Building Go executable ${binary}"
VERBATIM)
if (ARG_ALL)
add_custom_target(${binary} ALL DEPENDS ${binpath})
else()
add_custom_target(${binary} DEPENDS ${binpath})
endif()
endif()
endfunction()
# This function provides an automatic way to 'configure'-like generate a file
# based on a set of common and custom variables, specifically targeting the
# variables needed for the 'lit.site.cfg' files. This function bundles the
# common variables that any Lit instance is likely to need, and custom
# variables can be passed in.
function(configure_lit_site_cfg input output)
foreach(c ${LLVM_TARGETS_TO_BUILD})
set(TARGETS_BUILT "${TARGETS_BUILT} ${c}")
endforeach(c)
set(TARGETS_TO_BUILD ${TARGETS_BUILT})
set(SHLIBEXT "${LTDL_SHLIB_EXT}")
# Configuration-time: See Unit/lit.site.cfg.in
if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
else ()
set(LLVM_BUILD_MODE "%(build_mode)s")
endif ()
# They below might not be the build tree but provided binary tree.
set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR ${LLVM_LIBRARY_DIR})
# SHLIBDIR points the build tree.
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
# FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
# plugins. We may rename it.
if(LLVM_ENABLE_PLUGINS)
set(ENABLE_SHARED "1")
else()
set(ENABLE_SHARED "0")
endif()
if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
set(ENABLE_ASSERTIONS "1")
else()
set(ENABLE_ASSERTIONS "0")
endif()
set(HOST_OS ${CMAKE_SYSTEM_NAME})
set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR})
set(HOST_CC "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}")
set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}")
configure_file(${input} ${output} @ONLY)
endfunction()
# A raw function to create a lit target. This is used to implement the testuite
# management functions.
function(add_lit_target target comment)
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
set(LIT_ARGS "${ARG_ARGS} ${LLVM_LIT_ARGS}")
separate_arguments(LIT_ARGS)
if (NOT CMAKE_CFG_INTDIR STREQUAL ".")
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
if (LLVM_MAIN_SRC_DIR)
set (LIT_COMMAND ${PYTHON_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
else()
find_program(LIT_COMMAND llvm-lit)
endif ()
list(APPEND LIT_COMMAND ${LIT_ARGS})
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})
endforeach()
if (ARG_UNPARSED_ARGUMENTS)
add_custom_target(${target}
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
COMMENT "${comment}"
${cmake_3_2_USES_TERMINAL}
)
else()
add_custom_target(${target}
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
message(STATUS "${target} does nothing.")
endif()
if (ARG_DEPENDS)
add_dependencies(${target} ${ARG_DEPENDS})
endif()
# Tests should be excluded from "Build Solution".
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
endfunction()
# A function to add a set of lit test suites to be driven through 'check-*' targets.
function(add_lit_testsuite target comment)
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
# EXCLUDE_FROM_ALL excludes the test ${target} out of check-all.
if(NOT EXCLUDE_FROM_ALL)
# Register the testsuites, params and depends for the global check rule.
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_TESTSUITES ${ARG_UNPARSED_ARGUMENTS})
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_PARAMS ${ARG_PARAMS})
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_EXTRA_ARGS ${ARG_ARGS})
endif()
# Produce a specific suffixed check rule.
add_lit_target(${target} ${comment}
${ARG_UNPARSED_ARGUMENTS}
PARAMS ${ARG_PARAMS}
DEPENDS ${ARG_DEPENDS}
ARGS ${ARG_ARGS}
)
endfunction()
function(add_lit_testsuites project directory)
if (NOT CMAKE_CONFIGURATION_TYPES)
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
file(GLOB_RECURSE litCfg ${directory}/lit*.cfg)
set(lit_suites)
foreach(f ${litCfg})
get_filename_component(dir ${f} DIRECTORY)
set(lit_suites ${lit_suites} ${dir})
endforeach()
list(REMOVE_DUPLICATES lit_suites)
foreach(dir ${lit_suites})
string(REPLACE ${directory} "" name_slash ${dir})
if (name_slash)
string(REPLACE "/" "-" name_slash ${name_slash})
string(REPLACE "\\" "-" name_dashes ${name_slash})
string(TOLOWER "${project}${name_dashes}" name_var)
add_lit_target("check-${name_var}" "Running lit suite ${dir}"
${dir}
PARAMS ${ARG_PARAMS}
DEPENDS ${ARG_DEPENDS}
ARGS ${ARG_ARGS}
)
endif()
endforeach()
endif()
endfunction()
function(llvm_install_library_symlink name dest type)
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
break()
endif()
endforeach()
set(component ${ARG_COMPONENT})
if(NOT component)
set(component ${name})
endif()
set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
set(output_dir lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 AND "${type}" STREQUAL "SHARED")
set(output_dir bin)
endif()
install(SCRIPT ${INSTALL_SYMLINK}
CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
COMPONENT ${component})
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
add_custom_target(install-${name}
DEPENDS ${name} ${dest} install-${dest}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endfunction()
function(llvm_install_symlink name dest)
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
break()
endif()
endforeach()
if(ARG_ALWAYS_GENERATE)
set(component ${dest})
else()
set(component ${name})
endif()
set(full_name ${name}${CMAKE_EXECUTABLE_SUFFIX})
set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
install(SCRIPT ${INSTALL_SYMLINK}
CODE "install_symlink(${full_name} ${full_dest} bin)"
COMPONENT ${component})
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
add_custom_target(install-${name}
DEPENDS ${name} ${dest} install-${dest}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
endfunction()
function(add_llvm_tool_symlink name dest)
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
if(UNIX)
set(LLVM_LINK_OR_COPY create_symlink)
set(dest_binary "${dest}${CMAKE_EXECUTABLE_SUFFIX}")
else()
set(LLVM_LINK_OR_COPY copy)
set(dest_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/${dest}${CMAKE_EXECUTABLE_SUFFIX}")
endif()
set(output_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
if(ARG_ALWAYS_GENERATE)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${dest_binary})
add_custom_command(TARGET ${dest} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}")
else()
add_custom_command(OUTPUT ${output_path}
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}"
DEPENDS ${dest})
add_custom_target(${name} ALL DEPENDS ${output_path})
set_target_properties(${name} PROPERTIES FOLDER Tools)
# Make sure the parent tool is a toolchain tool, otherwise exclude this tool
list(FIND LLVM_TOOLCHAIN_TOOLS ${dest} LLVM_IS_${dest}_TOOLCHAIN_TOOL)
if (NOT LLVM_IS_${dest}_TOOLCHAIN_TOOL GREATER -1)
set(LLVM_IS_${name}_TOOLCHAIN_TOOL ${LLVM_IS_${dest}_TOOLCHAIN_TOOL})
else()
list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
endif()
# LLVM_IS_${name}_TOOLCHAIN_TOOL will only be greater than -1 if both this
# tool and its parent tool are in LLVM_TOOLCHAIN_TOOLS
if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
llvm_install_symlink(${name} ${dest})
endif()
endif()
endif()
endfunction()
function(llvm_externalize_debuginfo name)
if(NOT LLVM_EXTERNALIZE_DEBUGINFO)
return()
endif()
if(APPLE)
if(CMAKE_CXX_FLAGS MATCHES "-flto"
OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
set(lto_object ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}-lto.o)
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-object_path_lto,${lto_object}")
endif()
add_custom_command(TARGET ${name} POST_BUILD
COMMAND xcrun dsymutil $<TARGET_FILE:${name}>
COMMAND xcrun strip -Sl $<TARGET_FILE:${name}>)
else()
message(FATAL_ERROR "LLVM_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
endif()
endfunction()
# There is no clear way of keeping track of compiler command-line
# options chosen via `add_definitions', so we need our own method for
# using it on tools/llvm-config/CMakeLists.txt.
# Beware that there is no implementation of remove_llvm_definitions.
macro(add_llvm_definitions)
# We don't want no semicolons on LLVM_DEFINITIONS:
foreach(arg ${ARGN})
if(DEFINED LLVM_DEFINITIONS)
set(LLVM_DEFINITIONS "${LLVM_DEFINITIONS} ${arg}")
else()
set(LLVM_DEFINITIONS ${arg})
endif()
endforeach(arg)
add_definitions( ${ARGN} )
endmacro(add_llvm_definitions)
# CMake build rules for the OCaml language.
# Assumes FindOCaml is used.
# http://ocaml.org/
#
# Example usage:
#
# add_ocaml_library(pkg_a OCAML mod_a OCAMLDEP pkg_b C mod_a_stubs PKG ctypes LLVM core)
#
# Unnamed parameters:
#
# * Library name.
#
# Named parameters:
#
# OCAML OCaml module names. Imply presence of a corresponding .ml and .mli files.
# OCAMLDEP Names of libraries this library depends on.
# C C stub sources. Imply presence of a corresponding .c file.
# CFLAGS Additional arguments passed when compiling C stubs.
# PKG Names of ocamlfind packages this library depends on.
# LLVM Names of LLVM libraries this library depends on.
# NOCOPY Do not automatically copy sources (.c, .ml, .mli) from the source directory,
# e.g. if they are generated.
#
function(add_ocaml_library name)
CMAKE_PARSE_ARGUMENTS(ARG "NOCOPY" "" "OCAML;OCAMLDEP;C;CFLAGS;PKG;LLVM" ${ARGN})
set(src ${CMAKE_CURRENT_SOURCE_DIR})
set(bin ${CMAKE_CURRENT_BINARY_DIR})
set(ocaml_pkgs)
foreach( ocaml_pkg ${ARG_PKG} )
list(APPEND ocaml_pkgs "-package" "${ocaml_pkg}")
endforeach()
set(sources)
set(ocaml_inputs)
set(ocaml_outputs "${bin}/${name}.cma")
if( ARG_C )
list(APPEND ocaml_outputs
"${bin}/lib${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
if ( BUILD_SHARED_LIBS )
list(APPEND ocaml_outputs
"${bin}/dll${name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
endif()
if( HAVE_OCAMLOPT )
list(APPEND ocaml_outputs
"${bin}/${name}.cmxa"
"${bin}/${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
set(ocaml_flags "-lstdc++" "-ldopt" "-L${LLVM_LIBRARY_DIR}"
"-ccopt" "-L\\$CAMLORIGIN/.."
"-ccopt" "-Wl,-rpath,\\$CAMLORIGIN/.."
${ocaml_pkgs})
foreach( ocaml_dep ${ARG_OCAMLDEP} )
get_target_property(dep_ocaml_flags "ocaml_${ocaml_dep}" OCAML_FLAGS)
list(APPEND ocaml_flags ${dep_ocaml_flags})
endforeach()
if( NOT BUILD_SHARED_LIBS )
list(APPEND ocaml_flags "-custom")
endif()
explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM})
foreach( llvm_lib ${llvm_libs} )
list(APPEND ocaml_flags "-l${llvm_lib}" )
endforeach()
get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
foreach(system_lib ${system_libs})
list(APPEND ocaml_flags "-l${system_lib}" )
endforeach()
string(REPLACE ";" " " ARG_CFLAGS "${ARG_CFLAGS}")
set(c_flags "${ARG_CFLAGS} ${LLVM_DEFINITIONS}")
foreach( include_dir ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR} )
set(c_flags "${c_flags} -I${include_dir}")
endforeach()
foreach( ocaml_file ${ARG_OCAML} )
list(APPEND sources "${ocaml_file}.mli" "${ocaml_file}.ml")
list(APPEND ocaml_inputs "${bin}/${ocaml_file}.mli" "${bin}/${ocaml_file}.ml")
list(APPEND ocaml_outputs "${bin}/${ocaml_file}.cmi" "${bin}/${ocaml_file}.cmo")
if( HAVE_OCAMLOPT )
list(APPEND ocaml_outputs
"${bin}/${ocaml_file}.cmx"
"${bin}/${ocaml_file}${CMAKE_C_OUTPUT_EXTENSION}")
endif()
endforeach()
foreach( c_file ${ARG_C} )
list(APPEND sources "${c_file}.c")
list(APPEND c_inputs "${bin}/${c_file}.c")
list(APPEND c_outputs "${bin}/${c_file}${CMAKE_C_OUTPUT_EXTENSION}")
endforeach()
if( NOT ARG_NOCOPY )
foreach( source ${sources} )
add_custom_command(
OUTPUT "${bin}/${source}"
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${src}/${source}" "${bin}"
DEPENDS "${src}/${source}"
COMMENT "Copying ${source} to build area")
endforeach()
endif()
foreach( c_input ${c_inputs} )
get_filename_component(basename "${c_input}" NAME_WE)
add_custom_command(
OUTPUT "${basename}${CMAKE_C_OUTPUT_EXTENSION}"
COMMAND "${OCAMLFIND}" "ocamlc" "-c" "${c_input}" -ccopt ${c_flags}
DEPENDS "${c_input}"
COMMENT "Building OCaml stub object file ${basename}${CMAKE_C_OUTPUT_EXTENSION}"
VERBATIM)
endforeach()
set(ocaml_params)
foreach( ocaml_input ${ocaml_inputs} ${c_outputs})
get_filename_component(filename "${ocaml_input}" NAME)
list(APPEND ocaml_params "${filename}")
endforeach()
if( APPLE )
set(ocaml_rpath "@executable_path/../../lib")
elseif( UNIX )
set(ocaml_rpath "\\$ORIGIN/../../lib")
endif()
list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
add_custom_command(
OUTPUT ${ocaml_outputs}
COMMAND "${OCAMLFIND}" "ocamlmklib" "-o" "${name}" ${ocaml_flags} ${ocaml_params}
DEPENDS ${ocaml_inputs} ${c_outputs}
COMMENT "Building OCaml library ${name}"
VERBATIM)
add_custom_command(
OUTPUT "${bin}/${name}.odoc"
COMMAND "${OCAMLFIND}" "ocamldoc"
"-I" "${bin}"
"-I" "${LLVM_LIBRARY_DIR}/ocaml/"
"-dump" "${bin}/${name}.odoc"
${ocaml_pkgs} ${ocaml_inputs}
DEPENDS ${ocaml_inputs} ${ocaml_outputs}
COMMENT "Building OCaml documentation for ${name}"
VERBATIM)
add_custom_target("ocaml_${name}" ALL DEPENDS ${ocaml_outputs} "${bin}/${name}.odoc")
set_target_properties("ocaml_${name}" PROPERTIES
OCAML_FLAGS "-I;${bin}")
set_target_properties("ocaml_${name}" PROPERTIES
OCAML_ODOC "${bin}/${name}.odoc")
foreach( ocaml_dep ${ARG_OCAMLDEP} )
add_dependencies("ocaml_${name}" "ocaml_${ocaml_dep}")
endforeach()
foreach( llvm_lib ${llvm_libs} )
add_dependencies("ocaml_${name}" "${llvm_lib}")
endforeach()
set(install_files)
set(install_shlibs)
foreach( ocaml_output ${ocaml_outputs} )
get_filename_component(ext "${ocaml_output}" EXT)
if( NOT (ext STREQUAL ".cmo" OR
ext STREQUAL CMAKE_C_OUTPUT_EXTENSION OR
ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX) )
list(APPEND install_files "${ocaml_output}")
elseif( ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX)
list(APPEND install_shlibs "${ocaml_output}")
endif()
endforeach()
install(FILES ${install_files}
DESTINATION lib/ocaml)
install(FILES ${install_shlibs}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION lib/ocaml)
foreach( install_file ${install_files} ${install_shlibs} )
get_filename_component(filename "${install_file}" NAME)
add_custom_command(TARGET "ocaml_${name}" POST_BUILD
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${install_file}"
"${LLVM_LIBRARY_DIR}/ocaml/"
COMMENT "Copying OCaml library component ${filename} to intermediate area"
VERBATIM)
endforeach()
endfunction()
# Handy function for creating the different Sphinx targets.
#
# ``builder`` should be one of the supported builders used by
# the sphinx-build command.
#
# ``project`` should be the project name
function (add_sphinx_target builder project)
set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${builder}")
set(SPHINX_DOC_TREE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
set(SPHINX_TARGET_NAME docs-${project}-${builder})
if (SPHINX_WARNINGS_AS_ERRORS)
set(SPHINX_WARNINGS_AS_ERRORS_FLAG "-W")
else()
set(SPHINX_WARNINGS_AS_ERRORS_FLAG "")
endif()
add_custom_target(${SPHINX_TARGET_NAME}
COMMAND ${SPHINX_EXECUTABLE}
-b ${builder}
-d "${SPHINX_DOC_TREE_DIR}"
-q # Quiet: no output other than errors and warnings.
${SPHINX_WARNINGS_AS_ERRORS_FLAG} # Treat warnings as errors if requested
"${CMAKE_CURRENT_SOURCE_DIR}" # Source
"${SPHINX_BUILD_DIR}" # Output
COMMENT
"Generating ${builder} Sphinx documentation for ${project} into \"${SPHINX_BUILD_DIR}\"")
# When "clean" target is run, remove the Sphinx build directory
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${SPHINX_BUILD_DIR}")
# We need to remove ${SPHINX_DOC_TREE_DIR} when make clean is run
# but we should only add this path once
get_property(_CURRENT_MAKE_CLEAN_FILES
DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES)
list(FIND _CURRENT_MAKE_CLEAN_FILES "${SPHINX_DOC_TREE_DIR}" _INDEX)
if (_INDEX EQUAL -1)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${SPHINX_DOC_TREE_DIR}")
endif()
if (LLVM_BUILD_DOCS)
add_dependencies(sphinx ${SPHINX_TARGET_NAME})
# Handle installation
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if (builder STREQUAL man)
# FIXME: We might not ship all the tools that these man pages describe
install(DIRECTORY "${SPHINX_BUILD_DIR}/" # Slash indicates contents of
DESTINATION share/man/man1)
elseif (builder STREQUAL html)
install(DIRECTORY "${SPHINX_BUILD_DIR}"
DESTINATION "share/doc/${project}")
else()
message(WARNING Installation of ${builder} not supported)
endif()
endif()
endif()
endfunction()
# The macro choose_msvc_crt() takes a list of possible
# C runtimes to choose from, in the form of compiler flags,
# to present to the user. (MTd for /MTd, etc)
#
# The macro is invoked at the end of the file.
#
# CMake already sets CRT flags in the CMAKE_CXX_FLAGS_* and
# CMAKE_C_FLAGS_* variables by default. To let the user
# override that for each build type:
# 1. Detect which CRT is already selected, and reflect this in
# LLVM_USE_CRT_* so the user can have a better idea of what
# changes they're making.
# 2. Replace the flags in both variables with the new flag via a regex.
# 3. set() the variables back into the cache so the changes
# are user-visible.
### Helper macros: ###
macro(make_crt_regex regex crts)
set(${regex} "")
foreach(crt ${${crts}})
# Trying to match the beginning or end of the string with stuff
# like [ ^]+ didn't work, so use a bunch of parentheses instead.
set(${regex} "${${regex}}|(^| +)/${crt}($| +)")
endforeach(crt)
string(REGEX REPLACE "^\\|" "" ${regex} "${${regex}}")
endmacro(make_crt_regex)
macro(get_current_crt crt_current regex flagsvar)
# Find the selected-by-CMake CRT for each build type, if any.
# Strip off the leading slash and any whitespace.
string(REGEX MATCH "${${regex}}" ${crt_current} "${${flagsvar}}")
string(REPLACE "/" " " ${crt_current} "${${crt_current}}")
string(STRIP "${${crt_current}}" ${crt_current})
endmacro(get_current_crt)
# Replaces or adds a flag to a variable.
# Expects 'flag' to be padded with spaces.
macro(set_flag_in_var flagsvar regex flag)
string(REGEX MATCH "${${regex}}" current_flag "${${flagsvar}}")
if("${current_flag}" STREQUAL "")
set(${flagsvar} "${${flagsvar}}${${flag}}")
else()
string(REGEX REPLACE "${${regex}}" "${${flag}}" ${flagsvar} "${${flagsvar}}")
endif()
string(STRIP "${${flagsvar}}" ${flagsvar})
# Make sure this change gets reflected in the cache/gui.
# CMake requires the docstring parameter whenever set() touches the cache,
# so get the existing docstring and re-use that.
get_property(flagsvar_docs CACHE ${flagsvar} PROPERTY HELPSTRING)
set(${flagsvar} "${${flagsvar}}" CACHE STRING "${flagsvar_docs}" FORCE)
endmacro(set_flag_in_var)
macro(choose_msvc_crt MSVC_CRT)
if(LLVM_USE_CRT)
message(FATAL_ERROR
"LLVM_USE_CRT is deprecated. Use the CMAKE_BUILD_TYPE-specific
variables (LLVM_USE_CRT_DEBUG, etc) instead.")
endif()
make_crt_regex(MSVC_CRT_REGEX ${MSVC_CRT})
foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if (NOT LLVM_USE_CRT_${build})
get_current_crt(LLVM_USE_CRT_${build}
MSVC_CRT_REGEX
CMAKE_CXX_FLAGS_${build})
set(LLVM_USE_CRT_${build}
"${LLVM_USE_CRT_${build}}"
CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
FORCE)
set_property(CACHE LLVM_USE_CRT_${build}
PROPERTY STRINGS ;${${MSVC_CRT}})
endif(NOT LLVM_USE_CRT_${build})
endforeach(build_type)
foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if ("${LLVM_USE_CRT_${build}}" STREQUAL "")
set(flag_string " ")
else()
set(flag_string " /${LLVM_USE_CRT_${build}} ")
list(FIND ${MSVC_CRT} ${LLVM_USE_CRT_${build}} idx)
if (idx LESS 0)
message(FATAL_ERROR
"Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
endif (idx LESS 0)
message(STATUS "Using ${build_type} VC++ CRT: ${LLVM_USE_CRT_${build}}")
endif()
foreach(lang C CXX)
set_flag_in_var(CMAKE_${lang}_FLAGS_${build} MSVC_CRT_REGEX flag_string)
endforeach(lang)
endforeach(build_type)
endmacro(choose_msvc_crt MSVC_CRT)
# List of valid CRTs for MSVC
set(MSVC_CRT
MD
MDd
MT
MTd)
choose_msvc_crt(MSVC_CRT)
function(llvm_create_cross_target_internal target_name toochain buildtype)
if(NOT DEFINED LLVM_${target_name}_BUILD)
set(LLVM_${target_name}_BUILD "${CMAKE_BINARY_DIR}/${target_name}")
set(LLVM_${target_name}_BUILD ${LLVM_${target_name}_BUILD} PARENT_SCOPE)
message(STATUS "Setting native build dir to " ${LLVM_${target_name}_BUILD})
endif(NOT DEFINED LLVM_${target_name}_BUILD)
if (EXISTS ${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake)
set(CROSS_TOOLCHAIN_FLAGS_${target_name}
-DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\"
CACHE STRING "Toolchain file for ${target_name}")
endif()
add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}
COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_${target_name}_BUILD}
COMMENT "Creating ${LLVM_${target_name}_BUILD}...")
add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
DEPENDS ${LLVM_${target_name}_BUILD}
COMMENT "Configuring ${target_name} LLVM...")
add_custom_target(CONFIGURE_LLVM_${target_name}
DEPENDS ${LLVM_${target_name}_BUILD}/CMakeCache.txt)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
${LLVM_${target_name}_BUILD})
if(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
message(STATUS "Configuring ${target_name} build...")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
${LLVM_${target_name}_BUILD} )
message(STATUS "Configuring ${target_name} targets...")
if (buildtype)
set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} ${build_type_flags}
-G "${CMAKE_GENERATOR}" -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD} )
endif(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
endfunction()
function(llvm_create_cross_target target_name sysroot)
llvm_create_cross_target_internal(${target_name} ${sysroot} ${CMAKE_BUILD_TYPE})
endfunction()
llvm_create_cross_target_internal(NATIVE "" Release)
# Determine if the compiler has GCC-compatible command-line syntax.
if(NOT DEFINED LLVM_COMPILER_IS_GCC_COMPATIBLE)
if(CMAKE_COMPILER_IS_GNUCXX)
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
elseif( MSVC )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
endif()
endif()
# CMake find_package() module for the OCaml language.
# Assumes ocamlfind will be used for compilation.
# http://ocaml.org/
#
# Example usage:
#
# find_package(OCaml)
#
# If successful, the following variables will be defined:
# OCAMLFIND
# OCAML_VERSION
# OCAML_STDLIB_PATH
# HAVE_OCAMLOPT
#
# Also provides find_ocamlfind_package() macro.
#
# Example usage:
#
# find_ocamlfind_package(ctypes)
#
# In any case, the following variables are defined:
#
# HAVE_OCAML_${pkg}
#
# If successful, the following variables will be defined:
#
# OCAML_${pkg}_VERSION
include( FindPackageHandleStandardArgs )
find_program(OCAMLFIND
NAMES ocamlfind)
if( OCAMLFIND )
execute_process(
COMMAND ${OCAMLFIND} ocamlc -version
OUTPUT_VARIABLE OCAML_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${OCAMLFIND} ocamlc -where
OUTPUT_VARIABLE OCAML_STDLIB_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${OCAMLFIND} ocamlc -version
OUTPUT_QUIET
RESULT_VARIABLE find_ocaml_result)
if( find_ocaml_result EQUAL 0 )
set(HAVE_OCAMLOPT TRUE)
else()
set(HAVE_OCAMLOPT FALSE)
endif()
endif()
find_package_handle_standard_args( OCaml DEFAULT_MSG
OCAMLFIND
OCAML_VERSION
OCAML_STDLIB_PATH)
mark_as_advanced(
OCAMLFIND)
function(find_ocamlfind_package pkg)
CMAKE_PARSE_ARGUMENTS(ARG "OPTIONAL" "VERSION" "" ${ARGN})
execute_process(
COMMAND "${OCAMLFIND}" "query" "${pkg}" "-format" "%v"
RESULT_VARIABLE result
OUTPUT_VARIABLE version
ERROR_VARIABLE error
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if( NOT result EQUAL 0 AND NOT ARG_OPTIONAL )
message(FATAL_ERROR ${error})
endif()
if( result EQUAL 0 )
set(found TRUE)
else()
set(found FALSE)
endif()
if( found AND ARG_VERSION )
if( version VERSION_LESS ARG_VERSION AND ARG_OPTIONAL )
# If it's optional and the constraint is not satisfied, pretend
# it wasn't found.
set(found FALSE)
elseif( version VERSION_LESS ARG_VERSION )
message(FATAL_ERROR
"ocamlfind package ${pkg} should have version ${ARG_VERSION} or newer")
endif()
endif()
string(TOUPPER ${pkg} pkg)
set(HAVE_OCAML_${pkg} ${found}
PARENT_SCOPE)
set(OCAML_${pkg}_VERSION ${version}
PARENT_SCOPE)
endfunction()
# CMake find_package() Module for Sphinx documentation generator
# http://sphinx-doc.org/
#
# Example usage:
#
# find_package(Sphinx)
#
# If successful the following variables will be defined
# SPHINX_FOUND
# SPHINX_EXECUTABLE
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build sphinx-build2
DOC "Path to sphinx-build executable")
# Handle REQUIRED and QUIET arguments
# this will also set SPHINX_FOUND to true if SPHINX_EXECUTABLE exists
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx
"Failed to locate sphinx-build executable"
SPHINX_EXECUTABLE)
# Provide options for controlling different types of output
option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON)
option(SPHINX_OUTPUT_MAN "Output man pages" ON)
option(SPHINX_WARNINGS_AS_ERRORS "When building documentation treat warnings as errors" ON)
# CMake project that writes Subversion revision information to a header.
#
# Input variables:
# FIRST_SOURCE_DIR - First source directory
# FIRST_NAME - The macro prefix for the first repository's info
# SECOND_SOURCE_DIR - Second source directory (opt)
# SECOND_NAME - The macro prefix for the second repository's info (opt)
# HEADER_FILE - The header file to write
#
# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
# "SECOND" are substituted with the names specified in the input variables.
# Chop off cmake/modules/GetSVN.cmake
get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
# Handle strange terminals
set(ENV{TERM} "dumb")
macro(get_source_info_svn path revision repository)
# If svn is a bat file, find_program(Subversion) doesn't find it.
# Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
# the find_program call in FindSubversion.cmake.
find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
# FindSubversion does not work with symlinks. See PR 8437
if (NOT IS_SYMLINK "${path}")
find_package(Subversion)
endif()
if (Subversion_FOUND)
subversion_wc_info( ${path} Project )
if (Project_WC_REVISION)
set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
endif()
if (Project_WC_URL)
set(${repository} ${Project_WC_URL} PARENT_SCOPE)
endif()
endif()
endmacro()
macro(get_source_info_git_svn path revision repository)
find_program(git_executable NAMES git git.exe git.cmd)
if (git_executable)
execute_process(COMMAND ${git_executable} svn info
WORKING_DIRECTORY ${path}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if (git_result EQUAL 0)
string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
"\\2" git_svn_rev "${git_output}")
set(${revision} ${git_svn_rev} PARENT_SCOPE)
string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
"\\2" git_url "${git_output}")
set(${repository} ${git_url} PARENT_SCOPE)
endif()
endif()
endmacro()
macro(get_source_info_git path revision repository)
find_program(git_executable NAMES git git.exe git.cmd)
if (git_executable)
execute_process(COMMAND ${git_executable} log -1 --pretty=format:%H
WORKING_DIRECTORY ${path}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if (git_result EQUAL 0)
set(${revision} ${git_output} PARENT_SCOPE)
endif()
execute_process(COMMAND ${git_executable} remote -v
WORKING_DIRECTORY ${path}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output)
if (git_result EQUAL 0)
string(REGEX REPLACE "^(.*\n)?[^ \t]+[ \t]+([^ \t\n]+)[ \t]+\\(fetch\\).*"
"\\2" git_url "${git_output}")
set(${repository} "${git_url}" PARENT_SCOPE)
endif()
endif()
endmacro()
function(get_source_info path revision repository)
if (EXISTS "${path}/.svn")
get_source_info_svn("${path}" revision repository)
elseif (EXISTS "${path}/.git/svn")
get_source_info_git_svn("${path}" revision repository)
elseif (EXISTS "${path}/.git")
get_source_info_git("${path}" revision repository)
endif()
endfunction()
function(append_info name path)
get_source_info("${path}" revision repository)
string(STRIP "${revision}" revision)
string(STRIP "${repository}" repository)
file(APPEND "${HEADER_FILE}.txt"
"#define ${name}_REVISION \"${revision}\"\n")
file(APPEND "${HEADER_FILE}.txt"
"#define ${name}_REPOSITORY \"${repository}\"\n")
endfunction()
append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
if(DEFINED SECOND_SOURCE_DIR)
append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
endif()
# Copy the file only if it has changed.
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${HEADER_FILE}.txt" "${HEADER_FILE}")
file(REMOVE "${HEADER_FILE}.txt")
# This CMake module is responsible for interpreting the user defined LLVM_
# options and executing the appropriate CMake commands to realize the users'
# selections.
# This is commonly needed so make sure it's defined before we include anything
# else.
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "Host GCC version must be at least 4.7!")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
endif()
set(CLANG_CL 1)
elseif(NOT LLVM_ENABLE_LIBCXX)
# Otherwise, test that we aren't using too old of a version of libstdc++
# with the Clang compiler. This is tricky as there is no real way to
# check the version of libstdc++ directly. Instead we test for a known
# bug in libstdc++4.6 that is fixed in libstdc++4.7.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
check_cxx_source_compiles("
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }"
LLVM_NO_OLD_LIBSTDCXX)
if(NOT LLVM_NO_OLD_LIBSTDCXX)
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Host Visual Studio must be at least 2013")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.31101)
message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
" due to miscompiles from earlier versions")
endif()
endif()
endif()
if( LLVM_ENABLE_ASSERTIONS )
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if( NOT MSVC )
add_definitions( -D_DEBUG )
endif()
# On non-Debug builds cmake automatically defines NDEBUG, so we
# explicitly undefine it:
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions( -UNDEBUG )
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
foreach (flags_var_to_scrub
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL)
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach()
endif()
endif()
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
if( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "WITH_ASSERTS" )
if( LLVM_ENABLE_ASSERTIONS )
set( LLVM_ENABLE_ABI_BREAKING_CHECKS 1 )
endif()
elseif( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "FORCE_ON" )
set( LLVM_ENABLE_ABI_BREAKING_CHECKS 1 )
elseif( uppercase_LLVM_ABI_BREAKING_CHECKS STREQUAL "FORCE_OFF" )
# We don't need to do anything special to turn off ABI breaking checks.
elseif( NOT DEFINED LLVM_ABI_BREAKING_CHECKS )
# Treat LLVM_ABI_BREAKING_CHECKS like "FORCE_OFF" when it has not been
# defined.
else()
message(FATAL_ERROR "Unknown value for LLVM_ABI_BREAKING_CHECKS: \"${LLVM_ABI_BREAKING_CHECKS}\"!")
endif()
if(WIN32)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
else(CYGWIN)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
else(WIN32)
if(UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else(APPLE)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif(APPLE)
else(UNIX)
MESSAGE(SEND_ERROR "Unable to determine platform")
endif(UNIX)
endif(WIN32)
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
# We use *.dylib rather than *.so on darwin.
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
if(APPLE)
# Darwin-specific linker flags for loadable modules.
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
endif()
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endfunction()
function(append_if condition value)
if (${condition})
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endif()
endfunction()
macro(add_flag_if_supported flag name)
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS)
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
endmacro()
function(add_flag_or_print_warning flag name)
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
if (C_SUPPORTS_${name} AND CXX_SUPPORTS_${name})
message(STATUS "Building with ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${flag}" PARENT_SCOPE)
else()
message(WARNING "${flag} is not supported.")
endif()
endfunction()
if( LLVM_ENABLE_PIC )
if( XCODE )
# Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
# know how to disable this, so just force ENABLE_PIC off for now.
message(WARNING "-fPIC not supported with Xcode.")
elseif( WIN32 OR CYGWIN)
# On Windows all code is PIC. MinGW warns if -fPIC is used.
else()
add_flag_or_print_warning("-fPIC" FPIC)
endif()
endif()
if(NOT WIN32 AND NOT CYGWIN)
# MinGW warns if -fvisibility-inlines-hidden is used.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
endif()
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
# TODO: support other platforms and toolchains.
if( LLVM_BUILD_32_BITS )
message(STATUS "Building 32 bits executables and libraries.")
add_llvm_definitions( -m32 )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")
endif( LLVM_BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
if (LLVM_BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
if( XCODE )
# For Xcode enable several build settings that correspond to
# many warnings that are on by default in Clang but are
# not enabled for historical reasons. For versions of Xcode
# that do not support these options they will simply
# be ignored.
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES")
endif()
# On Win32 using MS tools, provide an option to set the number of parallel jobs
# to use.
if( MSVC_IDE )
set(LLVM_COMPILER_JOBS "0" CACHE STRING
"Number of parallel compiler jobs. 0 means use all processors. Default is 0.")
if( NOT LLVM_COMPILER_JOBS STREQUAL "1" )
if( LLVM_COMPILER_JOBS STREQUAL "0" )
add_llvm_definitions( /MP )
else()
message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS})
add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} )
endif()
else()
message(STATUS "Parallel compilation disabled")
endif()
endif()
if( MSVC )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0 )
# For MSVC 2013, disable iterator null pointer checking in debug mode,
# especially so std::equal(nullptr, nullptr, nullptr) will not assert.
add_llvm_definitions("-D_DEBUG_POINTER_IMPL=")
endif()
include(ChooseMSVCCRT)
if( NOT (${CMAKE_VERSION} VERSION_LESS 2.8.11) )
# set stack reserved size to ~10MB
# CMake previously automatically set this value for MSVC builds, but the
# behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
# value (1 MB) which is not enough for us in tasks such as parsing recursive
# C++ templates in Clang.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
endif()
if( MSVC11 )
add_llvm_definitions(-D_VARIADIC_MAX=10)
endif()
# Add definitions that make MSVC much less annoying.
add_llvm_definitions(
# For some reason MS wants to deprecate a bunch of standard functions...
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS
-D_SCL_SECURE_NO_DEPRECATE
-D_SCL_SECURE_NO_WARNINGS
)
set(msvc_warning_flags
# Disabled warnings.
-wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
-wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
-wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used'
-wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
-wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
-wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
-wd4355 # Suppress ''this' : used in base member initializer list'
-wd4456 # Suppress 'declaration of 'var' hides local variable'
-wd4457 # Suppress 'declaration of 'var' hides function parameter'
-wd4458 # Suppress 'declaration of 'var' hides class member'
-wd4459 # Suppress 'declaration of 'var' hides global declaration'
-wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
-wd4722 # Suppress 'function' : destructor never returns, potential memory leak
-wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
-wd4100 # Suppress 'unreferenced formal parameter'
-wd4127 # Suppress 'conditional expression is constant'
-wd4512 # Suppress 'assignment operator could not be generated'
-wd4505 # Suppress 'unreferenced local function has been removed'
-wd4610 # Suppress '<class> can never be instantiated'
-wd4510 # Suppress 'default constructor could not be generated'
-wd4702 # Suppress 'unreachable code'
-wd4245 # Suppress 'signed/unsigned mismatch'
-wd4706 # Suppress 'assignment within conditional expression'
-wd4310 # Suppress 'cast truncates constant value'
-wd4701 # Suppress 'potentially uninitialized local variable'
-wd4703 # Suppress 'potentially uninitialized local pointer variable'
-wd4389 # Suppress 'signed/unsigned mismatch'
-wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
-wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
-wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
-wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
-wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
# C4592 is disabled because of false positives in Visual Studio 2015
# Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
-wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
# Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
# support the 'aligned' attribute in the way that clang sources requires (for
# any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
# avoid unwanted alignment warnings.
# When we switch to requiring a version of MSVC that supports the 'alignas'
# specifier (MSVC 2015?) this warning can be re-enabled.
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
# Promoted warnings.
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
# Promoted warnings to errors.
-we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
)
# Enable warnings
if (LLVM_ENABLE_WARNINGS)
# Put /W4 in front of all the -we flags. cl.exe doesn't care, but for
# clang-cl having /W4 after the -we flags will re-enable the warnings
# disabled by -we.
set(msvc_warning_flags "/W4 ${msvc_warning_flags}")
# CMake appends /W3 by default, and having /W3 followed by /W4 will result in
# cl : Command line warning D9025 : overriding '/W3' with '/W4'. Since this is
# a command line warning and not a compiler warning, it cannot be suppressed except
# by fixing the command line.
string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if (LLVM_ENABLE_PEDANTIC)
# No MSVC equivalent available
endif (LLVM_ENABLE_PEDANTIC)
endif (LLVM_ENABLE_WARNINGS)
if (LLVM_ENABLE_WERROR)
append("/WX" msvc_warning_flags)
endif (LLVM_ENABLE_WERROR)
foreach(flag ${msvc_warning_flags})
append("${flag}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endforeach(flag)
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# clang-cl and cl by default produce non-deterministic binaries because
# link.exe /incremental requires a timestamp in the .obj file. clang-cl
# has the flag /Brepro to force deterministic binaries, so pass that when
# LLVM_ENABLE_TIMESTAMPS is turned off.
# This checks CMAKE_CXX_COMPILER_ID in addition to check_cxx_compiler_flag()
# because cl.exe does not emit an error on flags it doesn't understand,
# letting check_cxx_compiler_flag() claim it understands all flags.
check_cxx_compiler_flag("/Brepro" SUPPORTS_BREPRO)
append_if(SUPPORTS_BREPRO "/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (SUPPORTS_BREPRO)
# Check if /INCREMENTAL is passed to the linker and complain that it
# won't work with /Brepro.
string(TOUPPER "${CMAKE_EXE_LINKER_FLAGS}" upper_exe_flags)
string(TOUPPER "${CMAKE_MODULE_LINKER_FLAGS}" upper_module_flags)
string(TOUPPER "${CMAKE_SHARED_LINKER_FLAGS}" upper_shared_flags)
string(FIND "${upper_exe_flags}" "/INCREMENTAL" exe_index)
string(FIND "${upper_module_flags}" "/INCREMENTAL" module_index)
string(FIND "${upper_shared_flags}" "/INCREMENTAL" shared_index)
if (${exe_index} GREATER -1 OR
${module_index} GREATER -1 OR
${shared_index} GREATER -1)
message(FATAL_ERROR "LLVM_ENABLE_TIMESTAMPS not compatible with /INCREMENTAL linking")
endif()
endif()
endif()
# Disable sized deallocation if the flag is supported. MSVC fails to compile
# the operator new overload in User otherwise.
check_c_compiler_flag("/WX /Zc:sizedDealloc-" SUPPORTS_SIZED_DEALLOC)
append_if(SUPPORTS_SIZED_DEALLOC "/Zc:sizedDealloc-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
if (LLVM_ENABLE_WARNINGS)
append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append("-Wcast-qual" CMAKE_CXX_FLAGS)
# Turn off missing field initializer warnings for gcc to avoid noise from
# false positives with empty {}. Turn them on otherwise (they're off by
# default for clang).
check_cxx_compiler_flag("-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
if (CMAKE_COMPILER_IS_GNUCXX)
append("-Wno-missing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif()
append_if(LLVM_ENABLE_PEDANTIC "-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append_if(LLVM_ENABLE_PEDANTIC "-Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
add_flag_if_supported("-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG)
append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
# Check if -Wnon-virtual-dtor warns even though the class is marked final.
# If it does, don't add it. So it won't be added on clang 3.4 and older.
# This also catches cases when -Wnon-virtual-dtor isn't supported by
# the compiler at all. This flag is not activated for gcc since it will
# incorrectly identify a protected non-virtual base when there is a friend
# declaration.
if (NOT CMAKE_COMPILER_IS_GNUCXX)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11 -Werror=non-virtual-dtor")
CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();protected: ~base();};
class derived final : public base { public: ~derived();};
int main() { return 0; }"
CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
append_if(CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR
"-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
endif()
# Enable -Wdelete-non-virtual-dtor if available.
add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
# Check if -Wcomment is OK with an // comment ending with '\' if the next
# line is also a // comment.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment")
CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main() {return 0;}"
C_WCOMMENT_ALLOWS_LINE_WRAP)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP)
append("-Wno-comment" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif (LLVM_ENABLE_WARNINGS)
append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT LLVM_ENABLE_TIMESTAMPS)
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
endif ()
if (LLVM_ENABLE_CXX1Y)
check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
else()
check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
if (CXX_SUPPORTS_CXX11)
if (CYGWIN OR MINGW)
# MinGW and Cygwin are a bit stricter and lack things like
# 'strdup', 'stricmp', etc in c++11 mode.
append("-std=gnu++11" CMAKE_CXX_FLAGS)
else()
append("-std=c++11" CMAKE_CXX_FLAGS)
endif()
else()
message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
endif()
endif()
if (LLVM_ENABLE_MODULES)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules")
# Check that we can build code with modules enabled, and that repeatedly
# including <cassert> still manages to respect NDEBUG properly.
CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
#include <cassert>
#define NDEBUG
#include <cassert>
int main() { assert(this code is not compiled); }"
CXX_SUPPORTS_MODULES)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
if (CXX_SUPPORTS_MODULES)
append_if(CXX_SUPPORTS_MODULES "-fmodules" CMAKE_C_FLAGS)
append_if(CXX_SUPPORTS_MODULES "-fmodules -fcxx-modules" CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
endif()
endif(LLVM_ENABLE_MODULES)
endif( MSVC )
macro(append_common_sanitizer_flags)
if (NOT MSVC)
# Append -fno-omit-frame-pointer and turn on debug info to get better
# stack traces.
add_flag_if_supported("-fno-omit-frame-pointer" FNO_OMIT_FRAME_POINTER)
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
add_flag_if_supported("-gline-tables-only" GLINE_TABLES_ONLY)
endif()
# Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_flag_if_supported("-O1" O1)
endif()
elseif (CLANG_CL)
# Keep frame pointers around.
append("/Oy-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (CMAKE_LINKER MATCHES "lld-link.exe")
# Use DWARF debug info with LLD.
append("-gdwarf" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Pass /MANIFEST:NO so that CMake doesn't run mt.exe on our binaries.
# Adding manifests with mt.exe breaks LLD's symbol tables. See PR24476.
append("/MANIFEST:NO"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
else()
# Enable codeview otherwise.
append("/Z7" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# Always ask the linker to produce symbols with asan.
append("-debug" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
endmacro()
# Turn on sanitizers if necessary.
if(LLVM_USE_SANITIZER)
if (LLVM_ON_UNIX)
if (LLVM_USE_SANITIZER STREQUAL "Address")
append_common_sanitizer_flags()
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
append_common_sanitizer_flags()
append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
append_common_sanitizer_flags()
append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
append_common_sanitizer_flags()
append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
append_common_sanitizer_flags()
append("-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
elseif(MSVC)
if (LLVM_USE_SANITIZER STREQUAL "Address")
append_common_sanitizer_flags()
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${LLVM_USE_SANITIZER}")
endif()
else()
message(FATAL_ERROR "LLVM_USE_SANITIZER is not supported on this platform.")
endif()
if (LLVM_USE_SANITIZE_COVERAGE)
append("-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif()
# Turn on -gsplit-dwarf if requested
if(LLVM_USE_SPLIT_DWARF)
add_definitions("-gsplit-dwarf")
endif()
add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
add_llvm_definitions( -D__STDC_FORMAT_MACROS )
add_llvm_definitions( -D__STDC_LIMIT_MACROS )
# clang doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_GENERATOR STREQUAL "Ninja")
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# Add flags for add_dead_strip().
# FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
# But MinSizeRel seems to add that automatically, so maybe disable these
# flags instead if LLVM_NO_DEAD_STRIP is set.
if(NOT CYGWIN AND NOT WIN32)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
# Don't add -ffunction-section if it can be disabled with -fno-function-sections.
# Doing so will break sanitizers.
add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS)
endif()
add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
endif()
endif()
if(CYGWIN OR MINGW)
# Prune --out-implib from executables. It doesn't make sense even
# with --export-all-symbols.
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
endif()
if(MSVC)
# Remove flags here, for exceptions and RTTI.
# Each target property or source property should be responsible to control
# them.
# CL.EXE complains to override flags like "/GR /GR-".
string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# Provide public options to globally control RTTI and EH
option(LLVM_ENABLE_EH "Enable Exception handling" OFF)
option(LLVM_ENABLE_RTTI "Enable run time type information" OFF)
if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)
message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
endif()
option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation (experimental)" Off)
mark_as_advanced(LLVM_BUILD_INSTRUMENTED)
append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate"
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
# Plugin support
# FIXME: Make this configurable.
if(WIN32 OR CYGWIN)
if(BUILD_SHARED_LIBS)
set(LLVM_ENABLE_PLUGINS ON)
else()
set(LLVM_ENABLE_PLUGINS OFF)
endif()
else()
set(LLVM_ENABLE_PLUGINS ON)
endif()
# This CMake module is responsible for setting the standard library to libc++
# if the user has requested it.
include(DetermineGCCCompatible)
if(NOT DEFINED LLVM_STDLIB_HANDLED)
set(LLVM_STDLIB_HANDLED ON)
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endfunction()
include(CheckCXXCompilerFlag)
if(LLVM_ENABLE_LIBCXX)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
if(CXX_SUPPORTS_STDLIB)
append("-stdlib=libc++"
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS)
if(LLVM_ENABLE_LIBCXXABI)
append("-lc++abi"
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS)
endif()
else()
message(WARNING "Can't specify libc++ with '-stdlib='")
endif()
else()
message(WARNING "Not sure how to specify libc++ for this compiler")
endif()
endif()
endif()
function(get_system_libs return_var)
message(AUTHOR_WARNING "get_system_libs no longer needed")
set(${return_var} "" PARENT_SCOPE)
endfunction()
function(link_system_libs target)
message(AUTHOR_WARNING "link_system_libs no longer needed")
endfunction()
function(is_llvm_target_library library return_var)
# Sets variable `return_var' to ON if `library' corresponds to a
# LLVM supported target. To OFF if it doesn't.
set(${return_var} OFF PARENT_SCOPE)
string(TOUPPER "${library}" capitalized_lib)
string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
foreach(t ${targets})
if( capitalized_lib STREQUAL t OR
capitalized_lib STREQUAL "LLVM${t}" OR
capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
capitalized_lib STREQUAL "LLVM${t}INFO" )
set(${return_var} ON PARENT_SCOPE)
break()
endif()
endforeach()
endfunction(is_llvm_target_library)
macro(llvm_config executable)
cmake_parse_arguments(ARG "USE_SHARED" "" "" ${ARGN})
set(link_components ${ARG_UNPARSED_ARGUMENTS})
if(USE_SHARED)
# If USE_SHARED is specified, then we link against libLLVM,
# but also against the component libraries below. This is
# done in case libLLVM does not contain all of the components
# the target requires.
#
# Strip LLVM_DYLIB_COMPONENTS out of link_components.
# To do this, we need special handling for "all", since that
# may imply linking to libraries that are not included in
# libLLVM.
if (DEFINED link_components AND DEFINED LLVM_DYLIB_COMPONENTS)
if("${LLVM_DYLIB_COMPONENTS}" STREQUAL "all")
set(link_components "")
else()
list(REMOVE_ITEM link_components ${LLVM_DYLIB_COMPONENTS})
endif()
endif()
target_link_libraries(${executable} LLVM)
endif()
explicit_llvm_config(${executable} ${link_components})
endmacro(llvm_config)
function(explicit_llvm_config executable)
set( link_components ${ARGN} )
llvm_map_components_to_libnames(LIBRARIES ${link_components})
get_target_property(t ${executable} TYPE)
if("x${t}" STREQUAL "xSTATIC_LIBRARY")
target_link_libraries(${executable} INTERFACE ${LIBRARIES})
elseif("x${t}" STREQUAL "xSHARED_LIBRARY" OR "x${t}" STREQUAL "xMODULE_LIBRARY")
target_link_libraries(${executable} PRIVATE ${LIBRARIES})
else()
# Use plain form for legacy user.
target_link_libraries(${executable} ${LIBRARIES})
endif()
endfunction(explicit_llvm_config)
# This is Deprecated
function(llvm_map_components_to_libraries OUT_VAR)
message(AUTHOR_WARNING "Using llvm_map_components_to_libraries() is deprecated. Use llvm_map_components_to_libnames() instead")
explicit_map_components_to_libraries(result ${ARGN})
set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
endfunction(llvm_map_components_to_libraries)
# This is a variant intended for the final user:
# Map LINK_COMPONENTS to actual libnames.
function(llvm_map_components_to_libnames out_libs)
set( link_components ${ARGN} )
if(NOT LLVM_AVAILABLE_LIBS)
# Inside LLVM itself available libs are in a global property.
get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
endif()
string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
# Expand some keywords:
list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
list(FIND link_components "engine" engine_required)
if( NOT engine_required EQUAL -1 )
list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 )
list(APPEND link_components "jit")
list(APPEND link_components "native")
else()
list(APPEND link_components "interpreter")
endif()
endif()
list(FIND link_components "native" native_required)
if( NOT native_required EQUAL -1 )
if( NOT have_native_backend EQUAL -1 )
list(APPEND link_components ${LLVM_NATIVE_ARCH})
endif()
endif()
# Translate symbolic component names to real libraries:
foreach(c ${link_components})
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
if( TARGET LLVM${c}CodeGen )
list(APPEND expanded_components "LLVM${c}CodeGen")
else()
if( TARGET LLVM${c} )
list(APPEND expanded_components "LLVM${c}")
else()
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
endif()
endif()
if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "LLVM${c}AsmParser")
endif()
if( TARGET LLVM${c}Desc )
list(APPEND expanded_components "LLVM${c}Desc")
endif()
if( TARGET LLVM${c}Info )
list(APPEND expanded_components "LLVM${c}Info")
endif()
if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "LLVM${c}Disassembler")
endif()
elseif( c STREQUAL "native" )
# already processed
elseif( c STREQUAL "nativecodegen" )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen")
if( TARGET LLVM${LLVM_NATIVE_ARCH}Desc )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Desc")
endif()
if( TARGET LLVM${LLVM_NATIVE_ARCH}Info )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Info")
endif()
elseif( c STREQUAL "backend" )
# same case as in `native'.
elseif( c STREQUAL "engine" )
# already processed
elseif( c STREQUAL "all" )
list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
elseif( c STREQUAL "AllTargetsAsmPrinters" )
# Link all the asm printers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmPrinter )
list(APPEND expanded_components "LLVM${t}AsmPrinter")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsAsmParsers" )
# Link all the asm parsers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}AsmParser )
list(APPEND expanded_components "LLVM${t}AsmParser")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDescs" )
# Link all the descs from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Desc )
list(APPEND expanded_components "LLVM${t}Desc")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsDisassemblers" )
# Link all the disassemblers from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Disassembler )
list(APPEND expanded_components "LLVM${t}Disassembler")
endif()
endforeach(t)
elseif( c STREQUAL "AllTargetsInfos" )
# Link all the infos from all the targets
foreach(t ${LLVM_TARGETS_TO_BUILD})
if( TARGET LLVM${t}Info )
list(APPEND expanded_components "LLVM${t}Info")
endif()
endforeach(t)
else( NOT idx LESS 0 )
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
list(FIND capitalized_libs LLVM${capitalized} lib_idx)
if( lib_idx LESS 0 )
# The component is unknown. Maybe is an omitted target?
is_llvm_target_library(${c} iltl_result)
if( NOT iltl_result )
message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
endif()
else( lib_idx LESS 0 )
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
list(APPEND expanded_components ${canonical_lib})
endif( lib_idx LESS 0 )
endif( NOT idx LESS 0 )
endforeach(c)
set(${out_libs} ${expanded_components} PARENT_SCOPE)
endfunction()
# Perform a post-order traversal of the dependency graph.
# This duplicates the algorithm used by llvm-config, originally
# in tools/llvm-config/llvm-config.cpp, function ComputeLibsForComponents.
function(expand_topologically name required_libs visited_libs)
list(FIND visited_libs ${name} found)
if( found LESS 0 )
list(APPEND visited_libs ${name})
set(visited_libs ${visited_libs} PARENT_SCOPE)
get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
foreach( lib_dep ${lib_deps} )
expand_topologically(${lib_dep} "${required_libs}" "${visited_libs}")
set(required_libs ${required_libs} PARENT_SCOPE)
set(visited_libs ${visited_libs} PARENT_SCOPE)
endforeach()
list(APPEND required_libs ${name})
set(required_libs ${required_libs} PARENT_SCOPE)
endif()
endfunction()
# Expand dependencies while topologically sorting the list of libraries:
function(llvm_expand_dependencies out_libs)
set(expanded_components ${ARGN})
set(required_libs)
set(visited_libs)
foreach( lib ${expanded_components} )
expand_topologically(${lib} "${required_libs}" "${visited_libs}")
endforeach()
list(REVERSE required_libs)
set(${out_libs} ${required_libs} PARENT_SCOPE)
endfunction()
function(explicit_map_components_to_libraries out_libs)
llvm_map_components_to_libnames(link_libs ${ARGN})
llvm_expand_dependencies(expanded_components ${link_libs})
# Return just the libraries included in this build:
set(result)
foreach(c ${expanded_components})
if( TARGET ${c} )
set(result ${result} ${c})
endif()
endforeach(c)
set(${out_libs} ${result} PARENT_SCOPE)
endfunction(explicit_map_components_to_libraries)
# This file provides information and services to the final user.
# Compute the CMake directory from the LLVMConfig.cmake file location.
get_filename_component(_LLVM_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# Compute the installation prefix from the LLVMConfig.cmake file location.
get_filename_component(LLVM_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PREFIX}" PATH)
get_filename_component(LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PREFIX}" PATH)
get_filename_component(LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PREFIX}" PATH)
set(_LLVM_LIBRARY_DIR "${LLVM_INSTALL_PREFIX}/lib")
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 8)
set(LLVM_VERSION_PATCH 0)
set(LLVM_PACKAGE_VERSION 3.8.0)
set(LLVM_COMMON_DEPENDS )
set(LLVM_AVAILABLE_LIBS LLVMSupport LLVMAArch64Utils LLVMMC LLVMAArch64AsmPrinter LLVMAArch64Info LLVMAArch64Desc LLVMMCParser LLVMAArch64AsmParser LLVMCore LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMTransformUtils LLVMObject LLVMProfileData LLVMInstrumentation LLVMInstCombine LLVMScalarOpts LLVMTarget LLVMCodeGen LLVMAsmPrinter LLVMSelectionDAG LLVMAArch64CodeGen LLVMMCDisassembler LLVMAArch64Disassembler LLVMAMDGPUAsmPrinter LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMAMDGPUDesc LLVMAMDGPUAsmParser LLVMAsmParser LLVMIRReader LLVMLinker LLVMVectorize LLVMipo LLVMAMDGPUCodeGen LLVMARMAsmPrinter LLVMARMInfo LLVMARMDesc LLVMARMAsmParser LLVMARMCodeGen LLVMARMDisassembler LLVMBPFAsmPrinter LLVMBPFInfo LLVMBPFDesc LLVMBPFCodeGen LLVMCppBackendInfo LLVMCppBackendCodeGen LLVMDebugInfoCodeView LLVMDebugInfoDWARF LLVMDebugInfoPDB LLVMRuntimeDyld LLVMExecutionEngine LLVMMCJIT LLVMHexagonInfo LLVMHexagonDesc LLVMHexagonAsmParser LLVMHexagonCodeGen LLVMHexagonDisassembler LLVMInterpreter LLVMObjCARCOpts LLVMLTO LLVMOption LLVMLibDriver LLVMLineEditor LLVMMIRParser LLVMMSP430AsmPrinter LLVMMSP430Info LLVMMSP430Desc LLVMMSP430CodeGen LLVMMipsAsmPrinter LLVMMipsInfo LLVMMipsDesc LLVMMipsAsmParser LLVMMipsCodeGen LLVMMipsDisassembler LLVMNVPTXAsmPrinter LLVMNVPTXInfo LLVMNVPTXDesc LLVMNVPTXCodeGen LLVMX86Utils LLVMX86AsmPrinter LLVMX86Info LLVMX86Desc LLVMX86CodeGen LLVMOrcJIT LLVMPasses LLVMPowerPCAsmPrinter LLVMPowerPCInfo LLVMPowerPCDesc LLVMPowerPCAsmParser LLVMPowerPCCodeGen LLVMPowerPCDisassembler LLVMSparcAsmPrinter LLVMSparcInfo LLVMSparcDesc LLVMSparcAsmParser LLVMSparcCodeGen LLVMSparcDisassembler LLVMSymbolize LLVMSystemZAsmPrinter LLVMSystemZInfo LLVMSystemZDesc LLVMSystemZAsmParser LLVMSystemZCodeGen LLVMSystemZDisassembler LLVMTableGen LLVMX86AsmParser LLVMX86Disassembler LLVMXCoreAsmPrinter LLVMXCoreInfo LLVMXCoreDesc LLVMXCoreCodeGen LLVMXCoreDisassembler)
set(LLVM_ALL_TARGETS X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ AMDGPU BPF)
set(LLVM_TARGETS_TO_BUILD X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ AMDGPU BPF)
set(LLVM_TARGETS_WITH_JIT ARM AArch64 Mips PowerPC SystemZ X86)
set(TARGET_TRIPLE "x86_64-unknown-linux-gnu")
set(LLVM_ABI_BREAKING_CHECKS FORCE_OFF)
set(LLVM_ENABLE_ASSERTIONS 0)
set(LLVM_ENABLE_EH 0)
set(LLVM_ENABLE_RTTI 0)
set(LLVM_ENABLE_TERMINFO 0)
set(LLVM_ENABLE_THREADS 1)
set(LLVM_ENABLE_ZLIB 0)
set(LLVM_NATIVE_ARCH X86)
set(LLVM_ENABLE_PIC 1)
set(LLVM_ENABLE_PLUGINS @LLVM_ENABLE_PLUGINS@)
set(LLVM_PLUGIN_EXT @LLVM_PLUGIN_EXT@)
set(LLVM_ON_UNIX 1)
set(LLVM_ON_WIN32 0)
set(LLVM_LIBDIR_SUFFIX )
set(LLVM_INCLUDE_DIRS "${LLVM_INSTALL_PREFIX}/include")
set(LLVM_LIBRARY_DIRS "${_LLVM_LIBRARY_DIR}")
set(LLVM_DEFINITIONS "@LLVM_DEFINITIONS@")
set(LLVM_CMAKE_DIR "${_LLVM_CMAKE_DIR}")
set(LLVM_TOOLS_BINARY_DIR "${LLVM_INSTALL_PREFIX}/bin")
if(NOT TARGET LLVMSupport)
include("${LLVM_CMAKE_DIR}/LLVMExports.cmake")
endif()
include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSupport )
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64Utils LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64AsmPrinter LLVMAArch64Utils LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64Info LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64Desc LLVMAArch64AsmPrinter LLVMAArch64Info LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMCParser LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64AsmParser LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMMC LLVMMCParser LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMTransformUtils LLVMAnalysis LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMObject LLVMBitReader LLVMCore LLVMMC LLVMMCParser LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMProfileData LLVMCore LLVMObject LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMInstrumentation LLVMAnalysis LLVMCore LLVMMC LLVMProfileData LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMInstCombine LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMInstCombine LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMTarget LLVMAnalysis LLVMCore LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMCore LLVMInstrumentation LLVMMC LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAsmPrinter LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMMCParser LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64CodeGen LLVMAArch64AsmPrinter LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMCDisassembler LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAArch64Disassembler LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUUtils LLVMCore LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUDesc LLVMAMDGPUAsmPrinter LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUAsmParser LLVMAMDGPUDesc LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMMC LLVMMCParser LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAsmParser LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMIRReader LLVMAsmParser LLVMBitReader LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMLinker LLVMCore LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMVectorize LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMIRReader LLVMInstCombine LLVMLinker LLVMObject LLVMProfileData LLVMScalarOpts LLVMSupport LLVMTransformUtils LLVMVectorize)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAMDGPUCodeGen LLVMAMDGPUAsmParser LLVMAMDGPUAsmPrinter LLVMAMDGPUDesc LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils LLVMipo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMDesc LLVMARMAsmPrinter LLVMARMInfo LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMAsmParser LLVMARMDesc LLVMARMInfo LLVMMC LLVMMCParser LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMCodeGen LLVMARMAsmPrinter LLVMARMDesc LLVMARMInfo LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMARMDisassembler LLVMARMDesc LLVMARMInfo LLVMMCDisassembler LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAVRInfo LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMAVRCodeGen LLVMAVRInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBPFAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBPFInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBPFDesc LLVMBPFAsmPrinter LLVMBPFInfo LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMBPFCodeGen LLVMAsmPrinter LLVMBPFAsmPrinter LLVMBPFDesc LLVMBPFInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMCppBackendInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMCppBackendCodeGen LLVMCore LLVMCppBackendInfo LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMDebugInfoCodeView LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMDebugInfoDWARF LLVMObject LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMDebugInfoPDB LLVMObject LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMRuntimeDyld LLVMMC LLVMObject LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMExecutionEngine LLVMCore LLVMMC LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMCJIT LLVMCore LLVMExecutionEngine LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMHexagonInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMHexagonAsmParser LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMMCParser LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMHexagonCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMHexagonAsmParser LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMHexagonDisassembler LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMInterpreter LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMObjCARCOpts LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMLTO LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMCodeGen LLVMCore LLVMInstCombine LLVMLinker LLVMMC LLVMObjCARCOpts LLVMObject LLVMScalarOpts LLVMSupport LLVMTarget LLVMipo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMOption LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMLibDriver LLVMObject LLVMOption LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMLineEditor LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMIRParser LLVMAsmParser LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMSP430AsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMSP430Info LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMSP430Desc LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Info LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMSP430CodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Desc LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsDesc LLVMMC LLVMMipsAsmPrinter LLVMMipsInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsAsmParser LLVMMC LLVMMCParser LLVMMipsDesc LLVMMipsInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsAsmPrinter LLVMMipsDesc LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMMipsDisassembler LLVMMCDisassembler LLVMMipsInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMNVPTXAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMNVPTXInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMNVPTXDesc LLVMMC LLVMNVPTXAsmPrinter LLVMNVPTXInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMNVPTXCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMNVPTXAsmPrinter LLVMNVPTXDesc LLVMNVPTXInfo LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86Utils LLVMCore LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86AsmPrinter LLVMMC LLVMSupport LLVMX86Utils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86Info LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86Desc LLVMMC LLVMMCDisassembler LLVMObject LLVMSupport LLVMX86AsmPrinter LLVMX86Info)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86CodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMX86AsmPrinter LLVMX86Desc LLVMX86Info LLVMX86Utils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMOrcJIT LLVMCore LLVMExecutionEngine LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPasses LLVMAnalysis LLVMCore LLVMInstCombine LLVMScalarOpts LLVMSupport LLVMTransformUtils LLVMVectorize LLVMipo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCDesc LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCAsmParser LLVMMC LLVMMCParser LLVMPowerPCDesc LLVMPowerPCInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCDesc LLVMPowerPCInfo LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMPowerPCDisassembler LLVMMCDisassembler LLVMPowerPCInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcDesc LLVMMC LLVMSparcAsmPrinter LLVMSparcInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcAsmParser LLVMMC LLVMMCParser LLVMSparcDesc LLVMSparcInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcAsmPrinter LLVMSparcDesc LLVMSparcInfo LLVMSupport LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSparcDisassembler LLVMMCDisassembler LLVMSparcInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSymbolize LLVMDebugInfoDWARF LLVMDebugInfoPDB LLVMObject LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZDesc LLVMMC LLVMSupport LLVMSystemZAsmPrinter LLVMSystemZInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZAsmParser LLVMMC LLVMMCParser LLVMSupport LLVMSystemZDesc LLVMSystemZInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystemZAsmPrinter LLVMSystemZDesc LLVMSystemZInfo LLVMTarget)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMSystemZDisassembler LLVMMC LLVMMCDisassembler LLVMSupport LLVMSystemZDesc LLVMSystemZInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMTableGen LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMWebAssemblyAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMWebAssemblyInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMWebAssemblyDesc LLVMMC LLVMSupport LLVMWebAssemblyAsmPrinter LLVMWebAssemblyInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMWebAssemblyCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMWebAssemblyAsmPrinter LLVMWebAssemblyDesc LLVMWebAssemblyInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMWebAssemblyDisassembler LLVMMCDisassembler LLVMSupport LLVMWebAssemblyInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86AsmParser LLVMMC LLVMMCParser LLVMSupport LLVMX86Desc LLVMX86Info)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMX86Disassembler LLVMMCDisassembler LLVMSupport LLVMX86Info)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMXCoreAsmPrinter LLVMMC LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMXCoreInfo LLVMSupport)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMXCoreDesc LLVMMC LLVMSupport LLVMXCoreAsmPrinter LLVMXCoreInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMXCoreCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils LLVMXCoreAsmPrinter LLVMXCoreDesc LLVMXCoreInfo)
set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_LLVMXCoreDisassembler LLVMMCDisassembler LLVMSupport LLVMXCoreInfo)
unset(_LLVM_CMAKE_DIR)
unset(_LLVM_LIBRARY_DIR)
set(PACKAGE_VERSION "3.8.0")
# LLVM is API-compatible only with matching major.minor versions
# and patch versions not less than that requested.
if("3.8" VERSION_EQUAL
"${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}"
AND NOT "0" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_COMPATIBLE 1)
if("0" VERSION_EQUAL
"${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_EXACT 1)
endif()
endif()
# LLVM CMake target exports. Do not include directly.
add_library(LLVMSupport STATIC IMPORTED)
set_property(TARGET LLVMSupport PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSupport.a")
add_library(LLVMAArch64Utils STATIC IMPORTED)
set_property(TARGET LLVMAArch64Utils PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64Utils.a")
add_library(LLVMMC STATIC IMPORTED)
set_property(TARGET LLVMMC PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMC.a")
add_library(LLVMAArch64AsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMAArch64AsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64AsmPrinter.a")
add_library(LLVMAArch64Info STATIC IMPORTED)
set_property(TARGET LLVMAArch64Info PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64Info.a")
add_library(LLVMAArch64Desc STATIC IMPORTED)
set_property(TARGET LLVMAArch64Desc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64Desc.a")
add_library(LLVMMCParser STATIC IMPORTED)
set_property(TARGET LLVMMCParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMCParser.a")
add_library(LLVMAArch64AsmParser STATIC IMPORTED)
set_property(TARGET LLVMAArch64AsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64AsmParser.a")
add_library(LLVMCore STATIC IMPORTED)
set_property(TARGET LLVMCore PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMCore.a")
add_library(LLVMAnalysis STATIC IMPORTED)
set_property(TARGET LLVMAnalysis PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAnalysis.a")
add_library(LLVMBitReader STATIC IMPORTED)
set_property(TARGET LLVMBitReader PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBitReader.a")
add_library(LLVMBitWriter STATIC IMPORTED)
set_property(TARGET LLVMBitWriter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBitWriter.a")
add_library(LLVMTransformUtils STATIC IMPORTED)
set_property(TARGET LLVMTransformUtils PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMTransformUtils.a")
add_library(LLVMObject STATIC IMPORTED)
set_property(TARGET LLVMObject PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMObject.a")
add_library(LLVMProfileData STATIC IMPORTED)
set_property(TARGET LLVMProfileData PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMProfileData.a")
add_library(LLVMInstrumentation STATIC IMPORTED)
set_property(TARGET LLVMInstrumentation PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMInstrumentation.a")
add_library(LLVMInstCombine STATIC IMPORTED)
set_property(TARGET LLVMInstCombine PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMInstCombine.a")
add_library(LLVMScalarOpts STATIC IMPORTED)
set_property(TARGET LLVMScalarOpts PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMScalarOpts.a")
add_library(LLVMTarget STATIC IMPORTED)
set_property(TARGET LLVMTarget PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMTarget.a")
add_library(LLVMCodeGen STATIC IMPORTED)
set_property(TARGET LLVMCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMCodeGen.a")
add_library(LLVMAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAsmPrinter.a")
add_library(LLVMSelectionDAG STATIC IMPORTED)
set_property(TARGET LLVMSelectionDAG PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSelectionDAG.a")
add_library(LLVMAArch64CodeGen STATIC IMPORTED)
set_property(TARGET LLVMAArch64CodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64CodeGen.a")
add_library(LLVMMCDisassembler STATIC IMPORTED)
set_property(TARGET LLVMMCDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMCDisassembler.a")
add_library(LLVMAArch64Disassembler STATIC IMPORTED)
set_property(TARGET LLVMAArch64Disassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAArch64Disassembler.a")
add_library(LLVMAMDGPUAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUAsmPrinter.a")
add_library(LLVMAMDGPUInfo STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUInfo.a")
add_library(LLVMAMDGPUUtils STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUUtils PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUUtils.a")
add_library(LLVMAMDGPUDesc STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUDesc.a")
add_library(LLVMAMDGPUAsmParser STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUAsmParser.a")
add_library(LLVMAsmParser STATIC IMPORTED)
set_property(TARGET LLVMAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAsmParser.a")
add_library(LLVMIRReader STATIC IMPORTED)
set_property(TARGET LLVMIRReader PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMIRReader.a")
add_library(LLVMLinker STATIC IMPORTED)
set_property(TARGET LLVMLinker PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMLinker.a")
add_library(LLVMVectorize STATIC IMPORTED)
set_property(TARGET LLVMVectorize PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMVectorize.a")
add_library(LLVMipo STATIC IMPORTED)
set_property(TARGET LLVMipo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMipo.a")
add_library(LLVMAMDGPUCodeGen STATIC IMPORTED)
set_property(TARGET LLVMAMDGPUCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMAMDGPUCodeGen.a")
add_library(LLVMARMAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMARMAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMAsmPrinter.a")
add_library(LLVMARMInfo STATIC IMPORTED)
set_property(TARGET LLVMARMInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMInfo.a")
add_library(LLVMARMDesc STATIC IMPORTED)
set_property(TARGET LLVMARMDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMDesc.a")
add_library(LLVMARMAsmParser STATIC IMPORTED)
set_property(TARGET LLVMARMAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMAsmParser.a")
add_library(LLVMARMCodeGen STATIC IMPORTED)
set_property(TARGET LLVMARMCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMCodeGen.a")
add_library(LLVMARMDisassembler STATIC IMPORTED)
set_property(TARGET LLVMARMDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMARMDisassembler.a")
add_library(LLVMBPFAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMBPFAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBPFAsmPrinter.a")
add_library(LLVMBPFInfo STATIC IMPORTED)
set_property(TARGET LLVMBPFInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBPFInfo.a")
add_library(LLVMBPFDesc STATIC IMPORTED)
set_property(TARGET LLVMBPFDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBPFDesc.a")
add_library(LLVMBPFCodeGen STATIC IMPORTED)
set_property(TARGET LLVMBPFCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMBPFCodeGen.a")
add_library(LLVMCppBackendInfo STATIC IMPORTED)
set_property(TARGET LLVMCppBackendInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMCppBackendInfo.a")
add_library(LLVMCppBackendCodeGen STATIC IMPORTED)
set_property(TARGET LLVMCppBackendCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMCppBackendCodeGen.a")
add_library(LLVMDebugInfoCodeView STATIC IMPORTED)
set_property(TARGET LLVMDebugInfoCodeView PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMDebugInfoCodeView.a")
add_library(LLVMDebugInfoDWARF STATIC IMPORTED)
set_property(TARGET LLVMDebugInfoDWARF PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMDebugInfoDWARF.a")
add_library(LLVMDebugInfoPDB STATIC IMPORTED)
set_property(TARGET LLVMDebugInfoPDB PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMDebugInfoPDB.a")
add_library(LLVMRuntimeDyld STATIC IMPORTED)
set_property(TARGET LLVMRuntimeDyld PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMRuntimeDyld.a")
add_library(LLVMExecutionEngine STATIC IMPORTED)
set_property(TARGET LLVMExecutionEngine PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMExecutionEngine.a")
add_library(LLVMMCJIT STATIC IMPORTED)
set_property(TARGET LLVMMCJIT PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMCJIT.a")
add_library(LLVMHexagonInfo STATIC IMPORTED)
set_property(TARGET LLVMHexagonInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMHexagonInfo.a")
add_library(LLVMHexagonDesc STATIC IMPORTED)
set_property(TARGET LLVMHexagonDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMHexagonDesc.a")
add_library(LLVMHexagonAsmParser STATIC IMPORTED)
set_property(TARGET LLVMHexagonAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMHexagonAsmParser.a")
add_library(LLVMHexagonCodeGen STATIC IMPORTED)
set_property(TARGET LLVMHexagonCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMHexagonCodeGen.a")
add_library(LLVMHexagonDisassembler STATIC IMPORTED)
set_property(TARGET LLVMHexagonDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMHexagonDisassembler.a")
add_library(LLVMInterpreter STATIC IMPORTED)
set_property(TARGET LLVMInterpreter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMInterpreter.a")
add_library(LLVMObjCARCOpts STATIC IMPORTED)
set_property(TARGET LLVMObjCARCOpts PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMObjCARCOpts.a")
add_library(LLVMLTO STATIC IMPORTED)
set_property(TARGET LLVMLTO PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMLTO.a")
add_library(LLVMOption STATIC IMPORTED)
set_property(TARGET LLVMOption PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMOption.a")
add_library(LLVMLibDriver STATIC IMPORTED)
set_property(TARGET LLVMLibDriver PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMLibDriver.a")
add_library(LLVMLineEditor STATIC IMPORTED)
set_property(TARGET LLVMLineEditor PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMLineEditor.a")
add_library(LLVMMIRParser STATIC IMPORTED)
set_property(TARGET LLVMMIRParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMIRParser.a")
add_library(LLVMMSP430AsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMMSP430AsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMSP430AsmPrinter.a")
add_library(LLVMMSP430Info STATIC IMPORTED)
set_property(TARGET LLVMMSP430Info PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMSP430Info.a")
add_library(LLVMMSP430Desc STATIC IMPORTED)
set_property(TARGET LLVMMSP430Desc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMSP430Desc.a")
add_library(LLVMMSP430CodeGen STATIC IMPORTED)
set_property(TARGET LLVMMSP430CodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMSP430CodeGen.a")
add_library(LLVMMipsAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMMipsAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsAsmPrinter.a")
add_library(LLVMMipsInfo STATIC IMPORTED)
set_property(TARGET LLVMMipsInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsInfo.a")
add_library(LLVMMipsDesc STATIC IMPORTED)
set_property(TARGET LLVMMipsDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsDesc.a")
add_library(LLVMMipsAsmParser STATIC IMPORTED)
set_property(TARGET LLVMMipsAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsAsmParser.a")
add_library(LLVMMipsCodeGen STATIC IMPORTED)
set_property(TARGET LLVMMipsCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsCodeGen.a")
add_library(LLVMMipsDisassembler STATIC IMPORTED)
set_property(TARGET LLVMMipsDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMMipsDisassembler.a")
add_library(LLVMNVPTXAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMNVPTXAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMNVPTXAsmPrinter.a")
add_library(LLVMNVPTXInfo STATIC IMPORTED)
set_property(TARGET LLVMNVPTXInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMNVPTXInfo.a")
add_library(LLVMNVPTXDesc STATIC IMPORTED)
set_property(TARGET LLVMNVPTXDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMNVPTXDesc.a")
add_library(LLVMNVPTXCodeGen STATIC IMPORTED)
set_property(TARGET LLVMNVPTXCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMNVPTXCodeGen.a")
add_library(LLVMX86Utils STATIC IMPORTED)
set_property(TARGET LLVMX86Utils PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86Utils.a")
add_library(LLVMX86AsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMX86AsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86AsmPrinter.a")
add_library(LLVMX86Info STATIC IMPORTED)
set_property(TARGET LLVMX86Info PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86Info.a")
add_library(LLVMX86Desc STATIC IMPORTED)
set_property(TARGET LLVMX86Desc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86Desc.a")
add_library(LLVMX86CodeGen STATIC IMPORTED)
set_property(TARGET LLVMX86CodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86CodeGen.a")
add_library(LLVMOrcJIT STATIC IMPORTED)
set_property(TARGET LLVMOrcJIT PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMOrcJIT.a")
add_library(LLVMPasses STATIC IMPORTED)
set_property(TARGET LLVMPasses PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPasses.a")
add_library(LLVMPowerPCAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMPowerPCAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCAsmPrinter.a")
add_library(LLVMPowerPCInfo STATIC IMPORTED)
set_property(TARGET LLVMPowerPCInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCInfo.a")
add_library(LLVMPowerPCDesc STATIC IMPORTED)
set_property(TARGET LLVMPowerPCDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCDesc.a")
add_library(LLVMPowerPCAsmParser STATIC IMPORTED)
set_property(TARGET LLVMPowerPCAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCAsmParser.a")
add_library(LLVMPowerPCCodeGen STATIC IMPORTED)
set_property(TARGET LLVMPowerPCCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCCodeGen.a")
add_library(LLVMPowerPCDisassembler STATIC IMPORTED)
set_property(TARGET LLVMPowerPCDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMPowerPCDisassembler.a")
add_library(LLVMSparcAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMSparcAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcAsmPrinter.a")
add_library(LLVMSparcInfo STATIC IMPORTED)
set_property(TARGET LLVMSparcInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcInfo.a")
add_library(LLVMSparcDesc STATIC IMPORTED)
set_property(TARGET LLVMSparcDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcDesc.a")
add_library(LLVMSparcAsmParser STATIC IMPORTED)
set_property(TARGET LLVMSparcAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcAsmParser.a")
add_library(LLVMSparcCodeGen STATIC IMPORTED)
set_property(TARGET LLVMSparcCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcCodeGen.a")
add_library(LLVMSparcDisassembler STATIC IMPORTED)
set_property(TARGET LLVMSparcDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSparcDisassembler.a")
add_library(LLVMSymbolize STATIC IMPORTED)
set_property(TARGET LLVMSymbolize PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSymbolize.a")
add_library(LLVMSystemZAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMSystemZAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZAsmPrinter.a")
add_library(LLVMSystemZInfo STATIC IMPORTED)
set_property(TARGET LLVMSystemZInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZInfo.a")
add_library(LLVMSystemZDesc STATIC IMPORTED)
set_property(TARGET LLVMSystemZDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZDesc.a")
add_library(LLVMSystemZAsmParser STATIC IMPORTED)
set_property(TARGET LLVMSystemZAsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZAsmParser.a")
add_library(LLVMSystemZCodeGen STATIC IMPORTED)
set_property(TARGET LLVMSystemZCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZCodeGen.a")
add_library(LLVMSystemZDisassembler STATIC IMPORTED)
set_property(TARGET LLVMSystemZDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMSystemZDisassembler.a")
add_library(LLVMTableGen STATIC IMPORTED)
set_property(TARGET LLVMTableGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMTableGen.a")
add_library(LLVMX86AsmParser STATIC IMPORTED)
set_property(TARGET LLVMX86AsmParser PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86AsmParser.a")
add_library(LLVMX86Disassembler STATIC IMPORTED)
set_property(TARGET LLVMX86Disassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMX86Disassembler.a")
add_library(LLVMXCoreAsmPrinter STATIC IMPORTED)
set_property(TARGET LLVMXCoreAsmPrinter PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMXCoreAsmPrinter.a")
add_library(LLVMXCoreInfo STATIC IMPORTED)
set_property(TARGET LLVMXCoreInfo PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMXCoreInfo.a")
add_library(LLVMXCoreDesc STATIC IMPORTED)
set_property(TARGET LLVMXCoreDesc PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMXCoreDesc.a")
add_library(LLVMXCoreCodeGen STATIC IMPORTED)
set_property(TARGET LLVMXCoreCodeGen PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMXCoreCodeGen.a")
add_library(LLVMXCoreDisassembler STATIC IMPORTED)
set_property(TARGET LLVMXCoreDisassembler PROPERTY IMPORTED_LOCATION "${_LLVM_LIBRARY_DIR}/libLLVMXCoreDisassembler.a")
# Explicit library dependency information.
#
# The following property assignments tell CMake about link
# dependencies of libraries imported from LLVM.
set_property(TARGET LLVMSupport PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES )
set_property(TARGET LLVMAArch64Utils PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMMC PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMAArch64AsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAArch64Utils LLVMMC LLVMSupport)
set_property(TARGET LLVMAArch64Info PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMAArch64Desc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAArch64AsmPrinter LLVMAArch64Info LLVMMC LLVMSupport)
set_property(TARGET LLVMMCParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMAArch64AsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMMC LLVMMCParser LLVMSupport)
set_property(TARGET LLVMCore PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMAnalysis PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport)
set_property(TARGET LLVMBitReader PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport)
set_property(TARGET LLVMBitWriter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport)
set_property(TARGET LLVMTransformUtils PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMSupport)
set_property(TARGET LLVMObject PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMBitReader LLVMCore LLVMMC LLVMMCParser LLVMSupport)
set_property(TARGET LLVMProfileData PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMObject LLVMSupport)
set_property(TARGET LLVMInstrumentation PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMMC LLVMProfileData LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMInstCombine PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMScalarOpts PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMInstCombine LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMTarget PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMMC LLVMSupport)
set_property(TARGET LLVMCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMCore LLVMInstrumentation LLVMMC LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMMCParser LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMSelectionDAG PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMAArch64CodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAArch64AsmPrinter LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(TARGET LLVMMCDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMAArch64Disassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAArch64Desc LLVMAArch64Info LLVMAArch64Utils LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(TARGET LLVMAMDGPUAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMAMDGPUInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMAMDGPUUtils PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMMC LLVMSupport)
set_property(TARGET LLVMAMDGPUDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAMDGPUAsmPrinter LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMMC LLVMSupport)
set_property(TARGET LLVMAMDGPUAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAMDGPUDesc LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMMC LLVMMCParser LLVMSupport)
set_property(TARGET LLVMAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport)
set_property(TARGET LLVMIRReader PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAsmParser LLVMBitReader LLVMCore LLVMSupport)
set_property(TARGET LLVMLinker PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMVectorize PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMipo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMIRReader LLVMInstCombine LLVMLinker LLVMObject LLVMProfileData LLVMScalarOpts LLVMSupport LLVMTransformUtils LLVMVectorize)
set_property(TARGET LLVMAMDGPUCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAMDGPUAsmParser LLVMAMDGPUAsmPrinter LLVMAMDGPUDesc LLVMAMDGPUInfo LLVMAMDGPUUtils LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils LLVMipo)
set_property(TARGET LLVMARMAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMARMInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMARMDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMARMAsmPrinter LLVMARMInfo LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(TARGET LLVMARMAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMARMDesc LLVMARMInfo LLVMMC LLVMMCParser LLVMSupport)
set_property(TARGET LLVMARMCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMARMAsmPrinter LLVMARMDesc LLVMARMInfo LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(TARGET LLVMARMDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMARMDesc LLVMARMInfo LLVMMCDisassembler LLVMSupport)
set_property(TARGET LLVMBPFAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMBPFInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMBPFDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMBPFAsmPrinter LLVMBPFInfo LLVMMC LLVMSupport)
set_property(TARGET LLVMBPFCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAsmPrinter LLVMBPFAsmPrinter LLVMBPFDesc LLVMBPFInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(TARGET LLVMCppBackendInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMCppBackendCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMCppBackendInfo LLVMSupport LLVMTarget)
set_property(TARGET LLVMDebugInfoCodeView PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMDebugInfoDWARF PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMObject LLVMSupport)
set_property(TARGET LLVMDebugInfoPDB PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMObject LLVMSupport)
set_property(TARGET LLVMRuntimeDyld PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMObject LLVMSupport)
set_property(TARGET LLVMExecutionEngine PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMMC LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTarget)
set_property(TARGET LLVMMCJIT PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMExecutionEngine LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTarget)
set_property(TARGET LLVMHexagonInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMHexagonDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMHexagonInfo LLVMMC LLVMSupport)
set_property(TARGET LLVMHexagonAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMMCParser LLVMSupport)
set_property(TARGET LLVMHexagonCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMHexagonAsmParser LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMHexagonDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMHexagonDesc LLVMHexagonInfo LLVMMC LLVMMCDisassembler LLVMSupport)
set_property(TARGET LLVMInterpreter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMSupport)
set_property(TARGET LLVMObjCARCOpts PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMLTO PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMCodeGen LLVMCore LLVMInstCombine LLVMLinker LLVMMC LLVMObjCARCOpts LLVMObject LLVMScalarOpts LLVMSupport LLVMTarget LLVMipo)
set_property(TARGET LLVMOption PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMLibDriver PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMObject LLVMOption LLVMSupport)
set_property(TARGET LLVMLineEditor PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMMIRParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAsmParser LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget)
set_property(TARGET LLVMMSP430AsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMMSP430Info PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMMSP430Desc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Info LLVMSupport)
set_property(TARGET LLVMMSP430CodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Desc LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(TARGET LLVMMipsAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMMipsInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMMipsDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMipsAsmPrinter LLVMMipsInfo LLVMSupport)
set_property(TARGET LLVMMipsAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCParser LLVMMipsDesc LLVMMipsInfo LLVMSupport)
set_property(TARGET LLVMMipsCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsAsmPrinter LLVMMipsDesc LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMTarget)
set_property(TARGET LLVMMipsDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMCDisassembler LLVMMipsInfo LLVMSupport)
set_property(TARGET LLVMNVPTXAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMNVPTXInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMNVPTXDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMNVPTXAsmPrinter LLVMNVPTXInfo LLVMSupport)
set_property(TARGET LLVMNVPTXCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMNVPTXAsmPrinter LLVMNVPTXDesc LLVMNVPTXInfo LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMX86Utils PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMSupport)
set_property(TARGET LLVMX86AsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport LLVMX86Utils)
set_property(TARGET LLVMX86Info PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMX86Desc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCDisassembler LLVMObject LLVMSupport LLVMX86AsmPrinter LLVMX86Info)
set_property(TARGET LLVMX86CodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMX86AsmPrinter LLVMX86Desc LLVMX86Info LLVMX86Utils)
set_property(TARGET LLVMOrcJIT PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMCore LLVMExecutionEngine LLVMObject LLVMRuntimeDyld LLVMSupport LLVMTransformUtils)
set_property(TARGET LLVMPasses PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMCore LLVMInstCombine LLVMScalarOpts LLVMSupport LLVMTransformUtils LLVMVectorize LLVMipo)
set_property(TARGET LLVMPowerPCAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMPowerPCInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMPowerPCDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCInfo LLVMSupport)
set_property(TARGET LLVMPowerPCAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCParser LLVMPowerPCDesc LLVMPowerPCInfo LLVMSupport)
set_property(TARGET LLVMPowerPCCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCDesc LLVMPowerPCInfo LLVMScalarOpts LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils)
set_property(TARGET LLVMPowerPCDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMCDisassembler LLVMPowerPCInfo LLVMSupport)
set_property(TARGET LLVMSparcAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMSparcInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMSparcDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSparcAsmPrinter LLVMSparcInfo LLVMSupport)
set_property(TARGET LLVMSparcAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCParser LLVMSparcDesc LLVMSparcInfo LLVMSupport)
set_property(TARGET LLVMSparcCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcAsmPrinter LLVMSparcDesc LLVMSparcInfo LLVMSupport LLVMTarget)
set_property(TARGET LLVMSparcDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMCDisassembler LLVMSparcInfo LLVMSupport)
set_property(TARGET LLVMSymbolize PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMDebugInfoDWARF LLVMDebugInfoPDB LLVMObject LLVMSupport)
set_property(TARGET LLVMSystemZAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMSystemZInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMSystemZDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport LLVMSystemZAsmPrinter LLVMSystemZInfo)
set_property(TARGET LLVMSystemZAsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCParser LLVMSupport LLVMSystemZDesc LLVMSystemZInfo)
set_property(TARGET LLVMSystemZCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystemZAsmPrinter LLVMSystemZDesc LLVMSystemZInfo LLVMTarget)
set_property(TARGET LLVMSystemZDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCDisassembler LLVMSupport LLVMSystemZDesc LLVMSystemZInfo)
set_property(TARGET LLVMTableGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMX86AsmParser PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMMCParser LLVMSupport LLVMX86Desc LLVMX86Info)
set_property(TARGET LLVMX86Disassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMCDisassembler LLVMSupport LLVMX86Info)
set_property(TARGET LLVMXCoreAsmPrinter PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport)
set_property(TARGET LLVMXCoreInfo PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMSupport)
set_property(TARGET LLVMXCoreDesc PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMC LLVMSupport LLVMXCoreAsmPrinter LLVMXCoreInfo)
set_property(TARGET LLVMXCoreCodeGen PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMTransformUtils LLVMXCoreAsmPrinter LLVMXCoreDesc LLVMXCoreInfo)
set_property(TARGET LLVMXCoreDisassembler PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES LLVMMCDisassembler LLVMSupport LLVMXCoreInfo)
set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES pthread dl m )
include(ExternalProject)
# llvm_ExternalProject_BuildCmd(out_var target)
# Utility function for constructing command lines for external project targets
function(llvm_ExternalProject_BuildCmd out_var target)
if (CMAKE_GENERATOR MATCHES "Make")
# Use special command for Makefiles to support parallelism.
set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
else()
set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
--config $<CONFIGURATION> PARENT_SCOPE)
endif()
endfunction()
# llvm_ExternalProject_Add(name source_dir ...
# USE_TOOLCHAIN
# Use just-built tools (see TOOLCHAIN_TOOLS)
# EXCLUDE_FROM_ALL
# Exclude this project from the all target
# NO_INSTALL
# Don't generate install targets for this project
# CMAKE_ARGS arguments...
# Optional cmake arguments to pass when configuring the project
# TOOLCHAIN_TOOLS targets...
# Targets for toolchain tools (defaults to clang;lld)
# DEPENDS targets...
# Targets that this project depends on
# EXTRA_TARGETS targets...
# Extra targets in the subproject to generate targets for
# )
function(llvm_ExternalProject_Add name source_dir)
cmake_parse_arguments(ARG "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL"
"SOURCE_DIR"
"CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS" ${ARGN})
canonicalize_tool_name(${name} nameCanon)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang lld)
endif()
foreach(tool ${ARG_TOOLCHAIN_TOOLS})
if(TARGET ${tool})
list(APPEND TOOLCHAIN_TOOLS ${tool})
list(APPEND TOOLCHAIN_BINS $<TARGET_FILE:${tool}>)
endif()
endforeach()
if(NOT ARG_RUNTIME_LIBRARIES)
set(ARG_RUNTIME_LIBRARIES compiler-rt libcxx)
endif()
foreach(lib ${ARG_RUNTIME_LIBRARIES})
if(TARGET ${lib})
list(APPEND RUNTIME_LIBRARIES ${lib})
endif()
endforeach()
list(FIND TOOLCHAIN_TOOLS clang FOUND_CLANG)
if(FOUND_CLANG GREATER -1)
set(CLANG_IN_TOOLCHAIN On)
endif()
if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
set(cmake_3_1_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL 1)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
set(cmake_3_4_USES_TERMINAL_OPTIONS
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
)
set(cmake_3_4_USES_TERMINAL USES_TERMINAL 1)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.1.20141116)
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-stamps/)
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-bins/)
add_custom_target(${name}-clear
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
COMMENT "Clobbering ${name} build and stamp directories"
${cmake_3_2_USES_TERMINAL}
)
# Find all variables that start with COMPILER_RT and populate a variable with
# them.
get_cmake_property(variableNames VARIABLES)
foreach(variableName ${variableNames})
if(variableName MATCHES "^${nameCanon}")
string(REPLACE ";" "\;" value "${${variableName}}")
list(APPEND PASSTHROUGH_VARIABLES
-D${variableName}=${value})
endif()
endforeach()
if(ARG_USE_TOOLCHAIN)
if(CLANG_IN_TOOLCHAIN)
set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
endif()
list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
DEPENDS ${ARG_DEPENDS}
COMMAND ${CMAKE_COMMAND} -E touch ${BINARY_DIR}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_DIR}/${name}-mkdir
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp
COMMENT "Clobbering bootstrap build and stamp directories"
)
add_custom_target(${name}-clobber
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
if(ARG_EXCLUDE_FROM_ALL)
set(exclude ${cmake_3_1_EXCLUDE_FROM_ALL})
endif()
ExternalProject_Add(${name}
DEPENDS ${ARG_DEPENDS}
${name}-clobber
PREFIX ${CMAKE_BINARY_DIR}/projects/${name}
SOURCE_DIR ${source_dir}
STAMP_DIR ${STAMP_DIR}
BINARY_DIR ${BINARY_DIR}
${exclude}
CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS}
${compiler_args}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
${ARG_CMAKE_ARGS}
${PASSTHROUGH_VARIABLES}
INSTALL_COMMAND ""
STEP_TARGETS configure build
${cmake_3_4_USES_TERMINAL_OPTIONS}
)
if(ARG_USE_TOOLCHAIN)
ExternalProject_Add_Step(${name} force-rebuild
COMMENT "Forcing rebuild becaues tools have changed"
DEPENDERS configure
DEPENDS ${TOOLCHAIN_BINS}
${cmake_3_4_USES_TERMINAL} )
endif()
if(ARG_USE_TOOLCHAIN)
set(force_deps DEPENDS ${TOOLCHAIN_BINS})
endif()
llvm_ExternalProject_BuildCmd(run_clean clean)
ExternalProject_Add_Step(${name} clean
COMMAND ${run_clean}
COMMENT "Cleaning ${name}..."
DEPENDEES configure
${force_deps}
WORKING_DIRECTORY ${BINARY_DIR}
${cmake_3_4_USES_TERMINAL}
)
ExternalProject_Add_StepTargets(${name} clean)
if(ARG_USE_TOOLCHAIN)
add_dependencies(${name}-clean ${name}-clobber)
set_target_properties(${name}-clean PROPERTIES
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
endif()
if(NOT ARG_NO_INSTALL)
install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
COMPONENT ${name})
add_custom_target(install-${name}
DEPENDS ${name}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${name}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
${cmake_3_2_USES_TERMINAL})
endif()
# Add top-level targets
foreach(target ${ARG_EXTRA_TARGETS})
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target})
add_custom_target(${target}
COMMAND ${build_runtime_cmd}
DEPENDS ${name}-configure
WORKING_DIRECTORY ${BINARY_DIR}
VERBATIM
${cmake_3_2_USES_TERMINAL})
endforeach()
endfunction()
include(AddFileDependencies)
include(CMakeParseArguments)
function(llvm_replace_compiler_option var old new)
# Replaces a compiler option or switch `old' in `var' by `new'.
# If `old' is not in `var', appends `new' to `var'.
# Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
# If the option already is on the variable, don't add it:
if( "${${var}}" MATCHES "(^| )${new}($| )" )
set(n "")
else()
set(n "${new}")
endif()
if( "${${var}}" MATCHES "(^| )${old}($| )" )
string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
else()
set( ${var} "${${var}} ${n}" )
endif()
set( ${var} "${${var}}" PARENT_SCOPE )
endfunction(llvm_replace_compiler_option)
macro(add_td_sources srcs)
file(GLOB tds *.td)
if( tds )
source_group("TableGen descriptions" FILES ${tds})
set_source_files_properties(${tds} PROPERTIES HEADER_FILE_ONLY ON)
list(APPEND ${srcs} ${tds})
endif()
endmacro(add_td_sources)
function(add_header_files_for_glob hdrs_out glob)
file(GLOB hds ${glob})
set(${hdrs_out} ${hds} PARENT_SCOPE)
endfunction(add_header_files_for_glob)
function(find_all_header_files hdrs_out additional_headerdirs)
add_header_files_for_glob(hds *.h)
list(APPEND all_headers ${hds})
foreach(additional_dir ${additional_headerdirs})
add_header_files_for_glob(hds "${additional_dir}/*.h")
list(APPEND all_headers ${hds})
add_header_files_for_glob(hds "${additional_dir}/*.inc")
list(APPEND all_headers ${hds})
endforeach(additional_dir)
set( ${hdrs_out} ${all_headers} PARENT_SCOPE )
endfunction(find_all_header_files)
function(llvm_process_sources OUT_VAR)
cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
set(sources ${ARG_UNPARSED_ARGUMENTS})
llvm_check_source_file_list( ${sources} )
if( MSVC_IDE OR XCODE )
# This adds .td and .h files to the Visual Studio solution:
add_td_sources(sources)
find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
if (hdrs)
set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
endif()
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
endif()
set( ${OUT_VAR} ${sources} PARENT_SCOPE )
endfunction(llvm_process_sources)
function(llvm_check_source_file_list)
set(listed ${ARGN})
file(GLOB globbed *.c *.cpp)
foreach(g ${globbed})
get_filename_component(fn ${g} NAME)
# Don't reject hidden files. Some editors create backups in the
# same directory as the file.
if (NOT "${fn}" MATCHES "^\\.")
list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
if( idx LESS 0 )
list(FIND listed ${fn} idx)
if( idx LESS 0 )
message(SEND_ERROR "Found unknown source file ${g}
Please update ${CMAKE_CURRENT_LIST_FILE}\n")
endif()
endif()
endif()
endforeach()
endfunction(llvm_check_source_file_list)
# LLVM_TARGET_DEFINITIONS must contain the name of the .td file to process.
# Extra parameters for `tblgen' may come after `ofn' parameter.
# Adds the name of the generated file to TABLEGEN_OUTPUT.
function(tablegen project ofn)
# Validate calling context.
foreach(v
${project}_TABLEGEN_EXE
LLVM_MAIN_SRC_DIR
LLVM_MAIN_INCLUDE_DIR
)
if(NOT ${v})
message(FATAL_ERROR "${v} not set")
endif()
endforeach()
file(GLOB local_tds "*.td")
file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
else()
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE
${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS})
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
# Generate tablegen output in a temporary file.
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${LLVM_MAIN_SRC_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
# directory and local_tds may not contain it, so we must
# explicitly list it here:
DEPENDS ${${project}_TABLEGEN_TARGET} ${local_tds} ${global_tds}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
COMMENT "Building ${ofn}..."
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
# Only update the real output file if there are any differences.
# This prevents recompilation of all the files depending on it if there
# aren't any.
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
${CMAKE_CURRENT_BINARY_DIR}/${ofn}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
COMMENT "Updating ${ofn}..."
)
# `make clean' must remove all those generated files:
set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn}.tmp ${ofn})
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES
GENERATED 1)
endfunction()
# Creates a target for publicly exporting tablegen dependencies.
function(add_public_tablegen_target target)
if(NOT TABLEGEN_OUTPUT)
message(FATAL_ERROR "Requires tablegen() definitions as TABLEGEN_OUTPUT.")
endif()
add_custom_target(${target}
DEPENDS ${TABLEGEN_OUTPUT})
if(LLVM_COMMON_DEPENDS)
add_dependencies(${target} ${LLVM_COMMON_DEPENDS})
endif()
set_target_properties(${target} PROPERTIES FOLDER "Tablegenning")
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${target} PARENT_SCOPE)
endfunction()
if(LLVM_USE_HOST_TOOLS)
add_custom_command(OUTPUT LIB_LLVMSUPPORT
COMMAND ${CMAKE_COMMAND} --build . --target LLVMSupport --config Release
DEPENDS CONFIGURE_LLVM_NATIVE
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
COMMENT "Building libLLVMSupport for native TableGen...")
add_custom_target(NATIVE_LIB_LLVMSUPPORT DEPENDS LIB_LLVMSUPPORT)
add_custom_command(OUTPUT LIB_LLVMTABLEGEN
COMMAND ${CMAKE_COMMAND} --build . --target LLVMTableGen --config Release
DEPENDS CONFIGURE_LLVM_NATIVE
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
COMMENT "Building libLLVMTableGen for native TableGen...")
add_custom_target(NATIVE_LIB_LLVMTABLEGEN DEPENDS LIB_LLVMTABLEGEN)
endif(LLVM_USE_HOST_TOOLS)
macro(add_tablegen target project)
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
if(NOT XCODE)
# FIXME: It leaks to user, callee of add_tablegen.
set(LLVM_ENABLE_OBJLIB ON)
endif()
add_llvm_utility(${target} ${ARGN})
set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
set(${project}_TABLEGEN "${target}" CACHE
STRING "Native TableGen executable. Saves building one when cross-compiling.")
# Upgrade existing LLVM_TABLEGEN setting.
if(${project} STREQUAL LLVM)
if(${LLVM_TABLEGEN} STREQUAL tblgen)
set(LLVM_TABLEGEN "${target}" CACHE
STRING "Native TableGen executable. Saves building one when cross-compiling."
FORCE)
endif()
endif()
# Effective tblgen executable to be used:
set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE)
set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE)
if(LLVM_USE_HOST_TOOLS)
if( ${${project}_TABLEGEN} STREQUAL "${target}" )
if (NOT CMAKE_CONFIGURATION_TYPES)
set(${project}_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/${target}")
else()
set(${project}_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/${target}")
endif()
set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE)
add_custom_command(OUTPUT ${${project}_TABLEGEN_EXE}
COMMAND ${CMAKE_COMMAND} --build . --target ${target} --config Release
DEPENDS ${target} NATIVE_LIB_LLVMSUPPORT NATIVE_LIB_LLVMTABLEGEN
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
COMMENT "Building native TableGen...")
add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE})
set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE)
endif()
endif()
if( MINGW )
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set_target_properties(${target} PROPERTIES LINK_FLAGS -Wl,--stack,16777216)
endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
endif( MINGW )
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${target}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
endmacro()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment