cmake: Don't try to install exports if there aren't any
authorJustin Bogner <mail@justinbogner.com>
Tue, 8 Nov 2016 05:02:18 +0000 (05:02 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 8 Nov 2016 05:02:18 +0000 (05:02 +0000)
When using LLVM_DISTRIBUTION_COMPONENTS, it's possible for LLVM's
export list to be empty. If this happens the install(EXPORTS) command
will fail, but since there isn't anything to install anyway we really
just want to skip it.

llvm-svn: 286209

llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CMakeLists.txt

index 11fa225..e8e119b 100644 (file)
@@ -587,6 +587,7 @@ macro(add_llvm_library name)
       if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
           NOT LLVM_DISTRIBUTION_COMPONENTS)
         set(export_to_llvmexports EXPORT LLVMExports)
+        set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
       endif()
 
       install(TARGETS ${name}
@@ -627,6 +628,7 @@ macro(add_llvm_loadable_module name)
         if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
             NOT LLVM_DISTRIBUTION_COMPONENTS)
           set(export_to_llvmexports EXPORT LLVMExports)
+          set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
         endif()
 
         install(TARGETS ${name}
@@ -811,6 +813,7 @@ macro(add_llvm_tool name)
       if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
           NOT LLVM_DISTRIBUTION_COMPONENTS)
         set(export_to_llvmexports EXPORT LLVMExports)
+        set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
       endif()
 
       install(TARGETS ${name}
index 080c30e..ac4b0b7 100644 (file)
@@ -103,8 +103,11 @@ configure_file(
   @ONLY)
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-  install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
-          COMPONENT cmake-exports)
+  get_property(llvm_has_exports GLOBAL PROPERTY LLVM_HAS_EXPORTS)
+  if(llvm_has_exports)
+    install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
+            COMPONENT cmake-exports)
+  endif()
 
   install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake