forked from OSchip/llvm-project
[CMake] Make llvm_ExternalProject always call the build action
This makes it so that when running 'ninja test-suite' from the top-level LLVM ninja build it *always* re-runs the ninja command in the test-suite directory. This mechanism is required because the top-level ninja file doesn't have a view into the subdirectory dependency tree, so it can't know what, if anything, needs to be rebuilt. llvm-svn: 265863
This commit is contained in:
parent
826824ea3d
commit
79c68d52b1
|
@ -2,12 +2,12 @@ include(ExternalProject)
|
||||||
|
|
||||||
# llvm_ExternalProject_BuildCmd(out_var target)
|
# llvm_ExternalProject_BuildCmd(out_var target)
|
||||||
# Utility function for constructing command lines for external project targets
|
# Utility function for constructing command lines for external project targets
|
||||||
function(llvm_ExternalProject_BuildCmd out_var target)
|
function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
|
||||||
if (CMAKE_GENERATOR MATCHES "Make")
|
if (CMAKE_GENERATOR MATCHES "Make")
|
||||||
# Use special command for Makefiles to support parallelism.
|
# Use special command for Makefiles to support parallelism.
|
||||||
set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
|
set(${out_var} "$(MAKE)" "-C" "${BINARY_DIR}" "${target}" PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
|
set(${out_var} ${CMAKE_COMMAND} --build ${bin_dir} --target ${target}
|
||||||
--config $<CONFIGURATION> PARENT_SCOPE)
|
--config $<CONFIGURATION> PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -63,6 +63,7 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
|
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
|
||||||
set(cmake_3_1_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL 1)
|
set(cmake_3_1_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL 1)
|
||||||
|
set(cmake_3_1_BUILD_ALWAYS BUILD_ALWAYS 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
|
if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
|
||||||
|
@ -138,14 +139,21 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||||
${PASSTHROUGH_VARIABLES}
|
${PASSTHROUGH_VARIABLES}
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
STEP_TARGETS configure build
|
STEP_TARGETS configure build
|
||||||
|
${cmake_3_1_BUILD_ALWAYS}
|
||||||
${cmake_3_4_USES_TERMINAL_OPTIONS}
|
${cmake_3_4_USES_TERMINAL_OPTIONS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ARG_USE_TOOLCHAIN)
|
if(CMAKE_VERSION VERSION_LESS 3.1.0)
|
||||||
|
set(ALWAYS_REBUILD ${CMAKE_CURRENT_BINARY_DIR}/${name}-always-rebuild)
|
||||||
|
add_custom_target(${name}-always-rebuild
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_DIR}/${name}-clobber-stamp)
|
||||||
|
|
||||||
|
llvm_ExternalProject_BuildCmd(run_build all ${BINARY_DIR})
|
||||||
ExternalProject_Add_Step(${name} force-rebuild
|
ExternalProject_Add_Step(${name} force-rebuild
|
||||||
COMMENT "Forcing rebuild becaues tools have changed"
|
COMMAND ${run_build}
|
||||||
DEPENDERS configure
|
COMMENT "Forcing rebuild of ${name}"
|
||||||
DEPENDS ${TOOLCHAIN_BINS}
|
DEPENDEES configure clean
|
||||||
|
DEPENDS ${ALWAYS_REBUILD} ${ARG_DEPENDS} ${TOOLCHAIN_BINS}
|
||||||
${cmake_3_4_USES_TERMINAL} )
|
${cmake_3_4_USES_TERMINAL} )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -153,7 +161,7 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||||
set(force_deps DEPENDS ${TOOLCHAIN_BINS})
|
set(force_deps DEPENDS ${TOOLCHAIN_BINS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
llvm_ExternalProject_BuildCmd(run_clean clean)
|
llvm_ExternalProject_BuildCmd(run_clean clean ${BINARY_DIR})
|
||||||
ExternalProject_Add_Step(${name} clean
|
ExternalProject_Add_Step(${name} clean
|
||||||
COMMAND ${run_clean}
|
COMMAND ${run_clean}
|
||||||
COMMENT "Cleaning ${name}..."
|
COMMENT "Cleaning ${name}..."
|
||||||
|
@ -184,7 +192,7 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||||
|
|
||||||
# Add top-level targets
|
# Add top-level targets
|
||||||
foreach(target ${ARG_EXTRA_TARGETS})
|
foreach(target ${ARG_EXTRA_TARGETS})
|
||||||
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target})
|
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target} ${BINARY_DIR})
|
||||||
add_custom_target(${target}
|
add_custom_target(${target}
|
||||||
COMMAND ${build_runtime_cmd}
|
COMMAND ${build_runtime_cmd}
|
||||||
DEPENDS ${name}-configure
|
DEPENDS ${name}-configure
|
||||||
|
|
Loading…
Reference in New Issue