cmake_minimum_required(VERSION 2.8)
-# FIXME: It may be removed when we use 2.8.12.
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
- # Invalidate a couple of keywords.
- set(cmake_2_8_12_INTERFACE)
- set(cmake_2_8_12_PRIVATE)
-else()
- # Use ${cmake_2_8_12_KEYWORD} intead of KEYWORD in target_link_libraries().
- set(cmake_2_8_12_INTERFACE INTERFACE)
- set(cmake_2_8_12_PRIVATE PRIVATE)
- if(POLICY CMP0022)
- cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
- endif()
-endif()
-
-
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
endif()
-macro(add_lld_library name)
- llvm_process_sources(srcs ${ARGN})
- if (MSVC_IDE OR XCODE)
- string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
- list(GET split_path -1 dir)
- file(GLOB_RECURSE headers
- ../../include/lld${dir}/*.h)
- set(srcs ${srcs} ${headers})
- endif()
- if (MODULE)
- set(libkind MODULE)
- elseif (SHARED_LIBRARY)
- set(libkind SHARED)
- else()
- set(libkind)
- endif()
- add_library(${name} ${libkind} ${srcs})
- llvm_update_compile_flags(${name} ${srcs})
- if (LLVM_COMMON_DEPENDS)
- add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
- endif()
-
- target_link_libraries(${name} ${LLVM_USED_LIBS})
- llvm_config(${name} ${LLVM_LINK_COMPONENTS})
- target_link_libraries(${name} ${LLVM_COMMON_LIBS})
-
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- install(TARGETS ${name}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
- endif()
- set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
-endmacro(add_lld_library)
-
-macro(add_lld_executable name)
- add_llvm_executable(${name} ${ARGN})
- set_target_properties(${name} PROPERTIES FOLDER "lld executables")
-endmacro(add_lld_executable)
-
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldConfig
+add_llvm_library(lldConfig
Version.cpp
+ LINK_LIBS
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldCore
+add_llvm_library(lldCore
DefinedAtom.cpp
Error.cpp
File.cpp
LinkingContext.cpp
Resolver.cpp
SymbolTable.cpp
- )
-
-target_link_libraries(lldCore ${cmake_2_8_12_INTERFACE}
- lldNative
- lldYAML
+ LINK_LIBS
+ LLVMSupport
)
tablegen(LLVM WinLinkOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(DriverOptionsTableGen)
-set(LLVM_LINK_COMPONENTS object option support)
-
-add_lld_library(lldDriver
+add_llvm_library(lldDriver
CoreDriver.cpp
DarwinLdDriver.cpp
Driver.cpp
UniversalDriver.cpp
WinLinkDriver.cpp
WinLinkModuleDef.cpp
+ LINK_LIBS
+ lldConfig
+ lldPasses
+ lldMachO
+ lldPECOFF
+ lldELF
+ lldCore
+ lldNative
+ lldReaderWriter
+ lldYAML
+ LLVMObject
+ LLVMOption
+ LLVMSupport
)
add_dependencies(lldDriver DriverOptionsTableGen)
-target_link_libraries(lldDriver ${cmake_2_8_12_INTERFACE}
- lldConfig
- lldPasses
- lldMachO
- lldPECOFF
- lldELF
- lldCore
- lldNative
- lldReaderWriter
- lldYAML
- LLVMObject
- LLVMOption
- LLVMSupport
- )
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldPasses
+add_llvm_library(lldPasses
LayoutPass.cpp
RoundTripNativePass.cpp
RoundTripYAMLPass.cpp
- )
-
-target_link_libraries(lldPasses ${cmake_2_8_12_INTERFACE}
- lldReaderWriter
+ LINK_LIBS
+ lldReaderWriter
+ LLVMSupport
)
add_subdirectory(PECOFF)
add_subdirectory(YAML)
-set(LLVM_LINK_COMPONENTS object support)
-
if (MSVC)
add_definitions(-wd4062) # Suppress 'warning C4062: Enumerator has no associated handler in a switch statement.'
endif()
-add_lld_library(lldReaderWriter
+add_llvm_library(lldReaderWriter
CoreLinkingContext.cpp
FileArchive.cpp
LinkerScript.cpp
Reader.cpp
Writer.cpp
FileArchive.cpp
- )
-
-target_link_libraries(lldReaderWriter ${cmake_2_8_12_INTERFACE}
- lldCore
- lldPasses
+ LINK_LIBS
+ lldCore
+ LLVMObject
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldAArch64ELFTarget
+add_llvm_library(lldAArch64ELFTarget
AArch64LinkingContext.cpp
AArch64TargetHandler.cpp
AArch64RelocationHandler.cpp
AArch64RelocationPass.cpp
- )
-
-target_link_libraries(lldAArch64ELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-add_lld_library(lldARMELFTarget
+add_llvm_library(lldARMELFTarget
ARMLinkingContext.cpp
ARMTargetHandler.cpp
ARMRelocationHandler.cpp
ARMRelocationPass.cpp
- )
-
-target_link_libraries(lldARMELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
)
-add_lld_library(lldELF
+add_llvm_library(lldELF
ArrayOrderPass.cpp
ELFLinkingContext.cpp
Reader.cpp
Writer.cpp
- )
-
-target_link_libraries(lldELF ${cmake_2_8_12_INTERFACE}
- lldHexagonELFTarget
- lldMipsELFTarget
- lldPPCELFTarget
- lldPasses
- lldReaderWriter
- lldX86ELFTarget
- lldX86_64ELFTarget
- lldAArch64ELFTarget
- lldARMELFTarget
+ LINK_LIBS
+ lldHexagonELFTarget
+ lldMipsELFTarget
+ lldPPCELFTarget
+ lldPasses
+ lldReaderWriter
+ lldX86ELFTarget
+ lldX86_64ELFTarget
+ lldAArch64ELFTarget
+ lldARMELFTarget
)
include_directories(.)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldHexagonELFTarget
+add_llvm_library(lldHexagonELFTarget
HexagonLinkingContext.cpp
HexagonRelocationHandler.cpp
HexagonTargetHandler.cpp
- )
-
-target_link_libraries(lldHexagonELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldMipsELFTarget
+add_llvm_library(lldMipsELFTarget
MipsCtorsOrderPass.cpp
MipsELFFlagsMerger.cpp
MipsLinkingContext.cpp
MipsRelocationHandler.cpp
MipsRelocationPass.cpp
MipsTargetHandler.cpp
- )
-
-target_link_libraries(lldMipsELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldPPCELFTarget
+add_llvm_library(lldPPCELFTarget
PPCLinkingContext.cpp
PPCTargetHandler.cpp
- )
-
-target_link_libraries(lldPPCELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldX86ELFTarget
+add_llvm_library(lldX86ELFTarget
X86LinkingContext.cpp
X86TargetHandler.cpp
X86RelocationHandler.cpp
- )
-
-target_link_libraries(lldX86ELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldX86_64ELFTarget
+add_llvm_library(lldX86_64ELFTarget
X86_64LinkingContext.cpp
X86_64TargetHandler.cpp
X86_64RelocationHandler.cpp
X86_64RelocationPass.cpp
- )
-
-target_link_libraries(lldX86_64ELFTarget ${cmake_2_8_12_INTERFACE}
- lldCore
+ LINK_LIBS
+ lldCore
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldMachO
+add_llvm_library(lldMachO
ArchHandler.cpp
ArchHandler_arm.cpp
ArchHandler_arm64.cpp
ShimPass.cpp
StubsPass.cpp
WriterMachO.cpp
- )
-
-target_link_libraries(lldMachO ${cmake_2_8_12_INTERFACE}
- lldReaderWriter
- lldPasses
+ LINK_LIBS
+ lldReaderWriter
+ lldPasses
+ LLVMSupport
)
include_directories(.)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldNative
+add_llvm_library(lldNative
ReaderNative.cpp
WriterNative.cpp
- )
-
-target_link_libraries(lldNative ${cmake_2_8_12_INTERFACE}
- lldReaderWriter
+ LINK_LIBS
+ lldReaderWriter
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS object support)
-
-add_lld_library(lldPECOFF
+add_llvm_library(lldPECOFF
EdataPass.cpp
IdataPass.cpp
LinkerGeneratedSymbolFile.cpp
ReaderImportHeader.cpp
WriterImportLibrary.cpp
WriterPECOFF.cpp
- )
-
-target_link_libraries(lldPECOFF ${cmake_2_8_12_INTERFACE}
- lldReaderWriter
- lldDriver
+ LINK_LIBS
+ lldReaderWriter
+ LLVMObject
+ LLVMSupport
)
-set(LLVM_LINK_COMPONENTS support)
-
-add_lld_library(lldYAML
+add_llvm_library(lldYAML
ReaderWriterYAML.cpp
- )
-
-target_link_libraries(lldYAML ${cmake_2_8_12_INTERFACE}
- lldReaderWriter
+ LINK_LIBS
+ lldReaderWriter
+ LLVMSupport
)
-add_lld_executable(lld
+add_llvm_executable(lld
lld.cpp
)
-add_lld_executable(linker-script-test
+add_llvm_executable(linker-script-test
linker-script-test.cpp
)