From 57c29ad223430da30617a3b673564075754defff Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 21 Jan 2015 21:26:27 +0000 Subject: [PATCH] add_lld_library -> add_llvm_library * Works better for shared libraries (sets PRIVATE instead of INTERFACE) * Fixes http://llvm.org/bugs/show_bug.cgi?id=22269 * Also, use build-target names instead of component names Differential Revision: http://reviews.llvm.org/D7074 From: Greg Fitzgerald llvm-svn: 226702 --- lld/CMakeLists.txt | 54 ------------------------- lld/lib/Config/CMakeLists.txt | 6 +-- lld/lib/Core/CMakeLists.txt | 11 ++--- lld/lib/Driver/CMakeLists.txt | 31 +++++++------- lld/lib/Passes/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/CMakeLists.txt | 13 +++--- lld/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/ELF/ARM/CMakeLists.txt | 8 ++-- lld/lib/ReaderWriter/ELF/CMakeLists.txt | 24 +++++------ lld/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/ELF/Mips/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/ELF/PPC/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/ELF/X86/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/MachO/CMakeLists.txt | 13 +++--- lld/lib/ReaderWriter/Native/CMakeLists.txt | 11 ++--- lld/lib/ReaderWriter/PECOFF/CMakeLists.txt | 13 +++--- lld/lib/ReaderWriter/YAML/CMakeLists.txt | 11 ++--- lld/tools/lld/CMakeLists.txt | 2 +- lld/utils/linker-script-test/CMakeLists.txt | 2 +- 20 files changed, 87 insertions(+), 189 deletions(-) diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index d32287c..436a6f7 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -3,21 +3,6 @@ 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}) @@ -105,45 +90,6 @@ if (MSVC) 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 diff --git a/lld/lib/Config/CMakeLists.txt b/lld/lib/Config/CMakeLists.txt index f749f5d..f7ea042 100644 --- a/lld/lib/Config/CMakeLists.txt +++ b/lld/lib/Config/CMakeLists.txt @@ -1,5 +1,5 @@ -set(LLVM_LINK_COMPONENTS support) - -add_lld_library(lldConfig +add_llvm_library(lldConfig Version.cpp + LINK_LIBS + LLVMSupport ) diff --git a/lld/lib/Core/CMakeLists.txt b/lld/lib/Core/CMakeLists.txt index bbd5bf8..28e50d7 100644 --- a/lld/lib/Core/CMakeLists.txt +++ b/lld/lib/Core/CMakeLists.txt @@ -1,15 +1,10 @@ -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 ) diff --git a/lld/lib/Driver/CMakeLists.txt b/lld/lib/Driver/CMakeLists.txt index 6ff4c59..865e9a0 100644 --- a/lld/lib/Driver/CMakeLists.txt +++ b/lld/lib/Driver/CMakeLists.txt @@ -10,9 +10,7 @@ set(LLVM_TARGET_DEFINITIONS WinLinkOptions.td) 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 @@ -20,21 +18,20 @@ add_lld_library(lldDriver 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 - ) diff --git a/lld/lib/Passes/CMakeLists.txt b/lld/lib/Passes/CMakeLists.txt index f4d9353..367752b 100644 --- a/lld/lib/Passes/CMakeLists.txt +++ b/lld/lib/Passes/CMakeLists.txt @@ -1,11 +1,8 @@ -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 ) diff --git a/lld/lib/ReaderWriter/CMakeLists.txt b/lld/lib/ReaderWriter/CMakeLists.txt index 0751ccf..5aa2c2e 100644 --- a/lld/lib/ReaderWriter/CMakeLists.txt +++ b/lld/lib/ReaderWriter/CMakeLists.txt @@ -4,22 +4,19 @@ add_subdirectory(Native) 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 ) diff --git a/lld/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt index 0864bd4..1578c7f 100644 --- a/lld/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt @@ -1,12 +1,9 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/ARM/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/ARM/CMakeLists.txt index 571928f..35a1f78 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/ARM/CMakeLists.txt @@ -1,10 +1,8 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/CMakeLists.txt index f374a8f..38c4e73 100644 --- a/lld/lib/ReaderWriter/ELF/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/CMakeLists.txt @@ -1,20 +1,18 @@ -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(.) diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt index 59a2b95..7d168c8 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt @@ -1,11 +1,8 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/Mips/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/Mips/CMakeLists.txt index dfb0f81..7878c31 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/Mips/CMakeLists.txt @@ -1,14 +1,11 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/PPC/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/PPC/CMakeLists.txt index 6d16e0c..08b127c 100644 --- a/lld/lib/ReaderWriter/ELF/PPC/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/PPC/CMakeLists.txt @@ -1,10 +1,7 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/X86/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/X86/CMakeLists.txt index f032031..fb1c253 100644 --- a/lld/lib/ReaderWriter/ELF/X86/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/X86/CMakeLists.txt @@ -1,11 +1,8 @@ -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 ) diff --git a/lld/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt index 4f0c4b5..e20aee7 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt +++ b/lld/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt @@ -1,12 +1,9 @@ -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 ) diff --git a/lld/lib/ReaderWriter/MachO/CMakeLists.txt b/lld/lib/ReaderWriter/MachO/CMakeLists.txt index aedde51..95e95ff 100644 --- a/lld/lib/ReaderWriter/MachO/CMakeLists.txt +++ b/lld/lib/ReaderWriter/MachO/CMakeLists.txt @@ -1,6 +1,4 @@ -set(LLVM_LINK_COMPONENTS support) - -add_lld_library(lldMachO +add_llvm_library(lldMachO ArchHandler.cpp ArchHandler_arm.cpp ArchHandler_arm64.cpp @@ -17,11 +15,10 @@ add_lld_library(lldMachO ShimPass.cpp StubsPass.cpp WriterMachO.cpp - ) - -target_link_libraries(lldMachO ${cmake_2_8_12_INTERFACE} - lldReaderWriter - lldPasses + LINK_LIBS + lldReaderWriter + lldPasses + LLVMSupport ) include_directories(.) diff --git a/lld/lib/ReaderWriter/Native/CMakeLists.txt b/lld/lib/ReaderWriter/Native/CMakeLists.txt index 9789823..d02ea78 100644 --- a/lld/lib/ReaderWriter/Native/CMakeLists.txt +++ b/lld/lib/ReaderWriter/Native/CMakeLists.txt @@ -1,10 +1,7 @@ -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 ) diff --git a/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt b/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt index cb98f1a..a37097d 100644 --- a/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt +++ b/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt @@ -1,6 +1,4 @@ -set(LLVM_LINK_COMPONENTS object support) - -add_lld_library(lldPECOFF +add_llvm_library(lldPECOFF EdataPass.cpp IdataPass.cpp LinkerGeneratedSymbolFile.cpp @@ -11,9 +9,8 @@ add_lld_library(lldPECOFF ReaderImportHeader.cpp WriterImportLibrary.cpp WriterPECOFF.cpp - ) - -target_link_libraries(lldPECOFF ${cmake_2_8_12_INTERFACE} - lldReaderWriter - lldDriver + LINK_LIBS + lldReaderWriter + LLVMObject + LLVMSupport ) diff --git a/lld/lib/ReaderWriter/YAML/CMakeLists.txt b/lld/lib/ReaderWriter/YAML/CMakeLists.txt index 1ac4bad..8b071d3 100644 --- a/lld/lib/ReaderWriter/YAML/CMakeLists.txt +++ b/lld/lib/ReaderWriter/YAML/CMakeLists.txt @@ -1,9 +1,6 @@ -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 ) diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt index cb8a102..c0c154a 100644 --- a/lld/tools/lld/CMakeLists.txt +++ b/lld/tools/lld/CMakeLists.txt @@ -1,4 +1,4 @@ -add_lld_executable(lld +add_llvm_executable(lld lld.cpp ) diff --git a/lld/utils/linker-script-test/CMakeLists.txt b/lld/utils/linker-script-test/CMakeLists.txt index dd540a7..2492f10 100644 --- a/lld/utils/linker-script-test/CMakeLists.txt +++ b/lld/utils/linker-script-test/CMakeLists.txt @@ -1,4 +1,4 @@ -add_lld_executable(linker-script-test +add_llvm_executable(linker-script-test linker-script-test.cpp ) -- 2.7.4