Commit 28c0ff3e authored by hjohnson's avatar hjohnson

COMP: Set BRAINSTools building for ITKv3 and ITKv4

BRAINSTools is built quite differently for ITKv3 and
ITKv4.  This separates they way they are configured.

Added BRAINSTools as an External_Project for ITKv4,
and left it as an internal build for ITKv3.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@17786 3bd1e089-480b-0410-8dfb-8563597acbee
parent 09e6fbb1
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
# parsing the arguments given to that macro or function.
# It processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The <options> argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any value
# following, like e.g. the OPTIONAL keyword of the install() command.
#
# The <one_value_keywords> argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The <multi_value_keywords> argument contains all keywords for this macro
# which can be followed by more than one value, like e.g. the TARGETS or
# FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in <options>, <one_value_keywords> and
# <multi_value_keywords> a variable composed of the given <prefix>
# followed by "_" and the name of the respective keyword.
# These variables will then hold the respective value from the argument list.
# For the <options> keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
# your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments as the
# real install() command:
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# ...
#
# Assume my_install() has been called like this:
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
# After the cmake_parse_arguments() call the macro will have set the following
# variables:
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
# You can the continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
# another recognized keyword follows, this is interpreted as the beginning of
# the new option.
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach(arg_name)
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach(option)
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else(insideValues)
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif(insideValues)
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach(currentArg)
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach(arg_name)
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
......@@ -64,7 +64,6 @@ include(Slicer3PluginsMacros)
include(SlicerMacroExtractRepositoryInfo)
include(SlicerMacroGetPlatformArchitectureBitness)
include(SlicerMacroParseArguments)
include(SlicerMacroBuildCLI)
include(SlicerMacroEmptyExternalProject)
include(SlicerFunctionInstallLibrary)
......@@ -278,6 +277,11 @@ if(Slicer_SUPERBUILD)
return()
endif()
#-----------------------------------------------------------------------------
# CMake Function(s) and Macro(s)
#-----------------------------------------------------------------------------
include(SlicerMacroBuildCLI)
# Clear SlicerTargets.cmake
file(WRITE "${Slicer_BINARY_DIR}/SlicerTargets.cmake"
"# Generated by CMake, do not edit!")
......
......@@ -68,12 +68,20 @@ endif()
option(Slicer_BUILD_WITH_ITKv4 "Build Slicer against ITKv4" OFF)
mark_as_advanced(Slicer_BUILD_WITH_ITKv4)
set(ITK_EXTERNAL_NAME "ITKv3")
if(Slicer_BUILD_WITH_ITKv4)
set(ITK_EXTERNAL_NAME "ITKv4")
else()
set(ITK_EXTERNAL_NAME "ITKv3")
endif()
set(Slicer_DEPENDENCIES LibArchive cmcurl OpenIGTLink teem VTK ${ITK_EXTERNAL_NAME} CTK qCDashAPI SlicerExecutionModel)
option(Slicer_BUILD_BRAINSTOOLS "Build BRAINSTools for Slicer Integration" ON)
mark_as_advanced(Slicer_BUILD_BRAINSTOOLS)
if(Slicer_BUILD_BRAINSTOOLS)
list(APPEND Slicer_DEPENDENCIES SlicerBRAINSTools)
endif()
if(Slicer_USE_BatchMake)
list(APPEND Slicer_DEPENDENCIES BatchMake)
endif()
......@@ -151,10 +159,6 @@ if(DEFINED CTEST_CONFIGURATION_TYPE)
list(APPEND slicer_superbuild_extra_args -DCTEST_CONFIGURATION_TYPE:STRING=${CTEST_CONFIGURATION_TYPE})
endif()
if(Slicer_BUILD_CLI)
list(APPEND slicer_superbuild_extra_args -DBUILD_BRAINSTOOLS:BOOL=${Slicer_BUILD_BRAINSTOOLS})
endif()
if(Slicer_USE_PYTHONQT)
list(APPEND slicer_superbuild_extra_args
-DSlicer_USE_SYSTEM_PYTHON:BOOL=OFF
......
# Make sure this file is included only once
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED)
return()
endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
# Sanity checks
if(DEFINED SlicerBRAINSTools_DIR AND NOT EXISTS ${SlicerBRAINSTools_DIR})
message(FATAL_ERROR "SlicerBRAINSTools_DIR variable is defined but corresponds to non-existing directory")
endif()
# Set dependency list
set(SlicerBRAINSTools_DEPENDENCIES ${ITK_EXTERNAL_NAME} SlicerExecutionModel VTK )
# Include dependent projects if any
SlicerMacroCheckExternalProjectDependency(SlicerBRAINSTools)
set(proj SlicerBRAINSTools)
# Set CMake OSX variable to pass down the external project
set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS)
if(APPLE)
list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
endif()
if(NOT DEFINED SlicerBRAINSTools_DIR)
#-----------------------------------------------------------------------------
# DUPLICATED THERE FOR COMPLETNESS Plugins and Modules relative directories
#------------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Slicer install directories
#-----------------------------------------------------------------------------
set(Slicer_INSTALL_ROOT "./")
if(APPLE)
# Set to create Bundle
set(Slicer_BUNDLE_LOCATION "Slicer.app/Contents")
set(Slicer_INSTALL_ROOT "${Slicer_BUNDLE_LOCATION}/")
endif()
set(Slicer_PLUGINS_BIN_DIR "plugins")
set(Slicer_PLUGINS_LIB_DIR "plugins")
set(Slicer_INSTALL_PLUGINS_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_PLUGINS_BIN_DIR}")
set(Slicer_INSTALL_PLUGINS_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_PLUGINS_LIB_DIR}")
set(Slicer_HOME "${Slicer_BINARY_DIR}")
#message(STATUS "${__indent}Adding project ${proj}")
ExternalProject_Add(${proj}
GIT_REPOSITORY "${git_protocol}://github.com/BRAINSia/BRAINSStandAlone.git"
GIT_TAG "master"
SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
BINARY_DIR ${proj}-build
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
${CMAKE_OSX_EXTERNAL_PROJECT_ARGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} # Unused
-DBUILD_TESTING:BOOL=ON
#################### Propogate the Slicer Environment
## -- This could be some other variable to indicate a slicer build
-DINTEGRATE_WITH_SLICER:BOOL=ON
-DBRAINSTools_SUPERBUILD:BOOL=OFF
-DSlicer_PLUGINS_BIN_DIR:PATH=${CMAKE_BINARY_DIR}/Slicer-build/${Slicer_PLUGINS_BIN_DIR}
-DSlicer_PLUGINS_LIB_DIR:PATH=${CMAKE_BINARY_DIR}/Slicer-build/${Slicer_PLUGINS_LIB_DIR}
-DSlicer_INSTALL_PLUGINS_BIN_DIR:PATH=${CMAKE_BINARY_DIR}/Slicer-build/${Slicer_INSTALL_PLUGINS_BIN_DIR}
-DSlicer_INSTALL_PLUGINS_LIB_DIR:PATH=${CMAKE_BINARY_DIR}/Slicer-build/${Slicer_INSTALL_PLUGINS_LIB_DIR}
#################### Propogate the Slicer Environment
# ITK
-DITK_DIR:PATH=${ITK_DIR}
-DVTK_DIR:PATH=${VTK_DIR}
# SlicerExecutionModel
-DSlicerExecutionModel_DIR:PATH=${SlicerExecutionModel_DIR}
## Which SlicerBRAINSTools packages to use
-DUSE_BRAINSFit:BOOL=ON
-DUSE_BRAINSResample:BOOL=ON
-DUSE_BRAINSROIAuto:BOOL=ON
-DUSE_BRAINSDemonWarp:BOOL=ON
-DUSE_BRAINSMultiModeSegment:BOOL=ON
-DUSE_BRAINSMush:BOOL=ON
-DUSE_BRAINSConstellationDetector:BOOL=ON
-DUSE_GTRACT:BOOL=ON
-DUSE_BRAINSABC:BOOL=ON
-DUSE_BRAINSInitializedControlPoints:BOOL=ON
INSTALL_COMMAND ""
DEPENDS
${SlicerBRAINSTools_DEPENDENCIES}
)
set(SlicerBRAINSTools_DIR ${CMAKE_BINARY_DIR}/${proj}-build)
else()
# The project is provided using SlicerBRAINSTools_DIR, nevertheless since other project may depend on SlicerBRAINSTools,
# let's add an 'empty' one
SlicerMacroEmptyExternalProject(${proj} "${SlicerBRAINSTools_DEPENDENCIES}")
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment