Skip to content

Commit bc787fb

Browse files
authored
Merge pull request #1943 from ANTsX/install_from_build_root
ENH: allow install step from the build root
2 parents b53aad3 + a00493f commit bc787fb

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

SuperBuild.cmake

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,37 @@ ExternalProject_Add_Step(${proj} forcebuild
328328
DEPENDERS build
329329
ALWAYS 1
330330
)
331+
332+
# -------------------------------------------------------------------------
333+
# Superbuild install: delegate to inner ANTS-build
334+
# -------------------------------------------------------------------------
335+
336+
set(_inner_build_dir "${CMAKE_BINARY_DIR}/${LOCAL_PROJECT_NAME}-build")
337+
338+
# Create a harmless stamp so the superbuild has an install script
339+
set(_superbuild_stamp "${CMAKE_CURRENT_BINARY_DIR}/superbuild-install-stamp.txt")
340+
file(WRITE "${_superbuild_stamp}" "ANTs superbuild install stamp\n")
341+
install(FILES "${_superbuild_stamp}" DESTINATION "share/ANTs" COMPONENT Superbuild)
342+
343+
# Delegate install to the inner build tree (and build it first for cmake --install)
344+
install(CODE
345+
"
346+
message(STATUS \"Superbuild: building ${LOCAL_PROJECT_NAME} target before install\")
347+
execute_process(
348+
COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target \"${LOCAL_PROJECT_NAME}\"
349+
RESULT_VARIABLE _bres
350+
)
351+
if(NOT _bres EQUAL 0)
352+
message(FATAL_ERROR \"Superbuild build of ${LOCAL_PROJECT_NAME} failed with exit code: \${_bres}\")
353+
endif()
354+
355+
message(STATUS \"Superbuild: installing from inner build dir: ${_inner_build_dir}\")
356+
execute_process(
357+
COMMAND \"${CMAKE_COMMAND}\" --install \"${_inner_build_dir}\" --prefix \"${CMAKE_INSTALL_PREFIX}\"
358+
RESULT_VARIABLE _res
359+
)
360+
if(NOT _res EQUAL 0)
361+
message(FATAL_ERROR \"Inner ${LOCAL_PROJECT_NAME} install failed with exit code: \${_res}\")
362+
endif()
363+
"
364+
)

0 commit comments

Comments
 (0)