r258209 - [CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate install actions and targets.

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 14:41:51 PST 2016


Author: cbieneman
Date: Tue Jan 19 16:41:51 2016
New Revision: 258209

URL: http://llvm.org/viewvc/llvm-project?rev=258209&view=rev
Log:
[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.

Modified:
    cfe/trunk/CMakeLists.txt
    cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=258209&r1=258208&r2=258209&view=diff
==============================================================================
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Jan 19 16:41:51 2016
@@ -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

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=258209&r1=258208&r2=258209&view=diff
==============================================================================
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Tue Jan 19 16:41:51 2016
@@ -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)
 




More information about the cfe-commits mailing list