From: Chris Bieneman Date: Tue, 19 Jan 2016 22:41:51 +0000 (+0000) Subject: [CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate insta... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f1b3a21152c2a7db3c8949b8a8247510eb46948;p=clang [CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate install actions and targets. This change brings forward the LLVM convention that "executables" are just runnable binaries, and "tools" are executables that are part of the project's install. Having this abstraction will allow us to simplify some of the tool CMakeLists files, and it will standardize some of the install behaviors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258209 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 861fa964f2..272c80eaf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -444,6 +444,22 @@ macro(add_clang_executable name) set_clang_windows_version_resource_properties(${name}) endmacro(add_clang_executable) +macro(add_clang_tool name) + add_clang_executable(${name} ${ARGN}) + install(TARGETS ${name} + EXPORT ClangTargets + RUNTIME DESTINATION bin + COMPONENT ${name}) + + if(NOT CMAKE_CONFIGURATION_TYPES) + add_custom_target(install-${name} + DEPENDS ${name} + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=${name} + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + endif() +endmacro() + macro(add_clang_symlink name dest) add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) # Always generate install targets diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index fca9b61675..ffcfbb505a 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -24,7 +24,7 @@ if(CLANG_PLUGIN_SUPPORT) set(LLVM_NO_DEAD_STRIP 1) endif() -add_clang_executable(clang +add_clang_tool(clang driver.cpp cc1_main.cpp cc1as_main.cpp @@ -51,18 +51,6 @@ endif() add_dependencies(clang clang-headers) -install(TARGETS clang - RUNTIME DESTINATION bin - COMPONENT clang) - -if(NOT CMAKE_CONFIGURATION_TYPES) - add_custom_target(install-clang - DEPENDS clang - COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=clang - -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") -endif() - if(NOT CLANG_LINKS_TO_CREATE) set(CLANG_LINKS_TO_CREATE clang++ clang-cl)