]> granicus.if.org Git - clang/commitdiff
[CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate insta...
authorChris Bieneman <beanz@apple.com>
Tue, 19 Jan 2016 22:41:51 +0000 (22:41 +0000)
committerChris Bieneman <beanz@apple.com>
Tue, 19 Jan 2016 22:41:51 +0000 (22:41 +0000)
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

CMakeLists.txt
tools/driver/CMakeLists.txt

index 861fa964f22ff61dd12d1abb943c68c5f3977b4f..272c80eaf3955feb03214de68403ca176261c540 100644 (file)
@@ -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
index fca9b616751bad832aaea2f68fcb042dd536c3df..ffcfbb505ae391fb48101c60a9c8a663b3a4da85 100644 (file)
@@ -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)