Skip to content

Commit

Permalink
Begin work on super build. #83
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhillyer committed Sep 4, 2020
1 parent 37380ea commit 0c70158
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 2 deletions.
35 changes: 33 additions & 2 deletions slicer/collageradiomics/CMakeLists.txt → slicer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,47 @@ set(EXTENSION_ICONURL "https://github.com/radxtools/collageradiomics/raw/master/
set(EXTENSION_SCREENSHOTURLS "https://github.com/radxtools/collageradiomics/raw/master/slicer/collageradiomics/CollageRadiomicsSlicer/Screenshot.jpg")
set(EXTENSION_DEPENDS "NA") # Specified as a list or "NA" if no dependencies

set(EXTENSION_BUILD_SUBDIRECTORY inner-build)

set(SUPERBUILD_TOPLEVEL_PROJECT inner)

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
mark_as_superbuild(Slicer_DIR)

find_package(Git REQUIRED)
mark_as_superbuild(GIT_EXECUTABLE)

#-----------------------------------------------------------------------------
# SuperBuild setup
option(${EXTENSION_NAME}_SUPERBUILD "Build ${EXTENSION_NAME} and the projects it depends on." ON)
mark_as_advanced(${EXTENSION_NAME}_SUPERBUILD)
if(${EXTENSION_NAME}_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
return()
endif()

#-----------------------------------------------------------------------------
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(SlicerRadiomicsAddCLI)

#-----------------------------------------------------------------------------
# Extension modules
add_subdirectory(CollageRadiomicsSlicer)
add_subdirectory(SlicerRadiomics)
add_subdirectory(SlicerRadiomicsCLI)
## NEXT_MODULE

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_GENERATE_CONFIG})
# Install extension python packages
install(CODE "message(\"CPack: - Install directory: ${python_packages_DIR}\")")
install(
DIRECTORY "${python_packages_DIR}/"
DESTINATION ${Slicer_INSTALL_ROOT}${Slicer_BUNDLE_EXTENSIONS_LOCATION}
COMPONENT RuntimeLibraries
)

#-----------------------------------------------------------------------------
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};ALL;/")
include(${Slicer_EXTENSION_CPACK})
File renamed without changes.
68 changes: 68 additions & 0 deletions slicer/SuperBuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#-----------------------------------------------------------------------------
# Git protocol option
#-----------------------------------------------------------------------------
option(Slicer_USE_GIT_PROTOCOL "If behind a firewall turn this off to use http instead." ON)

set(git_protocol "git")
if(NOT Slicer_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()

#-----------------------------------------------------------------------------
# Enable and setup External project global properties
#-----------------------------------------------------------------------------
set(ep_common_c_flags "${CMAKE_C_FLAGS_INIT} ${ADDITIONAL_C_FLAGS}")
set(ep_common_cxx_flags "${CMAKE_CXX_FLAGS_INIT} ${ADDITIONAL_CXX_FLAGS}")

#-----------------------------------------------------------------------------
# Project dependencies
#-----------------------------------------------------------------------------
include(ExternalProject)

foreach(dep ${EXTENSION_DEPENDS})
mark_as_superbuild(${dep}_DIR)
endforeach()

set(proj ${SUPERBUILD_TOPLEVEL_PROJECT})
if(UNIX)
set(${proj}_DEPENDS python-collageradiomics)
endif(UNIX)

ExternalProject_Include_Dependencies(${proj}
PROJECT_VAR proj
SUPERBUILD_VAR ${EXTENSION_NAME}_SUPERBUILD
)

ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
DOWNLOAD_COMMAND ""
INSTALL_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${EXTENSION_BUILD_SUBDIRECTORY}
BUILD_ALWAYS 1
CMAKE_CACHE_ARGS
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DSlicer_DIR:PATH=${Slicer_DIR}
-DMIDAS_PACKAGE_EMAIL:STRING=${MIDAS_PACKAGE_EMAIL}
-DMIDAS_PACKAGE_API_KEY:STRING=${MIDAS_PACKAGE_API_KEY}
-D${EXTENSION_NAME}_SUPERBUILD:BOOL=OFF
-DEXTENSION_SUPERBUILD_BINARY_DIR:PATH=${${EXTENSION_NAME}_BINARY_DIR}
-DSubversion_SVN_EXECUTABLE:STRING=${Subversion_SVN_EXECUTABLE}
-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
DEPENDS
${${proj}_DEPENDS}
)

ExternalProject_AlwaysConfigure(${proj})
92 changes: 92 additions & 0 deletions slicer/SuperBuild/External_python-collageradiomics.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
set(proj python-collageradiomics)

# Set dependency list
set(${proj}_DEPENDENCIES "")

# Include dependent projects if any
ExternalProject_Include_Dependencies(${proj} PROJECT_VAR proj DEPENDS_VAR ${proj}_DEPENDENCIES)

if(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
ExternalProject_FindPythonPackage(
MODULE_NAME "collageradiomics"
REQUIRED
)
endif()

if(NOT DEFINED ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
set(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj} ${Slicer_USE_SYSTEM_python})
endif()

if(NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})

if(NOT DEFINED git_protocol)
set(git_protocol "git")
endif()

ExternalProject_SetIfNotDefined(
${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY
"${git_protocol}://github.com/radxtools/collageradiomics"
QUIET
)

ExternalProject_SetIfNotDefined(
${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG
"origin/master"
QUIET
)

set(wrapper_script)
if(MSVC)
find_package(Vcvars REQUIRED)
set(wrapper_script ${Vcvars_WRAPPER_BATCH_FILE})
endif()

# Alternative python prefix for installing extension python packages
set(python_packages_DIR "${CMAKE_BINARY_DIR}/python-packages-install")
file(TO_NATIVE_PATH ${python_packages_DIR} python_packages_DIR_NATIVE_DIR)

set(_no_binary "")

# Install collageradiomics
set(_install_collageradiomics COMMAND ${CMAKE_COMMAND}
-E env
PYTHONNOUSERSITE=1
CC=${CMAKE_C_COMPILER}
${wrapper_script} ${PYTHON_EXECUTABLE} -m pip install . ${_no_binary}
--prefix ${python_packages_DIR_NATIVE_DIR}
)

ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
GIT_REPOSITORY "${${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY}"
GIT_TAG "${${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG}"
SOURCE_DIR ${proj}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo_append ""
${_install_pyyaml}
${_install_collageradiomics}
DEPENDS
${${proj}_DEPENDENCIES}
)

ExternalProject_GenerateProjectDescription_Step(${proj})

#-----------------------------------------------------------------------------
# Launcher setting specific to build tree
set(${proj}_PYTHONPATH_LAUNCHER_BUILD
${python_packages_DIR}/${PYTHON_STDLIB_SUBDIR}
${python_packages_DIR}/${PYTHON_STDLIB_SUBDIR}/lib-dynload
${python_packages_DIR}/${PYTHON_SITE_PACKAGES_SUBDIR}
)
mark_as_superbuild(
VARS ${proj}_PYTHONPATH_LAUNCHER_BUILD
LABELS "PYTHONPATH_LAUNCHER_BUILD"
)

mark_as_superbuild(python_packages_DIR:PATH)

else()
ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES})
endif()
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 0c70158

Please sign in to comment.