1 set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
3 set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
5 # Compute the LLD version from the LLVM version.
6 string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION
8 message(STATUS "LLD version: ${LLD_VERSION}")
10 string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" LLD_VERSION_MAJOR
12 string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" LLD_VERSION_MINOR
15 # Determine LLD revision and repository.
16 # TODO: Figure out a way to get the revision and the repository on windows.
17 if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
18 execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetSourceVersion ${LLD_SOURCE_DIR}
19 OUTPUT_VARIABLE LLD_REVISION)
21 execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetRepositoryPath ${LLD_SOURCE_DIR}
22 OUTPUT_VARIABLE LLD_REPOSITORY)
24 # Replace newline characters with spaces
25 string(REGEX REPLACE "(\r?\n)+" " " LLD_REPOSITORY ${LLD_REPOSITORY})
26 # Remove leading spaces
27 STRING(REGEX REPLACE "^[ \t\r\n]+" "" LLD_REPOSITORY "${LLD_REPOSITORY}" )
28 # Remove trailing spaces
29 string(REGEX REPLACE "(\ )+$" "" LLD_REPOSITORY ${LLD_REPOSITORY})
33 # Replace newline characters with spaces
34 string(REGEX REPLACE "(\r?\n)+" " " LLD_REVISION ${LLD_REVISION})
35 # Remove leading spaces
36 STRING(REGEX REPLACE "^[ \t\r\n]+" "" LLD_REVISION "${LLD_REVISION}" )
37 # Remove trailing spaces
38 string(REGEX REPLACE "(\ )+$" "" LLD_REVISION ${LLD_REVISION})
42 # Configure the Version.inc file.
44 ${CMAKE_CURRENT_SOURCE_DIR}/include/lld/Config/Version.inc.in
45 ${CMAKE_CURRENT_BINARY_DIR}/include/lld/Config/Version.inc)
48 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
49 message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
50 "the makefiles distributed with LLVM. Please create a directory and run cmake "
51 "from there, passing the path to this source directory as the last argument. "
52 "This process created the file `CMakeCache.txt' and the directory "
53 "`CMakeFiles'. Please delete them.")
56 list (APPEND CMAKE_MODULE_PATH "${LLD_SOURCE_DIR}/cmake/modules")
59 "Enable VTune user task tracking."
64 include_directories(${VTune_INCLUDE_DIRS})
65 list(APPEND LLVM_COMMON_LIBS ${VTune_LIBRARIES})
66 add_definitions(-DLLD_HAS_VTUNE)
72 add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
73 add_definitions(-wd4062) # Suppress 'warning C4062: enumerator X in switch of enum Y is not handled' from system header.
76 include_directories(BEFORE
77 ${CMAKE_CURRENT_BINARY_DIR}/include
78 ${CMAKE_CURRENT_SOURCE_DIR}/include
81 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
82 install(DIRECTORY include/
86 PATTERN ".svn" EXCLUDE
90 macro(add_lld_library name)
91 add_llvm_library(${name} ${ARGN})
92 set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
93 endmacro(add_lld_library)
97 add_subdirectory(tools/lld)
99 if (LLVM_INCLUDE_TESTS)
100 add_subdirectory(test)
101 add_subdirectory(unittests)
104 add_subdirectory(docs)
105 add_subdirectory(COFF)
106 add_subdirectory(ELF)