OSDN Git Service

[cmake] Remove redundant call to cmake when building host tools.
authorDon Hinton <hintonda@gmail.com>
Tue, 28 Nov 2017 16:08:57 +0000 (16:08 +0000)
committerDon Hinton <hintonda@gmail.com>
Tue, 28 Nov 2017 16:08:57 +0000 (16:08 +0000)
Summary:
Remove the redundant, config-time call to cmake when
building host tools for cross compiles or optimized tablegen..

The config-time call to cmake is redundant because it will always get
called again when the CONFIGURE_LLVM_${target_name} target fires at
build-time.  This speeds up initial configuration, but has no affect
on build behavior.

Reviewers: beanz

Reviewed By: beanz

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D40229

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319176 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/CrossCompile.cmake

index ff092b2..8f9e613 100644 (file)
@@ -12,6 +12,14 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
         CACHE STRING "Toolchain file for ${target_name}")
   endif()
 
+  if (buildtype)
+    set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
+  endif()
+  if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
+    # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
+    set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
+  endif()
+
   add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}
     COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_${target_name}_BUILD}
     COMMENT "Creating ${LLVM_${target_name}_BUILD}...")
@@ -23,6 +31,8 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
     COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
         ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
         -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
+        -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
+        ${build_type_flags} ${external_clang_dir}
     WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
     DEPENDS CREATE_LLVM_${target_name}
     COMMENT "Configuring ${target_name} LLVM...")
@@ -30,32 +40,6 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
   add_custom_target(CONFIGURE_LLVM_${target_name}
                     DEPENDS ${LLVM_${target_name}_BUILD}/CMakeCache.txt)
 
-  set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
-                                      ${LLVM_${target_name}_BUILD})
-
-  if(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
-    
-
-    message(STATUS "Configuring ${target_name} build...")
-    execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
-      ${LLVM_${target_name}_BUILD} )
-
-    message(STATUS "Configuring ${target_name} targets...")
-    if (buildtype)
-      set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
-    endif()
-       if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
-         # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
-         set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
-       endif()
-    execute_process(COMMAND ${CMAKE_COMMAND} ${build_type_flags}
-        -G "${CMAKE_GENERATOR}" -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
-        ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
-        -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
-        ${external_clang_dir}
-      WORKING_DIRECTORY ${LLVM_${target_name}_BUILD} )
-  endif(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
-
 endfunction()
 
 function(llvm_create_cross_target target_name sysroot)