@@ -1,10 +1,10 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
cmake_minimum_required (VERSION 2.8.12.2 )
cmake_minimum_required (VERSION 3.4.3 )
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS "No build type selected, default to Debug" )
set (CMAKE_BUILD_TYPE "Debug" )
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)" )
endif ()
if (POLICY CMP0022)
@@ -20,12 +20,6 @@ if (POLICY CMP0051)
cmake_policy (SET CMP0051 OLD )
endif ()
if (CMAKE_VERSION VERSION_LESS 3.1.20141117)
set (cmake_3_2_USES_TERMINAL)
else ()
set (cmake_3_2_USES_TERMINAL USES_TERMINAL )
endif ()
if (NOT DEFINED LLVM_VERSION_MAJOR)
set (LLVM_VERSION_MAJOR 3)
endif ()
@@ -36,7 +30,7 @@ if(NOT DEFINED LLVM_VERSION_PATCH)
set (LLVM_VERSION_PATCH 0)
endif ()
if (NOT DEFINED LLVM_VERSION_SUFFIX)
set (LLVM_VERSION_SUFFIX svn )
set (LLVM_VERSION_SUFFIX "" )
endif ()
if (POLICY CMP0048 )
@@ -56,23 +50,43 @@ project(LLVM
${cmake_3_0_LANGUAGES}
C CXX ASM)
if (APPLE)
if (NOT CMAKE_LIBTOOL)
find_program (CMAKE_LIBTOOL NAMES libtool)
endif ()
if (CMAKE_LIBTOOL)
set (CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable" )
message (STATUS "Found libtool - ${CMAKE_LIBTOOL} " )
get_property (languages GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach (lang ${languages} )
set (CMAKE_${lang} _CREATE_STATIC_LIBRARY
"${CMAKE_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> " )
endforeach ()
endif ()
endif ()
# The following only works with the Ninja generator in CMake >= 3.0.
set (LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
"Define the maximum number of concurrent compilation jobs." )
if (LLVM_PARALLEL_COMPILE_JOBS)
if (CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja" )
message (WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later ." )
if (NOT CMAKE_MAKE_PROGRAM MATCHES "ninja" )
message (WARNING "Job pooling is only available with Ninja generators." )
else ()
set_property (GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${LLVM_PARALLEL_COMPILE_JOBS} )
set (CMAKE_JOB_POOL_COMPILE compile_job_pool)
endif ()
endif ()
set (LLVM_BUILD_GLOBAL_ISEL OFF CACHE BOOL "Experimental: Build GlobalISel" )
if (LLVM_BUILD_GLOBAL_ISEL)
add_definitions (-DLLVM_BUILD_GLOBAL_ISEL)
endif ()
set (LLVM_PARALLEL_LINK_JOBS "" CACHE STRING
"Define the maximum number of concurrent link jobs." )
if (LLVM_PARALLEL_LINK_JOBS)
if (CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja" )
message (WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later ." )
if (NOT CMAKE_MAKE_PROGRAM MATCHES "ninja" )
message (WARNING "Job pooling is only available with Ninja generators." )
else ()
set_property (GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${LLVM_PARALLEL_LINK_JOBS} )
set (CMAKE_JOB_POOL_LINK link_job_pool)
@@ -181,6 +195,9 @@ endif()
set (LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
set (LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')" )
mark_as_advanced (LLVM_TOOLS_INSTALL_DIR)
# They are used as destination of target generators.
set (LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR} /bin)
set (LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR} /lib${LLVM_LIBDIR_SUFFIX} )
@@ -206,7 +223,6 @@ set(LLVM_ALL_TARGETS
AMDGPU
ARM
BPF
CppBackend
Hexagon
JSBackend # @LOCALMOD
Mips
@@ -231,11 +247,6 @@ set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
option (BUILD_SHARED_LIBS
"Build all libraries as shared libraries instead of static" OFF )
option (LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON )
if (LLVM_ENABLE_TIMESTAMPS)
set (ENABLE_TIMESTAMPS 1)
endif ()
option (LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON )
if (LLVM_ENABLE_BACKTRACES)
set (ENABLE_BACKTRACES 1)
@@ -273,6 +284,13 @@ include(AddLLVMDefinitions)
option (LLVM_ENABLE_PIC "Build Position-Independent Code" ON )
option (LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON )
option (LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF )
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
option (LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON )
option (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." OFF )
else ()
option (LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF )
option (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON )
endif ()
option (LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF )
option (LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF )
option (LLVM_ENABLE_LIBCXXABI "Use libc++abi when using libc++." OFF )
@@ -285,6 +303,8 @@ else()
option (LLVM_ENABLE_ASSERTIONS "Enable assertions" ON )
endif ()
option (LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF )
set (LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF." )
@@ -322,8 +342,26 @@ set(LLVM_USE_SANITIZER "" CACHE STRING
option (LLVM_USE_SPLIT_DWARF
"Use -gsplit-dwarf when compiling llvm." OFF )
option (WITH_POLLY "Build LLVM with Polly" ON )
option (LINK_POLLY_INTO_TOOLS "Static link Polly into tools" OFF )
option (LLVM_POLLY_LINK_INTO_TOOLS "Statically link Polly into tools (if available)" ON )
option (LLVM_POLLY_BUILD "Build LLVM with Polly" ON )
if (EXISTS ${LLVM_MAIN_SRC_DIR} /tools/polly/CMakeLists.txt)
set (POLLY_IN_TREE TRUE)
else ()
set (POLLY_IN_TREE FALSE )
endif ()
if (LLVM_POLLY_BUILD AND POLLY_IN_TREE)
set (WITH_POLLY ON )
else ()
set (WITH_POLLY OFF )
endif ()
if (LLVM_POLLY_LINK_INTO_TOOLS AND WITH_POLLY)
set (LINK_POLLY_INTO_TOOLS ON )
else ()
set (LINK_POLLY_INTO_TOOLS OFF )
endif ()
# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
@@ -354,6 +392,8 @@ option(LLVM_BUILD_TOOLS
"Build the LLVM tools. If OFF, just generate build targets." ON )
option (LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON )
option (LLVM_BUILD_UTILS
"Build LLVM utility binaries. If OFF, just generate build targets." ON )
option (LLVM_BUILD_RUNTIME
"Build the LLVM runtime libraries." ON )
@@ -388,25 +428,42 @@ if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set (LLVM_BUILD_LLVM_DYLIB_default ON )
endif ()
option (LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default} )
set (LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT ON )
if (LLVM_LINK_LLVM_DYLIB)
set (LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT OFF )
endif ()
option (LLVM_DISABLE_LLVM_DYLIB_ATEXIT "Disable llvm-shlib's atexit destructors." ${LLVM_DISABLE_LLVM_DYLIB_ATEXIT_DEFAULT} )
if (LLVM_DISABLE_LLVM_DYLIB_ATEXIT)
set (DISABLE_LLVM_DYLIB_ATEXIT 1)
endif ()
option (LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF )
if (CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND LLVM_ENABLE_ASSERTIONS))
set (LLVM_USE_HOST_TOOLS ON )
endif ()
if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
option (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
else ()
set (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\ Visual Studio 2013\\ Visualizers" FORCE )
endif ()
if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE)
if (NOT LLVM_PROFILE_MERGE_POOL_SIZE)
# A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
# for spining disks. Anything higher may only help on slower mediums.
set (LLVM_PROFILE_MERGE_POOL_SIZE "4" )
endif ()
if (NOT LLVM_PROFILE_FILE_PATTERN)
if (NOT LLVM_PROFILE_DATA_DIR)
set (LLVM_PROFILE_FILE_PATTERN "%${LLVM_PROFILE_MERGE_POOL_SIZE} m.profraw" )
else ()
file (TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR} /%${LLVM_PROFILE_MERGE_POOL_SIZE} m.profraw" LLVM_PROFILE_FILE_PATTERN)
endif ()
endif ()
endif ()
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
include (config-ix)
string (REPLACE "Native" ${LLVM_NATIVE_ARCH}
LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD} " )
list (REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
# By default, we target the host, but this can be overridden at CMake
# invocation time.
set (LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE} " CACHE STRING
@@ -646,6 +703,15 @@ add_subdirectory(lib/TableGen)
add_subdirectory (utils/TableGen)
# Force target to be built as soon as possible. Clang modules builds depend
# header-wise on it as they ship all headers from the umbrella folders. Building
# an entire module might include header, which depends on intrinsics_gen. This
# should be right after LLVMSupport and LLVMTableGen otherwise we introduce a
# circular dependence.
if (LLVM_ENABLE_MODULES)
list (APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
endif (LLVM_ENABLE_MODULES)
add_subdirectory (include/llvm)
add_subdirectory (lib)
@@ -664,6 +730,11 @@ else()
endif ()
endif ()
# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
add_subdirectory (utils/LLVMVisualizers)
endif ()
if (LLVM_INCLUDE_TESTS)
add_subdirectory (utils/unittest)
endif ()
@@ -676,16 +747,12 @@ endforeach()
add_subdirectory (projects)
if (WITH_POLLY)
if (NOT EXISTS ${LLVM_MAIN_SRC_DIR} /tools/polly/CMakeLists.txt)
set (WITH_POLLY OFF )
endif ()
endif (WITH_POLLY)
if ( LLVM_INCLUDE_TOOLS )
add_subdirectory (tools)
endif ()
add_subdirectory (runtimes)
if ( LLVM_INCLUDE_EXAMPLES )
add_subdirectory (examples)
endif ()
@@ -696,7 +763,8 @@ if( LLVM_INCLUDE_TESTS )
llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR} /projects/test-suite
USE_TOOLCHAIN
EXCLUDE_FROM_ALL
NO_INSTALL)
NO_INSTALL
ALWAYS_CLEAN)
endif ()
add_subdirectory (test)
add_subdirectory (unittests)
@@ -719,6 +787,8 @@ if( LLVM_INCLUDE_TESTS )
DEPENDS ${LLVM_LIT_DEPENDS}
ARGS ${LLVM_LIT_EXTRA_ARGS}
)
add_custom_target (test-depends DEPENDS ${LLVM_LIT_DEPENDS} )
set_target_properties (test-depends PROPERTIES FOLDER "Tests" )
endif ()
if (LLVM_INCLUDE_DOCS)
@@ -762,3 +832,27 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-P "${CMAKE_BINARY_DIR} /cmake_install.cmake" )
endif ()
endif ()
# This must be at the end of the LLVM root CMakeLists file because it must run
# after all targets are created.
if (LLVM_DISTRIBUTION_COMPONENTS)
if (CMAKE_CONFIGURATION_TYPES)
message (FATAL_ERROR "LLVM_DISTRIBUTION_COMPONENTS cannot be specified with multi-configuration generators (i.e. Xcode or Visual Studio)" )
endif ()
add_custom_target (distribution)
add_custom_target (install-distribution)
foreach (target ${LLVM_DISTRIBUTION_COMPONENTS} )
if (TARGET ${target} )
add_dependencies (distribution ${target} )
else ()
message (FATAL_ERROR "Specified distribution component '${target} ' doesn't have a target" )
endif ()
if (TARGET install-${target} )
add_dependencies (install-distribution install-${target} )
else ()
message (FATAL_ERROR "Specified distribution component '${target} ' doesn't have an install target" )
endif ()
endforeach ()
endif ()
0 comments on commit
7edfb84