llvm.org GIT mirror llvm / 908d3d5
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265863 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 4 years ago
1 changed file(s) with 17 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
11
22 # llvm_ExternalProject_BuildCmd(out_var target)
33 # Utility function for constructing command lines for external project targets
4 function(llvm_ExternalProject_BuildCmd out_var target)
4 function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
55 if (CMAKE_GENERATOR MATCHES "Make")
66 # Use special command for Makefiles to support parallelism.
7 set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
7 set(${out_var} "$(MAKE)" "-C" "${BINARY_DIR}" "${target}" PARENT_SCOPE)
88 else()
9 set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
9 set(${out_var} ${CMAKE_COMMAND} --build ${bin_dir} --target ${target}
1010 --config $ PARENT_SCOPE)
1111 endif()
1212 endfunction()
6262
6363 if(CMAKE_VERSION VERSION_GREATER 3.1.0)
6464 set(cmake_3_1_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL 1)
65 set(cmake_3_1_BUILD_ALWAYS BUILD_ALWAYS 1)
6566 endif()
6667
6768 if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
137138 ${PASSTHROUGH_VARIABLES}
138139 INSTALL_COMMAND ""
139140 STEP_TARGETS configure build
141 ${cmake_3_1_BUILD_ALWAYS}
140142 ${cmake_3_4_USES_TERMINAL_OPTIONS}
141143 )
142144
143 if(ARG_USE_TOOLCHAIN)
145 if(CMAKE_VERSION VERSION_LESS 3.1.0)
146 set(ALWAYS_REBUILD ${CMAKE_CURRENT_BINARY_DIR}/${name}-always-rebuild)
147 add_custom_target(${name}-always-rebuild
148 COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_DIR}/${name}-clobber-stamp)
149
150 llvm_ExternalProject_BuildCmd(run_build all ${BINARY_DIR})
144151 ExternalProject_Add_Step(${name} force-rebuild
145 COMMENT "Forcing rebuild becaues tools have changed"
146 DEPENDERS configure
147 DEPENDS ${TOOLCHAIN_BINS}
152 COMMAND ${run_build}
153 COMMENT "Forcing rebuild of ${name}"
154 DEPENDEES configure clean
155 DEPENDS ${ALWAYS_REBUILD} ${ARG_DEPENDS} ${TOOLCHAIN_BINS}
148156 ${cmake_3_4_USES_TERMINAL} )
149157 endif()
150158
152160 set(force_deps DEPENDS ${TOOLCHAIN_BINS})
153161 endif()
154162
155 llvm_ExternalProject_BuildCmd(run_clean clean)
163 llvm_ExternalProject_BuildCmd(run_clean clean ${BINARY_DIR})
156164 ExternalProject_Add_Step(${name} clean
157165 COMMAND ${run_clean}
158166 COMMENT "Cleaning ${name}..."
183191
184192 # Add top-level targets
185193 foreach(target ${ARG_EXTRA_TARGETS})
186 llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target})
194 llvm_ExternalProject_BuildCmd(build_runtime_cmd ${target} ${BINARY_DIR})
187195 add_custom_target(${target}
188196 COMMAND ${build_runtime_cmd}
189197 DEPENDS ${name}-configure