llvm.org GIT mirror llvm / f4f3881
[cmake] Re-commit: Remove redundant call to cmake when building host tools. Also pass CMAKE_(C|CXX)_COMPILER to add_custom_command. 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. Differential Revision: https://reviews.llvm.org/D40229 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319620 91177308-0d34-0410-b5e6-96231b3b80d8 Don Hinton 1 year, 10 months ago
1 changed file(s) with 15 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
1111 CACHE STRING "Toolchain file for ${target_name}")
1212 endif()
1313
14 if (buildtype)
15 set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
16 endif()
17 if (LLVM_USE_LINKER AND NOT CMAKE_CROSSCOMPILING)
18 set(linker_flag "-DLLVM_USE_LINKER=${LLVM_USE_LINKER}")
19 endif()
20 if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
21 # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
22 set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
23 endif()
24
1425 add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}
1526 COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_${target_name}_BUILD}
1627 COMMENT "Creating ${LLVM_${target_name}_BUILD}...")
2233 COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
2334 ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
2435 -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
36 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
37 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
38 -DLLVM_TARGETS_TO_BUILD=Native
39 ${build_type_flags} ${linker_flag} ${external_clang_dir}
2540 WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
2641 DEPENDS CREATE_LLVM_${target_name}
2742 COMMENT "Configuring ${target_name} LLVM...")
2843
2944 add_custom_target(CONFIGURE_LLVM_${target_name}
3045 DEPENDS ${LLVM_${target_name}_BUILD}/CMakeCache.txt)
31
32 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
33 ${LLVM_${target_name}_BUILD})
34
35 if(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
36
37 message(STATUS "Configuring ${target_name} build...")
38 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
39 ${LLVM_${target_name}_BUILD} )
40
41 message(STATUS "Configuring ${target_name} targets...")
42 if (buildtype)
43 set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
44 endif()
45 if (LLVM_USE_LINKER AND NOT CMAKE_CROSSCOMPILING)
46 set(linker_flag "-DLLVM_USE_LINKER=${LLVM_USE_LINKER}")
47 endif()
48 if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
49 # Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
50 set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
51 endif()
52 execute_process(COMMAND ${CMAKE_COMMAND} ${build_type_flags}
53 -G "${CMAKE_GENERATOR}" -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
54 ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
55 -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
56 ${external_clang_dir} ${linker_flag}
57 WORKING_DIRECTORY ${LLVM_${target_name}_BUILD} )
58 endif(NOT IS_DIRECTORY ${LLVM_${target_name}_BUILD})
5946
6047 endfunction()
6148