Commit 98669cae authored by jcfr's avatar jcfr

COMP: Add Slicer_BUILD_CLI_SUPPORT

* When disabled, neither the CLI factories or the CLI modules will be built.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@18929 3bd1e089-480b-0410-8dfb-8563597acbee
parent 5ca1f72c
......@@ -71,13 +71,12 @@ add_library(${lib_name}
set_target_properties(${lib_name} PROPERTIES LABELS SlicerQT)
set(SlicerQT_LIBRARIES
qSlicerBaseQTCLI
qSlicerBaseQTCoreModules
)
if(Slicer_USE_PYTHONQT)
set(SlicerQT_LIBRARIES
${SlicerQT_LIBRARIES}
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND SlicerQT_LIBRARIES
qSlicerBaseQTCLI
)
endif()
......@@ -85,7 +84,6 @@ target_link_libraries(${lib_name}
${SlicerQT_LIBRARIES}
)
# --------------------------------------------------------------------------
# Configure Application Bundle Resources (Mac Only)
# --------------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@
#include "vtkSlicerConfigure.h" // For Slicer_USE_PYTHONQT
// CTK includes
#include <ctkAbstractLibraryFactory.h>
#include <ctkCallback.h>
#ifdef Slicer_USE_PYTHONQT
# include <ctkPythonConsole.h>
......@@ -35,10 +36,15 @@
// MRMLWidgets includes
#include <qMRMLEventLoggerWidget.h>
// Slicer includes
#include "vtkSlicerVersionConfigure.h" // For Slicer_VERSION_FULL, Slicer_BUILD_CLI_SUPPORT
// SlicerQt includes
#include "qSlicerApplication.h"
#include "qSlicerCLIExecutableModuleFactory.h"
#include "qSlicerCLILoadableModuleFactory.h"
#ifdef Slicer_BUILD_CLI_SUPPORT
# include "qSlicerCLIExecutableModuleFactory.h"
# include "qSlicerCLILoadableModuleFactory.h"
#endif
#include "qSlicerCommandOptions.h"
#include "qSlicerCoreModuleFactory.h"
#include "qSlicerLoadableModuleFactory.h"
......@@ -47,9 +53,6 @@
#include "qSlicerModuleManager.h"
#include "qSlicerStyle.h"
// Slicer includes
#include "vtkSlicerVersionConfigure.h" // For Slicer_VERSION_FULL
// VTK includes
//#include <vtkObject.h>
......@@ -175,6 +178,7 @@ void registerScriptedLoadableModuleFactory(
}
//----------------------------------------------------------------------------
#ifdef Slicer_BUILD_CLI_SUPPORT
void registerCLIModuleFactory(
qSlicerModuleFactoryManager * moduleFactoryManager, const QString& tempDirectory,
const QSharedPointer<ctkAbstractLibraryFactory<qSlicerAbstractCoreModule>::HashType>& moduleFactorySharedRegisteredItemKeys)
......@@ -193,6 +197,7 @@ void registerCLIModuleFactory(
moduleFactoryManager->registerFactory("qSlicerCLIExecutableModuleFactory",
cliExecutableModuleFactory);
}
#endif
//----------------------------------------------------------------------------
void showMRMLEventLoggerWidget()
......@@ -283,6 +288,7 @@ int slicerQtMain(int argc, char* argv[])
{
registerScriptedLoadableModuleFactory(moduleFactoryManager, coreModuleFactory->sharedItems());
}
#ifdef Slicer_BUILD_CLI_SUPPORT
if (!app.commandOptions()->disableCLIModules())
{
registerCLIModuleFactory(
......@@ -290,6 +296,7 @@ int slicerQtMain(int argc, char* argv[])
qSlicerCoreApplication::application()->coreCommandOptions()->tempDirectory(),
coreModuleFactory->sharedItems());
}
#endif
moduleFactoryManager->setVerboseModuleDiscovery(app.commandOptions()->verboseModuleDiscovery());
......
if(Slicer_BUILD_EMSegment)
include_directories(
${EMSegment_SOURCE_DIR}
${RemoteIO_SOURCE_DIR} ${RemoteIO_BINARY_DIR})
if(Slicer_BUILD_CLI_SUPPORT)
if(Slicer_BUILD_EMSegment)
include_directories(
${EMSegment_SOURCE_DIR}
${RemoteIO_SOURCE_DIR} ${RemoteIO_BINARY_DIR})
endif()
endif()
set(KIT SlicerQT)
......@@ -15,8 +17,10 @@ set(KIT_TEST_SRCS
)
if(Slicer_USE_PYTHONQT_WITH_TCL)
list(APPEND KIT_TEST_SRCS qSlicerApplicationTpyclTest1.cxx)
if(Slicer_BUILD_EMSegment)
list(APPEND KIT_TEST_SRCS qSlicerApplicationTpyclEMSegmentIntegrationTest.cxx)
if(Slicer_BUILD_CLI_SUPPORT)
if(Slicer_BUILD_EMSegment)
list(APPEND KIT_TEST_SRCS qSlicerApplicationTpyclEMSegmentIntegrationTest.cxx)
endif()
endif()
endif()
create_test_sourcelist(Tests ${KIT}CxxTests.cxx
......@@ -29,8 +33,15 @@ list(REMOVE_ITEM TestsToRun ${KIT}CxxTests.cxx)
set(LIBRARY_NAME qSlicerQT)
set(target_libraries ${LIBRARY_NAME})
if(Slicer_BUILD_CLI_SUPPORT)
if(Slicer_BUILD_EMSegment)
list(APPEND target_libraries vtkSlicerEMSegmentModuleLogic)
endif()
endif()
add_executable(${KIT}CxxTests ${Tests})
target_link_libraries(${KIT}CxxTests ${LIBRARY_NAME} vtkSlicerEMSegmentModuleLogic)
target_link_libraries(${KIT}CxxTests ${target_libraries})
macro(SIMPLE_TEST TESTNAME)
add_test(NAME ${TESTNAME} COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:${KIT}CxxTests> ${TESTNAME} ${ARGN})
......@@ -44,8 +55,10 @@ SIMPLE_TEST( qSlicerAboutDialogTest1 )
if(Slicer_USE_PYTHONQT_WITH_TCL)
SIMPLE_TEST( qSlicerApplicationTpyclTest1 )
set_tests_properties(qSlicerApplicationTpyclTest1 PROPERTIES PASS_REGULAR_EXPRESSION stringArray)
if(Slicer_BUILD_EMSegment)
SIMPLE_TEST( qSlicerApplicationTpyclEMSegmentIntegrationTest $<TARGET_FILE:EMSegmentCommandLine>)
if(Slicer_BUILD_CLI_SUPPORT)
if(Slicer_BUILD_EMSegment)
SIMPLE_TEST( qSlicerApplicationTpyclEMSegmentIntegrationTest $<TARGET_FILE:EMSegmentCommandLine>)
endif()
endif()
endif()
SIMPLE_TEST( qSlicerMainWindowCoreTest1 )
......
......@@ -23,10 +23,14 @@ include_directories(
add_subdirectory(Logic)
add_subdirectory(QTCore)
add_subdirectory(QTGUI)
add_subdirectory(QTCLI)
if(Slicer_BUILD_CLI_SUPPORT)
add_subdirectory(QTCLI)
endif()
add_subdirectory(QTCoreModules)
add_subdirectory(GUI)
add_subdirectory(CLI)
if(Slicer_BUILD_CLI_SUPPORT)
add_subdirectory(CLI)
endif()
if(Slicer_USE_PYTHONQT)
add_subdirectory(Python)
......
......@@ -3,7 +3,9 @@ project(SlicerBaseLogic)
# --------------------------------------------------------------------------
# Third party library
# --------------------------------------------------------------------------
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
if(Slicer_BUILD_CLI_SUPPORT)
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
endif()
# --------------------------------------------------------------------------
# Subdirectories
......@@ -17,15 +19,20 @@ set(include_dirs
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${MRMLCore_INCLUDE_DIRS}
${MRMLCLI_INCLUDE_DIRS}
${MRMLLogic_INCLUDE_DIRS}
${ModuleDescriptionParser_INCLUDE_DIRS}
${vtkTeem_INCLUDE_DIRS}
${FreeSurfer_INCLUDE_DIRS}
${RemoteIO_INCLUDE_DIRS}
${LibArchive_INCLUDE_DIR}
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND include_dirs
${MRMLCLI_INCLUDE_DIRS}
${ModuleDescriptionParser_INCLUDE_DIRS}
)
endif()
if(Slicer_USE_PYTHONQT)
list(APPEND include_dirs
${PYTHON_INCLUDE_DIR}
......@@ -129,7 +136,6 @@ add_library(${lib_name} ${srcs})
set(libs
MRMLCore
MRMLCLI
MRMLLogic
vtkITK
${OPENTRACKER_LIB}
......@@ -139,6 +145,12 @@ set(libs
${LibArchive_LIBRARY}
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND libs
MRMLCLI
)
endif()
if(Slicer_USE_PYTHONQT)
list(APPEND libs
vtkCommonPythonD # For vtkPythonUtils
......
......@@ -9,6 +9,7 @@
// Slicer includes
#include "vtkSlicerApplicationLogic.h"
#include "vtkSlicerColorLogic.h"
#include "vtkSlicerConfigure.h" // For Slicer_BUILD_CLI_SUPPORT
#include "vtkSlicerTask.h"
// VTK includes
......@@ -18,7 +19,9 @@
// MRML includes
#include <vtkCacheManager.h>
#include <vtkMRMLColorTableStorageNode.h>
#include <vtkMRMLCommandLineModuleNode.h>
#ifdef Slicer_BUILD_CLI_SUPPORT
# include <vtkMRMLCommandLineModuleNode.h>
#endif
#include <vtkMRMLDiffusionTensorVolumeDisplayNode.h>
#include <vtkMRMLDiffusionTensorVolumeNode.h>
#include <vtkMRMLDiffusionTensorVolumeSliceDisplayNode.h>
......@@ -833,7 +836,9 @@ void vtkSlicerApplicationLogic::ProcessReadNodeData(ReadDataRequest& req)
vtkMRMLDisplayableNode *fbnd = 0;
vtkMRMLColorTableNode *cnd = 0;
vtkMRMLDoubleArrayNode *dand = 0;
#ifdef Slicer_BUILD_CLI_SUPPORT
vtkMRMLCommandLineModuleNode *clp = 0;
#endif
nd = this->GetMRMLScene()->GetNodeByID( req.GetNode().c_str() );
......@@ -865,8 +870,9 @@ void vtkSlicerApplicationLogic::ProcessReadNodeData(ReadDataRequest& req)
fbnd = vtkMRMLDisplayableNode::SafeDownCast(nd);
cnd = vtkMRMLColorTableNode::SafeDownCast(nd);
dand = vtkMRMLDoubleArrayNode::SafeDownCast(nd);
#ifdef Slicer_BUILD_CLI_SUPPORT
clp = vtkMRMLCommandLineModuleNode::SafeDownCast(nd);
#endif
bool useURI = this->GetMRMLScene()->GetCacheManager()->IsRemoteReference(req.GetFilename().c_str());
bool storageNodeExists = false;
......@@ -1078,13 +1084,14 @@ void vtkSlicerApplicationLogic::ProcessReadNodeData(ReadDataRequest& req)
}
}
#ifdef Slicer_BUILD_CLI_SUPPORT
// if the node was a CommandLineModule node, then read the file
// (no storage node for these, yet)
if (clp)
{
clp->ReadParameterFile(req.GetFilename());
}
#endif
// Delete the file if requested
if (req.GetDeleteFile())
......
set(Slicer_PYTHON_SCRIPTS
slicer/__init__
slicer/cli
slicer/logic
slicer/slicerqt
slicer/testing
......@@ -10,7 +8,6 @@ set(Slicer_PYTHON_SCRIPTS
slicer/modulemrml/__init__
slicer/modulewidget/__init__
mrml
mrmlcli
mrmlLogic
teem
freesurfer
......@@ -18,6 +15,46 @@ set(Slicer_PYTHON_SCRIPTS
vtkITK
)
set(Slicer_PYTHON_MODULES_CONFIG "
# slicer libs
'freesurfer',
'mrml',
'mrmlLogic',
'remoteio',
'teem',
'qMRMLWidgetsPythonQt',
# slicer base libs
'logic',
'qSlicerBaseQTCorePythonQt',
'qSlicerBaseQTGUIPythonQt',
# slicer module
'modulelogic',
'modulemrml',
'modulewidget'"
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND Slicer_PYTHON_SCRIPTS
slicer/cli
mrmlcli
)
set(Slicer_PYTHON_MODULES_CONFIG "${Slicer_PYTHON_MODULES_CONFIG},
# slicer libs (Slicer_BUILD_CLI_SUPPORT:ON)
'mrmlcli',
# slicer base libs (Slicer_BUILD_CLI_SUPPORT:ON)
'qSlicerBaseQTCLIPythonQt',
#CLI logic (Slicer_BUILD_CLI_SUPPORT:ON)
"
)
endif()
configure_file(
slicer/__init__.py.in
${CMAKE_CURRENT_BINARY_DIR}/slicer/__init__.py
@ONLY
)
list(APPEND Slicer_PYTHON_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/slicer/__init__.py)
set(Slicer_PYTHON_RESOURCES
)
......
""" This module loads the Slicer library modules into its namespace."""
__kits_to_load = [
# slicer libs
'freesurfer',
'mrml',
'mrmlcli',
'mrmlLogic',
'remoteio',
'teem',
'qMRMLWidgetsPythonQt',
# slicer base libs
'logic',
'qSlicerBaseQTCorePythonQt',
'qSlicerBaseQTGUIPythonQt',
'qSlicerBaseQTCLIPythonQt',
# slicer module
'modulelogic',
'modulemrml',
'modulewidget'
#CLI logic
]
__kits_to_load = [ @Slicer_PYTHON_MODULES_CONFIG@ ]
for kit in __kits_to_load:
try:
......
""" This module loads the Slicer Module Logic vtk classes into its namespace."""
# Import the CLI logic
from qSlicerBaseQTCLIPython import vtkSlicerCLIModuleLogic
# HACK Ideally constant from vtkSlicerConfigure should be wrapped,
# that way the following try/except could be avoided.
try:
from qSlicerBaseQTCLIPython import vtkSlicerCLIModuleLogic
except: pass
from __main__ import _qSlicerCoreApplicationInstance as app
from slicer.util import importVTKClassesFromDirectory
......
......@@ -2,7 +2,12 @@ import vtk, qt, ctk
import slicer
from slicer.util import *
import slicer.cli
# HACK Ideally constant from vtkSlicerConfigure should be wrapped,
# that way the following try/except could be avoided.
try:
import slicer.cli
except: pass
#
# loadSlicerRCFile - Let's not add this function to 'slicer.util' so that
......
......@@ -4,8 +4,10 @@ project(qSlicerBaseQTCore)
# Third party library
#
# Required to define ModuleDescriptionParser_INCLUDE_DIRS
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
if(Slicer_BUILD_CLI_SUPPORT)
# Required to define ModuleDescriptionParser_INCLUDE_DIRS
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
endif()
#
# See CMake/SlicerMacroBuildBaseQtLibrary.cmake for details
......@@ -15,13 +17,18 @@ set(KIT_export_directive "Q_SLICER_BASE_QTCORE_EXPORT")
# Additional directories to include
set(KIT_include_directories
${ModuleDescriptionParser_INCLUDE_DIRS}
${MRMLCLI_INCLUDE_DIRS}
${MRMLLogic_INCLUDE_DIRS}
${MRMLDisplayableManager_INCLUDE_DIRS}
${FreeSurfer_INCLUDE_DIRS} # for qSlicerXcedeCatalogIO
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND KIT_include_directories
${ModuleDescriptionParser_INCLUDE_DIRS}
${MRMLCLI_INCLUDE_DIRS}
)
endif()
# Source files
set(KIT_SRCS
qSlicerAbstractCoreModule.cxx
......@@ -73,7 +80,6 @@ set(KIT_MOC_SRCS
# Additional Target libraries (QT libs already included)
set(KIT_target_libraries
ModuleDescriptionParser
SlicerBaseLogic
MRMLDisplayableManager
FreeSurfer # for qSlicerXcedeCatalogIO
......@@ -83,6 +89,12 @@ set(KIT_target_libraries
CTKVisualizationVTKCore
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND KIT_target_libraries
ModuleDescriptionParser
)
endif()
# Resources
set(KIT_resources
Resources/qSlicerBaseQTCore.qrc
......
......@@ -38,6 +38,7 @@
// - Slicer_QtPlugins_DIR
// - Slicer_USE_PYTHONQT
// - Slicer_BUILD_WIN32_CONSOLE
// - Slicer_BUILD_CLI_SUPPORT
#include "vtkSlicerConfigure.h"
#ifdef Slicer_USE_PYTHONQT
......@@ -68,7 +69,9 @@
// MRML includes
#include <vtkCacheManager.h>
#include <vtkMRMLCrosshairNode.h>
#include <vtkMRMLCommandLineModuleNode.h>
#ifdef Slicer_BUILD_CLI_SUPPORT
# include <vtkMRMLCommandLineModuleNode.h>
#endif
// VTK includes
#include <vtkNew.h>
......@@ -816,10 +819,12 @@ void qSlicerCoreApplication::setMRMLScene(vtkMRMLScene* newMRMLScene)
QString workingDirectory = QDir::currentPath();
newMRMLScene->SetRootDirectory(workingDirectory.toLatin1());
#ifdef Slicer_BUILD_CLI_SUPPORT
// Register the node type for the command line modules
// TODO: should probably done in the command line logic
vtkNew<vtkMRMLCommandLineModuleNode> clmNode;
newMRMLScene->RegisterNodeClass(clmNode.GetPointer());
#endif
// First scene needs a crosshair to be added manually
vtkNew<vtkMRMLCrosshairNode> crosshair;
......
......@@ -33,9 +33,13 @@ set(designer_plugin_MOC_SRCS
)
set(designer_plugin_TARGET_LIBRARIES
qSlicerBaseQTCLI
qSlicerBaseQTGUI
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND designer_plugin_TARGET_LIBRARIES
qSlicerBaseQTCLI
)
endif()
qctk_build_designer_plugin(
NAME ${PROJECT_NAME}
......
......@@ -76,12 +76,17 @@ set(SLICER_LIBRARY_PATHS_BUILD
${CTK_DIR}/CTK-build/bin/<CMAKE_CFG_INTDIR>
${QT_LIBRARY_DIR}
${ITK_DIR}/bin/<CMAKE_CFG_INTDIR>
${SlicerExecutionModel_DIR}/ModuleDescriptionParser/bin/<CMAKE_CFG_INTDIR>
${Teem_DIR}/bin/<CMAKE_CFG_INTDIR>
${LibArchive_DIR}/${LIB_SUBDIR}
<APPLAUNCHER_DIR>/bin/<CMAKE_CFG_INTDIR>
)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND SLICER_LIBRARY_PATHS_BUILD
${SlicerExecutionModel_DIR}/ModuleDescriptionParser/bin/<CMAKE_CFG_INTDIR>
)
endif()
# The following lines allow Slicer to load a CLI module extension that depends
# on libraries (i.e a logic class) provided by a loadable module extension.
list(APPEND SLICER_LIBRARY_PATHS_BUILD ../${Slicer_QTLOADABLEMODULES_LIB_DIR})
......@@ -89,7 +94,7 @@ if(CMAKE_CONFIGURATION_TYPES)
list(APPEND SLICER_LIBRARY_PATHS_BUILD ../${Slicer_QTLOADABLEMODULES_LIB_DIR}/<CMAKE_CFG_INTDIR>)
endif()
if(Slicer_BUILD_CLI)
if(Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_CLI)
list(APPEND SLICER_LIBRARY_PATHS_BUILD
<APPLAUNCHER_DIR>/${Slicer_CLIMODULES_LIB_DIR}/<CMAKE_CFG_INTDIR>
)
......@@ -155,7 +160,7 @@ set(SLICER_PATHS_BUILD
${QT_BINARY_DIR}
)
if(Slicer_BUILD_CLI)
if(Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_CLI)
list(APPEND SLICER_PATHS_BUILD
<APPLAUNCHER_DIR>/${Slicer_CLIMODULES_BIN_DIR}/<CMAKE_CFG_INTDIR>
)
......
......@@ -22,6 +22,7 @@ set(Slicer_USE_NUMPY "@Slicer_USE_NUMPY@")
set(Slicer_USE_OpenIGTLink "@Slicer_USE_OpenIGTLink@")
set(Slicer_USE_PYTHONQT "@Slicer_USE_PYTHONQT@")
set(Slicer_USE_PYTHONQT_WITH_TCL "@Slicer_USE_PYTHONQT_WITH_TCL@")
set(Slicer_BUILD_CLI_SUPPORT "@Slicer_BUILD_CLI_SUPPORT@")
# Qt
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(QT_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE_CONFIG@")
......@@ -47,7 +48,9 @@ if(Slicer_USE_PYTHONQT)
endif()
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(qCDashAPI_DIR "@qCDashAPI_DIR_CONFIG@" CACHE PATH "Path to qCDashAPI build or install directory" FORCE)
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(SLICERLIBCURL_DIR "@SLICERLIBCURL_DIR_CONFIG@" CACHE PATH "Path to Curl build or install directory" FORCE)
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(SlicerExecutionModel_DIR "@SlicerExecutionModel_DIR_CONFIG@" CACHE PATH "Path to SlicerExecutionModel build or install directory" FORCE)
if(Slicer_BUILD_CLI_SUPPORT)
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(SlicerExecutionModel_DIR "@SlicerExecutionModel_DIR_CONFIG@" CACHE PATH "Path to SlicerExecutionModel build or install directory" FORCE)
endif()
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(Teem_DIR "@Teem_DIR_CONFIG@" CACHE PATH "Path to Teem build or install directory")
__SLICER_SET_OR_COMPLAIN_IF_DEFINED(VTK_DIR "@VTK_DIR_CONFIG@" CACHE PATH "Path to VTK build or install directory")
......
......@@ -68,14 +68,19 @@ if(Slicer_USE_PYTHONQT)
set(PYTHON_DEBUG_LIBRARY_CONFIG ${PYTHON_DEBUG_LIBRARY})
endif()
endif()
set(SlicerExecutionModel_DIR_CONFIG ${SlicerExecutionModel_DIR})
if(Slicer_BUILD_CLI_SUPPORT)
set(SlicerExecutionModel_DIR_CONFIG ${SlicerExecutionModel_DIR})
endif()
set(SLICERLIBCURL_DIR_CONFIG ${SLICERLIBCURL_DIR})
set(Teem_DIR_CONFIG ${Teem_DIR})
set(VTK_DIR_CONFIG ${VTK_DIR})
# List all required external project
set(Slicer_EXTERNAL_PROJECTS_CONFIG CTK ITK qCDashAPI SlicerExecutionModel SLICERLIBCURL Teem VTK)
set(Slicer_EXTERNAL_PROJECTS_CONFIG CTK ITK qCDashAPI SLICERLIBCURL Teem VTK)
set(Slicer_EXTERNAL_PROJECTS_NO_USEFILE_CONFIG)
if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND Slicer_EXTERNAL_PROJECTS_CONFIG SlicerExecutionModel)
endif()
if(Slicer_USE_BatchMake)
list(APPEND Slicer_EXTERNAL_PROJECTS_CONFIG BatchMake)
endif()
......
......@@ -18,6 +18,7 @@ set(Slicer_MINOR_VERSION "@Slicer_MINOR_VERSION@")
set(Slicer_PATCH_VERSION "@Slicer_PATCH_VERSION@")
# Whether Slicer was built with modules and CLI support.
set(Slicer_BUILD_CLI_SUPPORT "@Slicer_BUILD_CLI_SUPPORT@")
set(Slicer_BUILD_CLI "@Slicer_BUILD_CLI@")
set(Slicer_BUILD_QTLOADABLEMODULES "@Slicer_BUILD_QTLOADABLEMODULES@")
......
......@@ -29,25 +29,34 @@ macro(SlicerMacroBuildModuleLogic)
${ARGN}
)
# Third-party library
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
list(APPEND MODULELOGIC_INCLUDE_DIRECTORIES
${Slicer_Libs_INCLUDE_DIRS}
${Slicer_Base_INCLUDE_DIRS}
${ModuleDescriptionParser_INCLUDE_DIRS}
${Slicer_ModuleLogic_INCLUDE_DIRS}
${Slicer_ModuleMRML_INCLUDE_DIRS}
)
# Note: Linking against qSlicerBaseQTCLI provides logic with
# access to the core application modulemanager. Using the module manager
# a module logic can then use the services provided by registrered
# command line module (CLI).
if(Slicer_BUILD_CLI_SUPPORT)
# Third-party library
find_package(SlicerExecutionModel REQUIRED ModuleDescriptionParser)
list(APPEND MODULELOGIC_INCLUDE_DIRECTORIES
${ModuleDescriptionParser_INCLUDE_DIRS}
)
# Note: Linking against qSlicerBaseQTCLI provides logic with
# access to the core application modulemanager. Using the module manager
# a module logic can then use the services provided by registrered
# command line module (CLI).
list(APPEND MODULELOGIC_TARGET_LIBRARIES
qSlicerBaseQTCLI
)
list(APPEND MODULELOGIC_TARGET_LIBRARIES
qSlicerBaseQTCLI
)
else()
list(APPEND MODULELOGIC_TARGET_LIBRARIES
SlicerBaseLogic
MRMLDisplayableManager
)
endif()
set(MODULELOGIC_NO_INSTALL_OPTION)
if(MODULELOGIC_NO_INSTALL)
......
......@@ -65,7 +65,9 @@ endif()
include(ctkMacroCompilePythonScript)
include(ctkMacroWrapPythonQt)
include(SlicerMacroParseArguments)
include(SlicerMacroBuildCLI)
if(Slicer_BUILD_CLI_SUPPORT)
include(SlicerMacroBuildCLI)
endif()
include(SlicerMacroBuildModuleQtLibrary)
include(SlicerMacroBuildModuleVTKLibrary)
include(SlicerMacroPythonWrapModuleVTKLibrary)
......
......@@ -42,6 +42,7 @@
#define Slicer_QtPlugins_DIR "@Slicer_QtPlugins_DIR@"
#cmakedefine Slicer_BUILD_CLI_SUPPORT
#cmakedefine Slicer_BUILD_CLI
#define Slicer_CLIMODULES_SUBDIR "@Slicer_CLIMODULES_SUBDIR@"
#define Slicer_CLIMODULES_BIN_DIR "@Slicer_CLIMODULES_BIN_DIR@"
......
......@@ -165,7 +165,11 @@ CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_QTSCRIPTEDMODULES "Build Slicer Python QT Modules" ON
"Slicer_USE_PYTHONQT" OFF)
mark_as_advanced(Slicer_BUILD_QTSCRIPTEDMODULES)
option(Slicer_BUILD_CLI "Build Slicer CLI Plugins" ON)
option(Slicer_BUILD_CLI_SUPPORT "Build Slicer with CLI support" ON)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_CLI "Build Slicer CLI Plugins" ON
"Slicer_BUILD_CLI_SUPPORT" OFF
)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_LEGACY_CLI "Build Slicer LEGACY_CLI Plugins" ON
"Slicer_BUILD_CLI" OFF
......@@ -217,17 +221,17 @@ CMAKE_DEPENDENT_OPTION(Slicer_USE_SimpleITK "Build Slicer with SimpleITK support
# module can be enabled/disabled at the superbuild level.
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_BRAINSTOOLS "Build the BRAINS subset of registration and segmentation tools." ON
"Slicer_BUILD_CLI" OFF)
"Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_CLI" OFF)
mark_as_advanced(Slicer_BUILD_BRAINSTOOLS)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_ChangeTrackerPy "Build ChangeTrackerPy." ON
"Slicer_BUILD_QTSCRIPTEDMODULES" OFF)
"Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_QTSCRIPTEDMODULES" OFF)
mark_as_advanced(Slicer_BUILD_ChangeTrackerPy)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_EMSegment "Build EMSegment." ON
"Slicer_BUILD_QTLOADABLEMODULES" OFF)
"Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_QTLOADABLEMODULES" OFF)
mark_as_advanced(Slicer_BUILD_EMSegment)
CMAKE_DEPENDENT_OPTION(
......@@ -238,10 +242,10 @@ mark_as_advanced(CLEAR Slicer_BUILD_OpenIGTLinkIF)
if("${ITK_VERSION_MAJOR}" STREQUAL "4")
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_SkullStripper "Build SkullStripper." ON
"Slicer_BUILD_CLI" OFF)
"Slicer_BUILD_CLI_SUPPORT AND Slicer_BUILD_CLI" OFF)
mark_as_advanced(Slicer_BUILD_SkullStripper)
else()
set(Slicer_BUILD_SkullStripper OFF CACHE BOOL "SkullStripper disabled with ITKv3" FORCE)
set(Slicer_BUILD_SkullStripper OFF CACHE INTERNAL "SkullStripper disabled with ITKv3" FORCE)
endif()
#-----------------------------------------------------------------------------
......@@ -321,14 +325,16 @@ set(Slicer_INCLUDE_DIR "include/Slicer-${Slicer_MAJOR_VERSION}.${Slicer_MINOR_VE
set(Slicer_SHARE_DIR "share/Slicer-${Slicer_MAJOR_VERSION}.${Slicer_MINOR_VERSION}")
set(Slicer_ITKFACTORIES_DIR "${Slicer_LIB_DIR}/ITKFactories")
# NOTE: Make sure to update vtkSlicerApplicationLogic::GetModuleShareDirectory()
# if the following variables are changed.
if(Slicer_BUILD_CLI_SUPPORT)
# NOTE: Make sure to update vtkSlicerApplicationLogic::GetModuleShareDirectory()
# if the following variables are changed.
set(Slicer_CLIMODULES_SUBDIR "cli-modules")
set(Slicer_CLIMODULES_SUBDIR "cli-modules")
set(Slicer_CLIMODULES_BIN_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
set(Slicer_CLIMODULES_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
set(Slicer_CLIMODULES_SHARE_DIR "${Slicer_SHARE_DIR}/${Slicer_CLIMODULES_SUBDIR}")
set(Slicer_CLIMODULES_BIN_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
set(Slicer_CLIMODULES_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
set(Slicer_CLIMODULES_SHARE_DIR "${Slicer_SHARE_DIR}/${Slicer_CLIMODULES_SUBDIR}")
endif()
#-----------------------------------------------------------------------------
# Slicer install directories
......@@ -346,22 +352,24 @@ set(Slicer_INSTALL_INCLUDE_DIR "${Slicer_INSTALL_ROOT}${Slicer_INCLUDE_DIR}")
set(Slicer_INSTALL_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_SHARE_DIR}")
set(Slicer_INSTALL_ITKFACTORIES_DIR "${Slicer_INSTALL_LIB_DIR}/ITKFactories")
set(Slicer_INSTALL_CLIMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_BIN_DIR}")
if(APPLE)
# HACK - On Mac OSX, since all libraries are fixed using the same "install_name" (specifying the
# location of the dependent libraries relatively to the location of Slicer executable), it
# is required for CLI executable to be located at same depth as Slicer executable.
# See also Slicer/Utilities/LastConfigureStep/SlicerCompleteBundles.cmake.in
#
# A more elegant solution would be to create a "Slicer.framework" on which both "Slicer.app"
# and the plugins/extensions (or loadable bundles) would depend on.
#
# NOTE: Make sure to update 'qSlicerCLIExecutableModuleFactory.cxx' if
# the following variable is changed.
set(Slicer_INSTALL_CLIMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}/${Slicer_CLIMODULES_SUBDIR}")
endif()
set(Slicer_INSTALL_CLIMODULES_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_LIB_DIR}")
set(Slicer_INSTALL_CLIMODULES_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_SHARE_DIR}")
if(Slicer_BUILD_CLI_SUPPORT)
set(Slicer_INSTALL_CLIMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_BIN_DIR}")
if(APPLE)
# HACK - On Mac OSX, since all libraries are fixed using the same "install_name" (specifying the
# location of the dependent libraries relatively to the location of Slicer executable), it
# is required for CLI executable to be located at same depth as Slicer executable.
# See also Slicer/Utilities/LastConfigureStep/SlicerCompleteBundles.cmake.in
#
# A more elegant solution would be to create a "Slicer.framework" on which both "Slicer.app"
# and the plugins/extensions (or loadable bundles) would depend on.
#
# NOTE: Make sure to update 'qSlicerCLIExecutableModuleFactory.cxx' if
# the following variable is changed.
set(Slicer_INSTALL_CLIMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}/${Slicer_CLIMODULES_SUBDIR}")
endif()
set(Slicer_INSTALL_CLIMODULES_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_LIB_DIR}")
set(Slicer_INSTALL_CLIMODULES_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_SHARE_DIR}")
endif()