-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #858 from KrisThielemans/STIR_6_prep
Stir 6 prep
- Loading branch information
Showing
4 changed files
with
62 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#======================================================================== | ||
# Author: Benjamin A Thomas | ||
# Author: Kris Thielemans | ||
# Copyright 2017, 2020 University College London | ||
# Copyright 2017, 2020-2024 University College London | ||
# | ||
# This file is part of the CCP SyneRBI (formerly PETMR) Synergistic Image Reconstruction Framework (SIRF) SuperBuild. | ||
# | ||
|
@@ -86,7 +86,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr | |
# Include dependent projects if any | ||
ExternalProject_Include_Dependencies(${proj} DEPENDS_VAR ${proj}_DEPENDENCIES) | ||
|
||
set(STIR_CMAKE_ARGS | ||
set(STIR_local_extra_cmake_args | ||
|
||
-DSWIG_EXECUTABLE:FILEPATH=${SWIG_EXECUTABLE} | ||
-DBUILD_EXECUTABLES:BOOL=${STIR_BUILD_EXECUTABLES} | ||
|
@@ -114,29 +114,29 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr | |
# 3 choices: | ||
# 1. NOT USE_ITK <- Disable ITK | ||
# 2. USE_ITK && USE_SYSTEM_ITK <- Need to set ITK_DIR, set with find_package in External_ITK.cmake | ||
# 3. USE_ITK && !USE_SYSTEM_ITK <- No need to do anything (ITK_DIR will get set during the installation of ITK) | ||
# 3. USE_ITK && !USE_SYSTEM_ITK <- No need to do anything (CMake will find it in CMAKE_INSTALL_PREFIX) | ||
# STIR enables ITK by default (If it is found, so no need to set -DDISABLE_ITK=OFF for cases 2 and 3) | ||
if (NOT USE_ITK) | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DDISABLE_ITK:BOOL=ON) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DDISABLE_ITK:BOOL=ON) | ||
else() | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DDISABLE_ITK:BOOL=OFF) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DDISABLE_ITK:BOOL=OFF) | ||
if (USE_SYSTEM_ITK) | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DITK_DIR:PATH=${ITK_DIR}) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DITK_DIR:PATH=${ITK_DIR}) | ||
endif() | ||
endif() | ||
# same for ROOT | ||
if (NOT USE_ROOT) | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DDISABLE_CERN_ROOT:BOOL=ON) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DDISABLE_CERN_ROOT:BOOL=ON) | ||
else() | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DDISABLE_CERN_ROOT:BOOL=OFF) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DDISABLE_CERN_ROOT:BOOL=OFF) | ||
if (USE_SYSTEM_ROOT) | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DROOT_DIR:PATH=${ROOT_DIR}) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DROOT_DIR:PATH=${ROOT_DIR}) | ||
endif() | ||
endif() | ||
|
||
## If building with NiftyPET projector | ||
if (${USE_NiftyPET}) | ||
set(STIR_CMAKE_ARGS ${STIR_CMAKE_ARGS} -DNiftyPET_PATH:PATH=${NiftyPET_PATH}) | ||
set(STIR_local_extra_cmake_args ${STIR_local_extra_cmake_args} -DNiftyPET_PATH:PATH=${NiftyPET_PATH}) | ||
endif() | ||
|
||
# Sets ${proj}_URL_MODIFIED and ${proj}_TAG_MODIFIED | ||
|
@@ -147,15 +147,53 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr | |
${${proj}_EP_ARGS_GIT} | ||
${${proj}_EP_ARGS_DIRS} | ||
CMAKE_ARGS | ||
${STIR_CMAKE_ARGS} | ||
${STIR_local_extra_cmake_args} | ||
${Boost_CMAKE_ARGS} | ||
${HDF5_CMAKE_ARGS} | ||
${${proj}_EXTRA_CMAKE_ARGS} | ||
DEPENDS | ||
${${proj}_DEPENDENCIES} | ||
) | ||
|
||
set(STIR_DIR ${SUPERBUILD_INSTALL_DIR}/lib/cmake) | ||
### Handle STIR_DIR | ||
# We need to find out where STIRConfig.cmake will be installed, as this changed | ||
# in STIR 6.0 (from lib/cmake to lib/cmake/STIR-V.v) | ||
# Unfortunately, this is complicated and brittle. | ||
|
||
# Get STIR version to see if it's 5.* | ||
# We will download STIR's VERSION.txt and check its content. | ||
# Set location of downloaded file | ||
set(STIR_VERSION_FILE "${${proj}_BINARY_DIR}/STIR_VERSION.txt") | ||
file(REMOVE "${STIR_VERSION_FILE}") | ||
# set URL with version file. Sadly this is far too complicated as | ||
# STIR_URL could be something weird, and we need to get at the URL for the "raw" file | ||
set(STIR_VERSION_URL "${STIR_URL}/${STIR_TAG}/VERSION.txt") | ||
string(REPLACE ".git" "" STIR_VERSION_URL "${STIR_VERSION_URL}") | ||
string(REPLACE "https://github.com" "https://raw.githubusercontent.com" STIR_VERSION_URL "${STIR_VERSION_URL}") | ||
string(REPLACE "[email protected]:" "https://raw.githubusercontent.com/" STIR_VERSION_URL "${STIR_VERSION_URL}") | ||
string(REPLACE "origin/" "" STIR_VERSION_URL "${STIR_VERSION_URL}") | ||
message(STATUS "Downloading STIR version from ${STIR_VERSION_URL}") | ||
# Download and read | ||
file(DOWNLOAD "${STIR_VERSION_URL}" "${STIR_VERSION_FILE}" STATUS download_status) | ||
list(GET download_status 0 download_status) | ||
if (NOT download_status EQUAL 0) | ||
message(WARNING | ||
"Download failed. We're going to assume this is recent STIR, e.g. where VERSION.txt might be removed.") | ||
set (STIR_VERSION 7.0.0) | ||
else() | ||
file(READ "${STIR_VERSION_FILE}" STIR_VERSION) | ||
endif() | ||
message(STATUS "Found STIR version ${STIR_VERSION}") | ||
# Finally, see what we need to do for different STIR versions | ||
if (STIR_VERSION VERSION_LESS 6.0) | ||
set(STIR_DIR "${${proj}_INSTALL_DIR}/lib/cmake") | ||
else() | ||
if (NOT "${proj}_INSTALL_DIR" MATCHES "${STIR_INSTALL_DIR}") | ||
message(WARNING "CMake might have trouble finding (the correct) STIR. If so, set STIR_DIR.") | ||
# TODO could adapt using the STIR_VERSION above, but it would fail if VERSION.txt is ever removed. | ||
# This is a corner case though, so KT is leaving it for later. | ||
endif() | ||
endif() | ||
|
||
|
||
if (BUILD_TESTING_${proj}) | ||
|
@@ -166,17 +204,14 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr | |
|
||
else() | ||
if(${USE_SYSTEM_${externalProjName}}) | ||
find_package(${proj} ${${externalProjName}_REQUIRED_VERSION} REQUIRED) | ||
message(STATUS "USING the system ${externalProjName}, set ${externalProjName}_DIR=${${externalProjName}_DIR}") | ||
find_package(${proj} ${${externalProjName}_REQUIRED_VERSION} REQUIRED CONFIG) | ||
message(STATUS "USING the system ${externalProjName} at ${externalProjName}_DIR=${${externalProjName}_DIR}") | ||
endif() | ||
ExternalProject_Add_Empty(${proj} DEPENDS "${${proj}_DEPENDENCIES}" | ||
${${proj}_EP_ARGS_DIRS} | ||
) | ||
endif() | ||
|
||
mark_as_superbuild( | ||
VARS | ||
${externalProjName}_DIR:PATH | ||
LABELS | ||
"FIND_PACKAGE" | ||
) | ||
if (STIR_DIR) | ||
set(STIR_CMAKE_ARGS "-DSTIR_DIR:PATH=${STIR_DIR}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters