aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /cmake
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Makefile12
-rwxr-xr-xcmake/config-ix.cmake10
-rw-r--r--cmake/modules/AddLLVM.cmake488
-rw-r--r--cmake/modules/CMakeLists.txt70
-rw-r--r--cmake/modules/ChooseMSVCCRT.cmake14
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake182
-rw-r--r--cmake/modules/HandleLLVMStdlib.cmake35
-rw-r--r--cmake/modules/LLVM-Config.cmake119
-rw-r--r--cmake/modules/LLVMConfig.cmake.in31
-rw-r--r--cmake/modules/LLVMProcessSources.cmake37
-rw-r--r--cmake/modules/Makefile96
-rw-r--r--cmake/modules/TableGen.cmake73
-rw-r--r--cmake/nsis_icon.icobin0 -> 65901 bytes
-rw-r--r--cmake/platforms/Android.cmake5
14 files changed, 872 insertions, 300 deletions
diff --git a/cmake/Makefile b/cmake/Makefile
new file mode 100644
index 0000000..523cd45
--- /dev/null
+++ b/cmake/Makefile
@@ -0,0 +1,12 @@
+##===- cmake/Makefile --------------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ..
+DIRS := modules
+
+include $(LEVEL)/Makefile.common
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index dc991a2..f007b37 100755
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -11,6 +11,8 @@ include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
+include(HandleLLVMStdlib)
+
if( UNIX AND NOT BEOS )
# Used by check_symbol_exists:
set(CMAKE_REQUIRED_LIBRARIES m)
@@ -49,7 +51,6 @@ check_include_file(ndir.h HAVE_NDIR_H)
if( NOT PURE_WINDOWS )
check_include_file(pthread.h HAVE_PTHREAD_H)
endif()
-check_include_file(sanitizer/msan_interface.h HAVE_SANITIZER_MSAN_INTERFACE_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(sys/dir.h HAVE_SYS_DIR_H)
@@ -97,6 +98,7 @@ if( NOT PURE_WINDOWS )
else()
set(HAVE_LIBZ 0)
endif()
+ check_library_exists(edit el_init "" HAVE_LIBEDIT)
if(LLVM_ENABLE_TERMINFO)
set(HAVE_TERMINFO 0)
foreach(library tinfo terminfo curses ncurses ncursesw)
@@ -114,7 +116,7 @@ if( NOT PURE_WINDOWS )
endif()
# function checks
-check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
+check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
@@ -316,8 +318,6 @@ if (LIBXML2_FOUND)
endif ()
endif ()
-include(CheckCXXCompilerFlag)
-
check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
set(USE_NO_MAYBE_UNINITIALIZED 0)
@@ -366,6 +366,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
set(LLVM_NATIVE_ARCH PowerPC)
elseif (LLVM_NATIVE_ARCH MATCHES "aarch64")
set(LLVM_NATIVE_ARCH AArch64)
+elseif (LLVM_NATIVE_ARCH MATCHES "arm64")
+ set(LLVM_NATIVE_ARCH ARM64)
elseif (LLVM_NATIVE_ARCH MATCHES "arm")
set(LLVM_NATIVE_ARCH ARM)
elseif (LLVM_NATIVE_ARCH MATCHES "mips")
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 34e4017..41902d2 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -2,16 +2,280 @@ include(LLVMParseArguments)
include(LLVMProcessSources)
include(LLVM-Config)
-macro(add_llvm_library name)
- llvm_process_sources( ALL_FILES ${ARGN} )
- add_library( ${name} ${ALL_FILES} )
- set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
- if( LLVM_COMMON_DEPENDS )
- add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
- endif( LLVM_COMMON_DEPENDS )
+function(llvm_update_compile_flags name)
+ get_property(sources TARGET ${name} PROPERTY SOURCES)
+ if("${sources}" MATCHES "\\.c(;|$)")
+ set(update_src_props ON)
+ endif()
- if( BUILD_SHARED_LIBS )
- llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
+ if(LLVM_REQUIRES_EH)
+ set(LLVM_REQUIRES_RTTI ON)
+ 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()
+
+ if(NOT LLVM_REQUIRES_RTTI)
+ 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}")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+ else()
+ set(native_export_file "${target_name}.def")
+
+ set(CAT "type")
+ if(CYGWIN)
+ set(CAT "cat")
+ endif()
+
+ # Using ${export_file} in add_custom_command directly confuses cmd.exe.
+ file(TO_NATIVE_PATH ${export_file} export_file_backslashes)
+
+ add_custom_command(OUTPUT ${native_export_file}
+ COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > ${native_export_file}
+ COMMAND ${CAT} ${export_file_backslashes} >> ${native_export_file}
+ DEPENDS ${export_file}
+ VERBATIM
+ COMMENT "Creating export file for ${target_name}")
+ if(CYGWIN OR MINGW)
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " ${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+ else()
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " /DEF:${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+ endif()
+ 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)
+
+function(add_dead_strip target_name)
+ if(NOT LLVM_NO_DEAD_STRIP)
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-dead_strip")
+ elseif(NOT WIN32)
+ # Object files are compiled with -ffunction-data-sections.
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,--gc-sections")
+ endif()
+ endif()
+endfunction(add_dead_strip)
+
+# 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 bindir libdir)
+ if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
+ string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${bindir})
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${libdir})
+ set_target_properties(${target} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${bi})
+ set_target_properties(${target} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li})
+ set_target_properties(${target} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li})
+ endforeach()
+ else()
+ set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bindir})
+ set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libdir})
+ set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libdir})
+ endif()
+endfunction()
+
+# llvm_add_library(name sources...
+# SHARED;STATIC
+# STATIC by default w/o BUILD_SHARED_LIBS.
+# SHARED by default w/ BUILD_SHARED_LIBS.
+# MODULE
+# Target ${name} might not be created on unsupported platforms.
+# Check with "if(TARGET ${name})".
+# 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.
+# )
+function(llvm_add_library name)
+ cmake_parse_arguments(ARG
+ "MODULE;SHARED;STATIC"
+ "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_ON_UNIX OR CYGWIN)
+ 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)
+ # 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_library(${name} SHARED ${ALL_FILES})
+ else()
+ add_library(${name} STATIC ${ALL_FILES})
+ endif()
+ set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
+ llvm_update_compile_flags(${name})
+ add_dead_strip( ${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 (MSVC)
set_target_properties(${name}
PROPERTIES
@@ -19,64 +283,101 @@ macro(add_llvm_library name)
endif ()
endif()
- # Ensure that the system libraries always comes last on the
- # list. Without this, linking the unit tests on MinGW fails.
- link_system_libs( ${name} )
+ if(ARG_MODULE OR ARG_SHARED)
+ if (LLVM_EXPORTED_SYMBOL_FILE)
+ add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
+ endif()
+ endif()
+
+ # Add the explicit dependency information for this library.
+ #
+ # 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})
+
+ llvm_map_components_to_libnames(llvm_libs
+ ${ARG_LINK_COMPONENTS}
+ ${LLVM_LINK_COMPONENTS}
+ )
+
+ 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}
+ )
+ elseif(ARG_SHARED AND BUILD_SHARED_LIBS)
+ # FIXME: It may be PRIVATE since SO knows its dependent libs.
+ target_link_libraries(${name} PUBLIC
+ ${ARG_LINK_LIBS}
+ ${lib_deps}
+ ${llvm_libs}
+ )
+ else()
+ # MODULE|SHARED
+ 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()
+endfunction()
+
+macro(add_llvm_library name)
+ if( BUILD_SHARED_LIBS )
+ llvm_add_library(${name} SHARED ${ARGN})
+ else()
+ llvm_add_library(${name} ${ARGN})
+ endif()
+ set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
install(TARGETS ${name}
+ EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Libraries")
-
- # Add the explicit dependency information for this library.
- #
- # 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})
- target_link_libraries(${name} ${lib_deps})
endmacro(add_llvm_library name)
macro(add_llvm_loadable_module name)
- if( NOT LLVM_ON_UNIX OR CYGWIN )
- message(STATUS "Loadable modules not supported on this platform.
-${name} ignored.")
+ llvm_add_library(${name} MODULE ${ARGN})
+ if(NOT TARGET ${name})
# Add empty "phony" target
add_custom_target(${name})
else()
- llvm_process_sources( ALL_FILES ${ARGN} )
- if (MODULE)
- set(libkind MODULE)
- else()
- set(libkind SHARED)
- endif()
-
- add_library( ${name} ${libkind} ${ALL_FILES} )
- set_target_properties( ${name} PROPERTIES PREFIX "" )
-
- llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
- link_system_libs( ${name} )
-
- if (APPLE)
- # Darwin-specific linker flags for loadable modules.
- set_target_properties(${name} PROPERTIES
- LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
- endif()
-
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${name}
+ EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
endif()
@@ -91,12 +392,19 @@ macro(add_llvm_executable name)
else()
add_executable(${name} ${ALL_FILES})
endif()
+ llvm_update_compile_flags(${name})
+ add_dead_strip( ${name} )
+
+ if (LLVM_EXPORTED_SYMBOL_FILE)
+ add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
+ endif(LLVM_EXPORTED_SYMBOL_FILE)
+
set(EXCLUDE_FROM_ALL OFF)
+ set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
- link_system_libs( ${name} )
endmacro(add_llvm_executable name)
@@ -106,7 +414,6 @@ set (LLVM_TOOLCHAIN_TOOLS
)
macro(add_llvm_tool name)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
if( NOT LLVM_BUILD_TOOLS )
set(EXCLUDE_FROM_ALL ON)
endif()
@@ -115,15 +422,19 @@ macro(add_llvm_tool name)
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} RUNTIME DESTINATION bin)
+ install(TARGETS ${name}
+ EXPORT LLVMExports
+ RUNTIME DESTINATION bin)
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)
-# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
if( NOT LLVM_BUILD_EXAMPLES )
set(EXCLUDE_FROM_ALL ON)
endif()
@@ -145,14 +456,14 @@ macro(add_llvm_target target_name)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
- add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
+ add_llvm_library(LLVM${target_name} ${ARGN})
set( CURRENT_LLVM_TARGET LLVM${target_name} )
endmacro(add_llvm_target)
# 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 everthing else.
+# enable or disable building it with everything else.
# Additional parameter can be specified as the name of directory.
macro(add_llvm_external_project name)
set(add_llvm_external_dir "${ARGN}")
@@ -204,51 +515,45 @@ endfunction(add_llvm_implicit_external_projects)
# Generic support for adding a unittest.
function(add_unittest test_suite test_name)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if( NOT LLVM_BUILD_TESTS )
set(EXCLUDE_FROM_ALL ON)
endif()
- add_llvm_executable(${test_name} ${ARGN})
- target_link_libraries(${test_name}
- gtest
- gtest_main
- LLVMSupport # gtest needs it for raw_ostream.
- )
-
- 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 ()
-
# Visual Studio 2012 only supports up to 8 template parameters in
# std::tr1::tuple by default, but gtest requires 10
if (MSVC AND MSVC_VERSION EQUAL 1700)
- set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS _VARIADIC_MAX=10)
+ list(APPEND LLVM_COMPILE_DEFINITIONS _VARIADIC_MAX=10)
endif ()
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
- set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
if (NOT LLVM_ENABLE_THREADS)
- set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
+ list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
endif ()
- get_property(target_compile_flags TARGET ${test_name} PROPERTY COMPILE_FLAGS)
- if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- set(target_compile_flags "${target_compile_flags} -fno-rtti")
- elseif (MSVC)
- llvm_replace_compiler_option(target_compile_flags "/GR" "/GR-")
+ if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
+ list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
endif ()
- if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
- set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros")
+ set(LLVM_REQUIRES_RTTI OFF)
+
+ add_llvm_executable(${test_name} ${ARGN})
+ set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
+ set_output_directory(${test_name} ${outdir} ${outdir})
+ target_link_libraries(${test_name}
+ gtest
+ gtest_main
+ LLVMSupport # gtest needs it for raw_ostream.
+ )
+
+ 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 ()
- set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}")
endfunction()
# This function provides an automatic way to 'configure'-like generate a file
-# based on a set of common and custom variables, specifically targetting the
+# 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.
@@ -259,7 +564,6 @@ function(configure_lit_site_cfg input output)
set(TARGETS_TO_BUILD ${TARGETS_BUILT})
set(SHLIBEXT "${LTDL_SHLIB_EXT}")
- set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}")
if(BUILD_SHARED_LIBS)
set(LLVM_SHARED_LIBS_ENABLED "1")
@@ -267,25 +571,24 @@ function(configure_lit_site_cfg input output)
set(LLVM_SHARED_LIBS_ENABLED "0")
endif(BUILD_SHARED_LIBS)
- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH")
- else() # Default for all other unix like systems.
- # CMake hardcodes the library locaction using rpath.
- # Therefore LD_LIBRARY_PATH is not required to run binaries in the
- # build dir. We pass it anyways.
- set(SHLIBPATH_VAR "LD_LIBRARY_PATH")
- endif()
-
# Configuration-time: See Unit/lit.site.cfg.in
- set(LLVM_BUILD_MODE "%(build_mode)s")
+ 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})
- set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_mode)s")
- set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_mode)s")
+ 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_LIBRARY_OUTPUT_INTDIR})
+
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
- set(SHLIBPATH_VAR ${SHLIBPATH_VAR})
if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
set(ENABLE_ASSERTIONS "1")
@@ -321,10 +624,12 @@ function(add_lit_target target comment)
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 ()
set(LIT_COMMAND
${PYTHON_EXECUTABLE}
${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py
- --param build_mode=${CMAKE_CFG_INTDIR}
${LIT_ARGS}
)
foreach(param ${ARG_PARAMS})
@@ -338,9 +643,12 @@ function(add_lit_target target comment)
add_dependencies(${target} ${ARG_DEPENDS})
else()
add_custom_target(${target}
- COMMAND cmake -E echo "${target} does nothing, no tools built.")
+ COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
message(STATUS "${target} does nothing.")
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.
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
index 0253952..08aeeb9 100644
--- a/cmake/modules/CMakeLists.txt
+++ b/cmake/modules/CMakeLists.txt
@@ -1,33 +1,89 @@
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/share/llvm/cmake")
-set(LLVM_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm/cmake)
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
+get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
+export(TARGETS ${LLVM_EXPORTS}
+ FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
-foreach(lib ${llvm_libs})
+get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
+
+foreach(lib ${LLVM_AVAILABLE_LIBS})
get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib})
set(all_llvm_lib_deps
"${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})")
endforeach(lib)
+# Generate LLVMConfig.cmake for the build tree.
+set(LLVM_CONFIG_CODE "
+# LLVM_BUILD_* values available only from LLVM build tree.
+set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\")
+set(LLVM_BUILD_ENABLE_ASSERTIONS \"${LLVM_ENABLE_ASSERTIONS}\")
+set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\")
+set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\")
+set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\")
+set(LLVM_BUILD_TOOLS_BINARY_DIR \"${LLVM_TOOLS_BINARY_DIR}\")
+")
+set(LLVM_CONFIG_INCLUDE_DIRS
+ "${LLVM_MAIN_INCLUDE_DIR}"
+ "${LLVM_INCLUDE_DIR}"
+ )
+set(LLVM_CONFIG_LIBRARY_DIRS
+ "${LLVM_LIBRARY_DIR}"
+ )
+set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake")
configure_file(
LLVMConfig.cmake.in
${llvm_cmake_builddir}/LLVMConfig.cmake
@ONLY)
+# For compatibility with projects that include(LLVMConfig)
+# via CMAKE_MODULE_PATH, place API modules next to it.
+# This should be removed in the future.
+file(COPY .
+ DESTINATION ${llvm_cmake_builddir}
+ FILES_MATCHING PATTERN *.cmake
+ PATTERN .svn EXCLUDE
+ PATTERN CMakeFiles EXCLUDE
+ )
+
+# Generate LLVMConfig.cmake for the install tree.
+set(LLVM_CONFIG_CODE "
+# Compute the installation prefix from this LLVMConfig.cmake file location.
+get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
+# Construct the proper number of get_filename_component(... PATH)
+# calls to compute the installation prefix.
+string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
+foreach(p ${_count})
+ set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
+get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
+endforeach(p)
+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib")
+set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
+set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
+configure_file(
+ LLVMConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
+ @ONLY)
+
+# Generate LLVMConfigVersion.cmake for build and install tree.
configure_file(
LLVMConfigVersion.cmake.in
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
@ONLY)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR})
+
install(FILES
- ${llvm_cmake_builddir}/LLVMConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
LLVM-Config.cmake
- DESTINATION share/llvm/cmake)
+ DESTINATION ${LLVM_INSTALL_PACKAGE_DIR})
install(DIRECTORY .
- DESTINATION share/llvm/cmake
+ DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
FILES_MATCHING PATTERN *.cmake
PATTERN .svn EXCLUDE
PATTERN LLVMConfig.cmake EXCLUDE
diff --git a/cmake/modules/ChooseMSVCCRT.cmake b/cmake/modules/ChooseMSVCCRT.cmake
index 25ed9c7..0e6e1aa 100644
--- a/cmake/modules/ChooseMSVCCRT.cmake
+++ b/cmake/modules/ChooseMSVCCRT.cmake
@@ -64,14 +64,14 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.")
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})
+ 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)
+ "${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}})
+ PROPERTY STRINGS ;${${MSVC_CRT}})
endif(NOT LLVM_USE_CRT_${build})
endforeach(build_type)
@@ -84,7 +84,7 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.")
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}}")
+ "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()
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index bb41a58..d5afc62 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -2,16 +2,48 @@
# options and executing the appropriate CMake commands to realize the users'
# selections.
+include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
-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)
+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()
+
+ # Also 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.
+ if(NOT LLVM_ENABLE_LIBCXX)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
+ if (ANDROID)
+ set(CMAKE_REQUIRED_LIBRARIES "atomic")
+ endif()
+ 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 17.0)
+ message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)")
+ endif()
+ endif()
endif()
if( LLVM_ENABLE_ASSERTIONS )
@@ -24,13 +56,13 @@ if( LLVM_ENABLE_ASSERTIONS )
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions( -UNDEBUG )
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
- set(REGEXP_NDEBUG "(^| )[/-]D *NDEBUG($| )")
- string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
- CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
- CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
- string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
- CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
+ set(REGEXP_NDEBUG "(^| )[/-]D *NDEBUG($| )")
+ string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
+ CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+ string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
+ CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+ string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
+ CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
endif()
else()
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
@@ -41,6 +73,7 @@ else()
endif()
if(WIN32)
+ set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
@@ -48,8 +81,6 @@ if(WIN32)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
- set(LTDL_SHLIB_EXT ".dll")
- set(EXEEXT ".exe")
# Maximum path length is 160 for non-unicode paths
set(MAXPATHLEN 160)
else(WIN32)
@@ -57,11 +88,10 @@ else(WIN32)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE)
- set(LTDL_SHLIB_EXT ".dylib")
+ set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else(APPLE)
- set(LTDL_SHLIB_EXT ".so")
+ set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif(APPLE)
- set(EXEEXT "")
# FIXME: Maximum path length is currently set to 'safe' fixed value
set(MAXPATHLEN 2024)
else(UNIX)
@@ -69,6 +99,17 @@ else(WIN32)
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()
+
function(add_flag_or_print_warning flag)
check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
@@ -132,6 +173,29 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
endif( LLVM_BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
+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 )
@@ -141,14 +205,8 @@ if( MSVC_IDE )
if( LLVM_COMPILER_JOBS STREQUAL "0" )
add_llvm_definitions( /MP )
else()
- if (MSVC10)
- message(FATAL_ERROR
- "Due to a bug in CMake only 0 and 1 is supported for "
- "LLVM_COMPILER_JOBS when generating for Visual Studio 2010")
- else()
- message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS})
- add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} )
- endif()
+ 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")
@@ -167,13 +225,7 @@ if( MSVC )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
endif()
- if( MSVC10 )
- # MSVC 10 will complain about headers in the STL not being exported, but
- # will not complain in MSVC 11.
- add_llvm_definitions(
- -wd4275 # Suppress 'An exported class was derived from a class that was not exported.'
- )
- elseif( MSVC11 )
+ if( MSVC11 )
add_llvm_definitions(-D_VARIADIC_MAX=10)
endif()
@@ -192,13 +244,14 @@ if( MSVC )
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
-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'
-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)'
- -wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
# Promoted warnings.
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
@@ -243,9 +296,24 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG)
append_if(CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG "-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
endif (LLVM_ENABLE_WARNINGS)
- if (LLVM_ENABLE_WERROR)
- add_llvm_definitions( -Werror )
- endif (LLVM_ENABLE_WERROR)
+ append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ 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()
endif( MSVC )
macro(append_common_sanitizer_flags)
@@ -297,3 +365,43 @@ if (UNIX 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")
+ 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.
+ check_c_compiler_flag("-Werror -ffunction-sections" C_SUPPORTS_FFUNCTION_SECTIONS)
+ check_cxx_compiler_flag("-Werror -ffunction-sections" CXX_SUPPORTS_FFUNCTION_SECTIONS)
+ append_if(C_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_CXX_FLAGS)
+ endif()
+ check_c_compiler_flag("-Werror -fdata-sections" C_SUPPORTS_FDATA_SECTIONS)
+ check_cxx_compiler_flag("-Werror -fdata-sections" CXX_SUPPORTS_FDATA_SECTIONS)
+ append_if(C_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_CXX_FLAGS)
+ 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()
diff --git a/cmake/modules/HandleLLVMStdlib.cmake b/cmake/modules/HandleLLVMStdlib.cmake
new file mode 100644
index 0000000..47bb6cd
--- /dev/null
+++ b/cmake/modules/HandleLLVMStdlib.cmake
@@ -0,0 +1,35 @@
+# This CMake module is responsible for setting the standard library to libc++
+# if the user has requested it.
+
+if(NOT DEFINED LLVM_STDLIB_HANDLED)
+ set(LLVM_STDLIB_HANDLED ON)
+
+ 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()
+
+ function(append_if condition value)
+ if(${condition})
+ foreach(variable ${ARGN})
+ set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
+ endforeach(variable)
+ endif()
+ endfunction()
+
+ include(CheckCXXCompilerFlag)
+ if(LLVM_ENABLE_LIBCXX)
+ if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
+ check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
+ append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS)
+ append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS)
+ append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS)
+ append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS)
+ else()
+ message(WARNING "Not sure how to specify libc++ for this compiler")
+ endif()
+ endif()
+endif()
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
index e26fabd..2783af8 100644
--- a/cmake/modules/LLVM-Config.cmake
+++ b/cmake/modules/LLVM-Config.cmake
@@ -1,36 +1,12 @@
function(get_system_libs return_var)
- # Returns in `return_var' a list of system libraries used by LLVM.
- if( NOT MSVC )
- if( MINGW )
- set(system_libs ${system_libs} imagehlp psapi shell32)
- elseif( CMAKE_HOST_UNIX )
- if( HAVE_LIBRT )
- set(system_libs ${system_libs} rt)
- endif()
- if( HAVE_LIBDL )
- set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
- endif()
- if(LLVM_ENABLE_TERMINFO)
- if(HAVE_TERMINFO)
- set(system_libs ${system_libs} ${TERMINFO_LIBS})
- endif()
- endif()
- if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
- set(system_libs ${system_libs} pthread)
- endif()
- if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
- set(system_libs ${system_libs} z)
- endif()
- endif( MINGW )
- endif( NOT MSVC )
- set(${return_var} ${system_libs} PARENT_SCOPE)
-endfunction(get_system_libs)
+ message(AUTHOR_WARNING "get_system_libs no longer needed")
+ set(${return_var} "" PARENT_SCOPE)
+endfunction()
function(link_system_libs target)
- get_system_libs(llvm_system_libs)
- target_link_libraries(${target} ${llvm_system_libs})
-endfunction(link_system_libs)
+ message(AUTHOR_WARNING "link_system_libs no longer needed")
+endfunction()
function(is_llvm_target_library library return_var)
@@ -41,12 +17,12 @@ function(is_llvm_target_library library return_var)
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" )
+ 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()
@@ -62,23 +38,33 @@ endmacro(llvm_config)
function(explicit_llvm_config executable)
set( link_components ${ARGN} )
- explicit_map_components_to_libraries(LIBRARIES ${link_components})
- target_link_libraries(${executable} ${LIBRARIES})
+ llvm_map_components_to_libnames(LIBRARIES ${link_components})
+ get_target_property(t ${executable} TYPE)
+ if("${t}" STREQUAL "STATIC_LIBRARY")
+ target_link_libraries(${executable} ${cmake_2_8_12_INTERFACE} ${LIBRARIES})
+ elseif("${t}" STREQUAL "SHARED_LIBRARY" OR "${t}" STREQUAL "MODULE_LIBRARY")
+ target_link_libraries(${executable} ${cmake_2_8_12_PRIVATE} ${LIBRARIES})
+ else()
+ # Use plain form for legacy user.
+ target_link_libraries(${executable} ${LIBRARIES})
+ endif()
endfunction(explicit_llvm_config)
# This is a variant intended for the final user:
function(llvm_map_components_to_libraries OUT_VAR)
explicit_map_components_to_libraries(result ${ARGN})
- get_system_libs(sys_result)
set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
endfunction(llvm_map_components_to_libraries)
-
-function(explicit_map_components_to_libraries out_libs)
+# Map LINK_COMPONENTS to actual libnames.
+function(llvm_map_components_to_libnames out_libs)
set( link_components ${ARGN} )
- get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
- string(TOUPPER "${llvm_libs}" capitalized_libs)
+ 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)
@@ -104,31 +90,25 @@ function(explicit_map_components_to_libraries out_libs)
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
- list(FIND llvm_libs "LLVM${c}CodeGen" idx)
- if( NOT idx LESS 0 )
- list(APPEND expanded_components "LLVM${c}CodeGen")
+ if( TARGET LLVM${c}CodeGen )
+ list(APPEND expanded_components "LLVM${c}CodeGen")
else()
- list(FIND llvm_libs "LLVM${c}" idx)
- if( NOT idx LESS 0 )
- list(APPEND expanded_components "LLVM${c}")
- else()
- message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
- endif()
+ 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()
- list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
- list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "LLVM${c}AsmParser")
endif()
- list(FIND llvm_libs "LLVM${c}Info" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}Info )
list(APPEND expanded_components "LLVM${c}Info")
endif()
- list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
- if( NOT asmidx LESS 0 )
+ if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "LLVM${c}Disassembler")
endif()
elseif( c STREQUAL "native" )
@@ -140,7 +120,7 @@ function(explicit_map_components_to_libraries out_libs)
elseif( c STREQUAL "engine" )
# already processed
elseif( c STREQUAL "all" )
- list(APPEND expanded_components ${llvm_libs})
+ list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
else( NOT idx LESS 0 )
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
@@ -152,12 +132,18 @@ function(explicit_map_components_to_libraries out_libs)
message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
endif()
else( lib_idx LESS 0 )
- list(GET llvm_libs ${lib_idx} canonical_lib)
+ 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)
- # Expand dependencies while topologically sorting the list of libraries:
+
+ set(${out_libs} ${expanded_components} PARENT_SCOPE)
+endfunction()
+
+# Expand dependencies while topologically sorting the list of libraries:
+function(llvm_expand_dependencies out_libs)
+ set(expanded_components ${ARGN})
list(LENGTH expanded_components lst_size)
set(cursor 0)
set(processed)
@@ -177,11 +163,16 @@ function(explicit_map_components_to_libraries out_libs)
list(LENGTH processed cursor)
list(LENGTH expanded_components lst_size)
endwhile( cursor LESS lst_size )
+ set(${out_libs} ${expanded_components} 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})
- list(FIND llvm_libs ${c} lib_idx)
- if( NOT lib_idx LESS 0 )
+ if( TARGET ${c} )
set(result ${result} ${c})
endif()
endforeach(c)
diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in
index 68fe296..2f8d037 100644
--- a/cmake/modules/LLVMConfig.cmake.in
+++ b/cmake/modules/LLVMConfig.cmake.in
@@ -1,12 +1,14 @@
# This file provides information and services to the final user.
+@LLVM_CONFIG_CODE@
+
set(LLVM_VERSION_MAJOR @LLVM_VERSION_MAJOR@)
set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
-set_property( GLOBAL PROPERTY LLVM_LIBS "@llvm_libs@")
+set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)
set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@)
@@ -18,8 +20,6 @@ set(LLVM_TARGETS_WITH_JIT @LLVM_TARGETS_WITH_JIT@)
set(TARGET_TRIPLE "@TARGET_TRIPLE@")
-set(LLVM_TOOLS_BINARY_DIR @LLVM_TOOLS_BINARY_DIR@)
-
set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@)
set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
@@ -30,29 +30,16 @@ set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
-set(HAVE_TERMINFO @HAVE_TERMINFO@)
-set(TERMINFO_LIBS @TERMINFO_LIBS@)
-set(HAVE_LIBDL @HAVE_LIBDL@)
-set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@)
-set(HAVE_LIBZ @HAVE_LIBZ@)
set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
-set(LLVM_INSTALL_PREFIX "@LLVM_INSTALL_PREFIX@")
-set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
-set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
+set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
+set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
+set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@")
-# We try to include using the current setting of CMAKE_MODULE_PATH,
-# which suppossedly was filled by the user with the directory where
-# this file was installed:
-include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
-
-# If failed, we assume that this is an un-installed build:
-if( NOT LLVMCONFIG_INCLUDED )
- set(CMAKE_MODULE_PATH
- ${CMAKE_MODULE_PATH}
- "@LLVM_SOURCE_DIR@/cmake/modules")
- include( LLVM-Config )
+if(NOT TARGET LLVMSupport)
+ include("@LLVM_CONFIG_EXPORTS_FILE@")
endif()
+include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake
index 2cef6cf..08b9c8e 100644
--- a/cmake/modules/LLVMProcessSources.cmake
+++ b/cmake/modules/LLVMProcessSources.cmake
@@ -1,4 +1,5 @@
include(AddFileDependencies)
+include(CMakeParseArguments)
function(llvm_replace_compiler_option var old new)
# Replaces a compiler option or switch `old' in `var' by `new'.
@@ -38,48 +39,24 @@ endmacro(add_header_files)
function(llvm_process_sources OUT_VAR)
- set( sources ${ARGN} )
+ cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS" ${ARGN})
+ set(sources ${ARG_UNPARSED_ARGUMENTS})
llvm_check_source_file_list( ${sources} )
- # Create file dependencies on the tablegenned files, if any. Seems
- # that this is not strictly needed, as dependencies of the .cpp
- # sources on the tablegenned .inc files are detected and handled,
- # but just in case...
- foreach( s ${sources} )
- set( f ${CMAKE_CURRENT_SOURCE_DIR}/${s} )
- add_file_dependencies( ${f} ${TABLEGEN_OUTPUT} )
- endforeach(s)
if( MSVC_IDE OR XCODE )
# This adds .td and .h files to the Visual Studio solution:
- # FIXME: Shall we handle *.def here?
add_td_sources(sources)
add_header_files(sources)
+ set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
+ list(APPEND sources ${ARG_ADDITIONAL_HEADERS})
endif()
- # Set common compiler options:
- if( NOT LLVM_REQUIRES_EH )
- if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
- add_definitions( -fno-exceptions )
- elseif( MSVC )
- llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/EHsc" "/EHs-c-")
- add_definitions( /D_HAS_EXCEPTIONS=0 )
- endif()
- endif()
- if( NOT LLVM_REQUIRES_RTTI )
- if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
- llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
- elseif( MSVC )
- llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
- endif()
- endif()
-
- set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE )
set( ${OUT_VAR} ${sources} PARENT_SCOPE )
endfunction(llvm_process_sources)
function(llvm_check_source_file_list)
set(listed ${ARGN})
- file(GLOB globbed *.cpp)
+ file(GLOB globbed *.c *.cpp)
foreach(g ${globbed})
get_filename_component(fn ${g} NAME)
list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
@@ -87,7 +64,7 @@ function(llvm_check_source_file_list)
list(FIND listed ${fn} idx)
if( idx LESS 0 )
message(SEND_ERROR "Found unknown source file ${g}
-Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
+Please update ${CMAKE_CURRENT_LIST_FILE}\n")
endif()
endif()
endforeach()
diff --git a/cmake/modules/Makefile b/cmake/modules/Makefile
new file mode 100644
index 0000000..8f20ddf
--- /dev/null
+++ b/cmake/modules/Makefile
@@ -0,0 +1,96 @@
+##===- cmake/modules/Makefile ------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+
+LINK_COMPONENTS := all
+
+include $(LEVEL)/Makefile.common
+
+PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
+
+OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
+
+$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
+ $(Echo) 'Generating LLVM CMake package config file'
+ $(Verb) ( \
+ cat $< | sed \
+ -e 's/@LLVM_CONFIG_CODE@/set(LLVM_INSTALL_PREFIX "'"$(subst /,\/,$(PROJ_prefix))"'")/' \
+ -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
+ -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
+ -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
+ -e 's/@LLVM_COMMON_DEPENDS@//' \
+ -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
+ -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
+ -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
+ -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
+ -e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
+ -e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
+ -e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
+ -e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
+ -e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
+ -e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
+ -e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
+ -e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
+ -e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
+ -e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \
+ -e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \
+ -e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
+ -e 's/@all_llvm_lib_deps@//' \
+ && \
+ grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \
+ ) > $@
+
+$(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in
+ $(Echo) 'Generating LLVM CMake package version file'
+ $(Verb) cat $< | sed \
+ -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
+ > $@
+
+$(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
+ $(Echo) 'Generating LLVM CMake target exports file'
+ $(Verb) ( \
+ echo '# LLVM CMake target exports. Do not include directly.' && \
+ for lib in $(subst -l,,$(LLVMConfigLibs)); do \
+ echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
+ echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
+ done && \
+ cat "$(LLVMBuildCMakeExportsFrag)" && \
+ echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
+ ) | grep -v gtest > $@
+
+all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
+
+SKIPSRCMODS := \
+ CheckAtomic.cmake \
+ GetHostTriple.cmake \
+ LLVMBuildExports.cmake \
+ LLVMConfig.cmake \
+ LLVMConfigVersion.cmake \
+ LLVMExports.cmake \
+ VersionFromVCS.cmake
+
+SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
+SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
+INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
+INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
+
+$(PROJ_cmake):
+ $(Echo) Making install directory: $@
+ $(Verb) $(MKDIR) $@
+
+$(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
+ $(Echo) Installing cmake modules: $(notdir $<)
+ $(Verb) $(DataInstall) $< $(PROJ_cmake)
+
+$(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
+ $(Echo) Installing cmake modules: $(notdir $<)
+ $(Verb) $(DataInstall) $< $(PROJ_cmake)
+
+install-local:: $(INSTSRCMODS) $(INSTOBJMODS)
diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake
index c17e67e..34b0343 100644
--- a/cmake/modules/TableGen.cmake
+++ b/cmake/modules/TableGen.cmake
@@ -2,21 +2,32 @@
# Extra parameters for `tblgen' may come after `ofn' parameter.
# Adds the name of the generated file to TABLEGEN_OUTPUT.
-macro(tablegen project ofn)
+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_SRC_DIR}/include/llvm/*.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
+ 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}
+ ${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
@@ -33,28 +44,30 @@ macro(tablegen project ofn)
${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
${CMAKE_CURRENT_BINARY_DIR}/${ofn}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
- COMMENT ""
+ 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})
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn}
- PROPERTIES GENERATED 1)
-endmacro(tablegen)
+ 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)
- # Creates a target for publicly exporting tablegen dependencies.
- if( TABLEGEN_OUTPUT )
- 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")
- endif( TABLEGEN_OUTPUT )
+ 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(CMAKE_CROSSCOMPILING)
@@ -78,23 +91,11 @@ if(CMAKE_CROSSCOMPILING)
endif()
macro(add_tablegen target project)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
-
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
add_llvm_utility(${target} ${ARGN})
set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
- # For Xcode builds, symlink bin/<target> to bin/<Config>/<target> so that
- # a separately-configured Clang project can still find llvm-tblgen.
- if (XCODE)
- add_custom_target(${target}-top ALL
- ${CMAKE_COMMAND} -E create_symlink
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX}
- DEPENDS ${target})
- endif ()
-
set(${project}_TABLEGEN "${target}" CACHE
STRING "Native TableGen executable. Saves building one when cross-compiling.")
@@ -106,7 +107,7 @@ macro(add_tablegen target project)
FORCE)
endif()
endif()
-
+
# Effective tblgen executable to be used:
set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE)
@@ -128,16 +129,14 @@ macro(add_tablegen target project)
endif()
if( MINGW )
- target_link_libraries(${target} imagehlp psapi shell32)
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( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD AND NOT BEOS )
- target_link_libraries(${target} pthread)
- endif()
-
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- install(TARGETS ${target} RUNTIME DESTINATION bin)
+ install(TARGETS ${target}
+ EXPORT LLVMExports
+ RUNTIME DESTINATION bin)
endif()
+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
endmacro()
diff --git a/cmake/nsis_icon.ico b/cmake/nsis_icon.ico
new file mode 100644
index 0000000..9e9e887
--- /dev/null
+++ b/cmake/nsis_icon.ico
Binary files differ
diff --git a/cmake/platforms/Android.cmake b/cmake/platforms/Android.cmake
index 35df5eb..2a6f5a5 100644
--- a/cmake/platforms/Android.cmake
+++ b/cmake/platforms/Android.cmake
@@ -22,7 +22,8 @@ ENDIF()
SET(ANDROID "1" CACHE STRING "ANDROID" FORCE)
-SET(ANDROID_COMMON_FLAGS "-target arm-linux-androideabi --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot -B${LLVM_ANDROID_TOOLCHAIN_DIR} -mllvm -arm-enable-ehabi")
+SET(ANDROID_COMMON_FLAGS "-target arm-linux-androideabi --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot -B${LLVM_ANDROID_TOOLCHAIN_DIR}")
SET(CMAKE_C_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
SET(CMAKE_CXX_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
-SET(CMAKE_LINK_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)
+SET(CMAKE_EXE_LINKER_FLAGS "-pie" CACHE STRING "toolchain_exelinkflags" FORCE)
+