Commit e466bcbc authored by jcfr's avatar jcfr

ENH: Slicer Base libraries, ModuleMRML and ModuleLogic targets are exported

Both global list Slicer_Libs_LIBRARIES and Slicer_Base_LIBRARIES have
been removed. It means libraries are expected to specify explicitly
their dependencies.

Variable Slicer_CORE_LIBRARY and Slicer_GUI_LIBRARY have been introduced.
They should be used each time it's required to link against qSlicerBaseQTCore
or qSlicerBaseQTGUI.

The variable MRML_LIBRARIES has been introduced, it should be used each
time a module is expected to link against the trhee libraries
 MRML, MRMLLogic and MRMLDisplayableManager. The rational behind this variable
is too anticipate a future possible relocation of MRML related libraries
outside of Slicer.

Waiting we setup a way to export the include directory associated with
all libraries so that they can be available to extension using SlicerConfig.
tThese diretories are still automatically appended to the global variables:
Slicer_Libs_INCLUDE_DIRS, Slicer_Base_INCLUDE_DIRS, Slicer_ModuleMRML_INCLUDE_DIRS
and Slicer_ModuleLogic_INCLUDE_DIRS

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16490 3bd1e089-480b-0410-8dfb-8563597acbee
parent c94aa2a4
......@@ -65,15 +65,12 @@ ADD_LIBRARY(${lib_name}
${SlicerQT_SRCS}
${SlicerQT_UI_CXX}
${SlicerQT_QRC_SRCS}
)
)
SET_TARGET_PROPERTIES(${lib_name} PROPERTIES LABELS SlicerQT)
# HACK Since we don't depend on SlicerBaseGUI, remove it from the list
SET(Slicer_BaseQT_LIBRARIES ${Slicer_Base_LIBRARIES})
LIST(REMOVE_ITEM Slicer_BaseQT_LIBRARIES SlicerBaseGUI)
SET(SlicerQT_LIBRARIES
${Slicer_BaseQT_LIBRARIES}
SET(SlicerQT_LIBRARIES
qSlicerBaseQTCLI
qSlicerBaseQTCoreModules
)
IF(Slicer_USE_PYTHONQT)
......@@ -82,7 +79,7 @@ IF(Slicer_USE_PYTHONQT)
qSlicerBaseQTCorePythonQt
qSlicerBaseQTGUIPythonQt
)
ENDIF(Slicer_USE_PYTHONQT)
ENDIF()
target_link_libraries(${lib_name}
${SlicerQT_LIBRARIES}
......
......@@ -80,11 +80,6 @@ IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name} PROPERTIES ${Slicer_LIBRARY_PROPERTIES})
ENDIF()
# --------------------------------------------------------------------------
# Update Slicer_Base_LIBRARIES
# --------------------------------------------------------------------------
SET(Slicer_Base_LIBRARIES ${Slicer_Base_LIBRARIES} ${lib_name} CACHE INTERNAL "Slicer Base libraries" FORCE)
# --------------------------------------------------------------------------
# Build library
# --------------------------------------------------------------------------
......
......@@ -164,11 +164,6 @@ IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name} PROPERTIES ${Slicer_LIBRARY_PROPERTIES})
ENDIF()
# --------------------------------------------------------------------------
# Update Slicer_Base_LIBRARIES
# --------------------------------------------------------------------------
SET(Slicer_Base_LIBRARIES ${Slicer_Base_LIBRARIES} ${lib_name} CACHE INTERNAL "Slicer Base libraries" FORCE)
# --------------------------------------------------------------------------
# Install library
# --------------------------------------------------------------------------
......
......@@ -60,7 +60,6 @@ SET(KIT_resources
SET(KIT_target_libraries
qSlicerBaseQTCore
qSlicerBaseQTGUI
#SlicerBaseLogic
ModuleDescriptionParser
MRMLCLI
)
......
......@@ -156,11 +156,6 @@ MACRO(SlicerMacroBuildBaseQtLibrary)
${SLICERQTBASELIB_QRC_SRCS}
${dynamicHeaders}
)
# --------------------------------------------------------------------------
# Update Slicer_Base_LIBRARIES
# --------------------------------------------------------------------------
SET(Slicer_Base_LIBRARIES ${Slicer_Base_LIBRARIES} ${lib_name} CACHE INTERNAL "Slicer Base libraries" FORCE)
# --------------------------------------------------------------------------
# Build the library
......@@ -225,5 +220,10 @@ MACRO(SlicerMacroBuildBaseQtLibrary)
SET_TARGET_PROPERTIES(${lib_name}PythonQt PROPERTIES COMPILE_FLAGS "-fPIC")
ENDIF()
ENDIF()
# --------------------------------------------------------------------------
# Export target
# --------------------------------------------------------------------------
SET_PROPERTY(GLOBAL APPEND PROPERTY Slicer_TARGETS ${SLICERQTBASELIB_NAME})
ENDMACRO()
......@@ -136,5 +136,10 @@ MACRO(SlicerMacroBuildModuleLibrary)
DESTINATION ${Slicer_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR}/${MODULELIBRARY_NAME} COMPONENT Development
)
ENDIF()
# --------------------------------------------------------------------------
# Export target
# --------------------------------------------------------------------------
SET_PROPERTY(GLOBAL APPEND PROPERTY Slicer_TARGETS ${MODULELIBRARY_NAME})
ENDMACRO()
......@@ -33,13 +33,16 @@ MACRO(SlicerMacroBuildModuleLogic)
${Slicer_Libs_INCLUDE_DIRS}
${Slicer_Base_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).
LIST(APPEND MODULELOGIC_TARGET_LIBRARIES
${Slicer_Libs_LIBRARIES}
SlicerBaseLogic
SlicerBaseCLI
${Slicer_ModuleLogic_LIBRARIES}
qSlicerBaseQTCLI
)
SlicerMacroBuildModuleLibrary(
......@@ -51,18 +54,15 @@ MACRO(SlicerMacroBuildModuleLogic)
)
#-----------------------------------------------------------------------------
# Update Slicer_ModuleLogic_INCLUDE_DIRS and Slicer_ModuleLogic_LIBRARIES
# Update Slicer_ModuleLogic_INCLUDE_DIRS
#-----------------------------------------------------------------------------
SET(Slicer_ModuleLogic_INCLUDE_DIRS
${Slicer_ModuleLogic_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "Slicer Module logic includes" FORCE)
SET(Slicer_ModuleLogic_LIBRARIES
${Slicer_ModuleLogic_LIBRARIES}
${MODULELOGIC_NAME}
CACHE INTERNAL "Slicer Module logic libraries" FORCE)
IF(Slicer_SOURCE_DIR)
SET(Slicer_ModuleLogic_INCLUDE_DIRS
${Slicer_ModuleLogic_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "Slicer Module logic includes" FORCE)
ENDIF()
# --------------------------------------------------------------------------
# Python wrapping
......
......@@ -33,11 +33,6 @@ MACRO(SlicerMacroBuildModuleMRML)
${Slicer_Libs_INCLUDE_DIRS}
${Slicer_ModuleMRML_INCLUDE_DIRS}
)
LIST(APPEND MODULEMRML_TARGET_LIBRARIES
${Slicer_Libs_LIBRARIES}
${Slicer_ModuleMRML_LIBRARIES}
)
SlicerMacroBuildModuleLibrary(
NAME ${MODULEMRML_NAME}
......@@ -48,18 +43,15 @@ MACRO(SlicerMacroBuildModuleMRML)
)
#-----------------------------------------------------------------------------
# Update Slicer_ModuleMRML_INCLUDE_DIRS and Slicer_ModuleMRML_LIBRARIES
# Update Slicer_ModuleMRML_INCLUDE_DIRS
#-----------------------------------------------------------------------------
SET(Slicer_ModuleMRML_INCLUDE_DIRS
${Slicer_ModuleMRML_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "Slicer Module MRML includes" FORCE)
SET(Slicer_ModuleMRML_LIBRARIES
${Slicer_ModuleMRML_LIBRARIES}
${ModuleMRML_NAME}
CACHE INTERNAL "Slicer Module MRML libraries" FORCE)
IF(Slicer_SOURCE_DIR)
SET(Slicer_ModuleMRML_INCLUDE_DIRS
${Slicer_ModuleMRML_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "Slicer Module MRML includes" FORCE)
ENDIF()
# --------------------------------------------------------------------------
# Python wrapping
......
......@@ -62,8 +62,8 @@ MACRO(slicerMacroBuildQtModule)
${CMAKE_CURRENT_BINARY_DIR}
${Slicer_Libs_INCLUDE_DIRS}
${Slicer_Base_INCLUDE_DIRS}
${MRMLLogic_SOURCE_DIR}
${MRMLLogic_BINARY_DIR}
${Slicer_ModuleLogic_INCLUDE_DIRS}
${Slicer_ModuleMRML_INCLUDE_DIRS}
${QTMODULE_INCLUDE_DIRECTORIES}
)
......@@ -141,8 +141,7 @@ MACRO(slicerMacroBuildQtModule)
SET_TARGET_PROPERTIES(${lib_name} PROPERTIES LABELS ${lib_name})
TARGET_LINK_LIBRARIES(${lib_name}
${Slicer_Libs_LIBRARIES}
${Slicer_Base_LIBRARIES}
${Slicer_GUI_LIBRARY}
${QTMODULE_TARGET_LIBRARIES}
)
......
......@@ -209,9 +209,7 @@ IF(Slicer_SUPERBUILD)
RETURN()
ENDIF()
#-----------------------------------------------------------------------------
# Clear SlicerTargets.cmake
#------------------------------------------------------------------------------
FILE(WRITE "${Slicer_BINARY_DIR}/SlicerTargets.cmake"
"# Generated by CMake, do not edit!")
......@@ -266,8 +264,6 @@ ENDIF()
#
SET(Slicer_Base_LIBRARIES CACHE INTERNAL "Slicer Base libraries" FORCE)
SET(Slicer_ModuleLogic_LIBRARIES CACHE INTERNAL "Slicer Module logic libraries" FORCE)
SET(Slicer_Base_INCLUDE_DIRS CACHE INTERNAL "Slicer Base includes" FORCE)
SET(Slicer_ModuleLogic_INCLUDE_DIRS CACHE INTERNAL "Slicer Module logic includes" FORCE)
SET(Slicer_ModuleMRML_INCLUDE_DIRS CACHE INTERNAL "Slicer Module logic includes" FORCE)
......@@ -528,6 +524,12 @@ INCLUDE(SlicerMacroPythonWrapModuleLibrary)
INCLUDE(SlicerMacroBuildModuleLogic)
INCLUDE(SlicerMacroBuildModuleMRML)
#-----------------------------------------------------------------------------
# Slicer Core and GUI library
#-----------------------------------------------------------------------------
SET(Slicer_CORE_LIBRARY qSlicerBaseQTCore)
SET(Slicer_GUI_LIBRARY qSlicerBaseQTGUI)
#-----------------------------------------------------------------------------
# Module Logic
#-----------------------------------------------------------------------------
......
......@@ -27,18 +27,13 @@ SET(Slicer_README_FILE_CONFIG ${Slicer_SOURCE_DIR}/README.txt)
# Path to extension CPack script
set(Slicer_EXTENSION_CPACK_CONFIG ${Slicer_SOURCE_DIR}/SlicerExtensionCPack.cmake)
SET(Slicer_Libs_INCLUDE_DIRS_CONFIG ${Slicer_Libs_INCLUDE_DIRS})
SET(Slicer_Libs_LIBRARY_DIRS_CONFIG ${Slicer_BINARY_DIR}/bin ${Slicer_BINARY_DIR}/lib)
SET(Slicer_GUI_LIBRARY_CONFIG ${Slicer_GUI_LIBRARY})
SET(Slicer_CORE_LIBRARY_CONFIG ${Slicer_CORE_LIBRARY})
SET(Slicer_Libs_INCLUDE_DIRS_CONFIG ${Slicer_Libs_INCLUDE_DIRS})
SET(Slicer_Base_INCLUDE_DIRS_CONFIG ${Slicer_Base_INCLUDE_DIRS})
SET(Slicer_Base_LIBRARY_DIRS_CONFIG ${Slicer_BINARY_DIR}/bin)
SET(Slicer_ModuleLogic_INCLUDE_DIRS_CONFIG ${Slicer_ModuleLogic_INCLUDE_DIRS})
SET(Slicer_ModuleLogic_LIBRARY_DIRS_CONFIG ${CMAKE_BINARY_DIR}/${Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR})
SET(Slicer_ModuleMRML_INCLUDE_DIRS_CONFIG ${Slicer_ModuleMRML_INCLUDE_DIRS})
SET(Slicer_ModuleMRML_LIBRARY_DIRS_CONFIG ${CMAKE_BINARY_DIR}/${Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR})
# Qt
SET(QT_QMAKE_EXECUTABLE_CONFIG ${QT_QMAKE_EXECUTABLE})
......@@ -65,7 +60,10 @@ IF(Slicer_USE_BatchMake)
LIST(APPEND Slicer_EXTERNAL_PROJECTS_CONFIG BatchMake)
ENDIF()
# Configure SlicerConfig.cmake for the install tree.
# Export Targets file.
SET(Slicer_TARGETS_FILE "${Slicer_BINARY_DIR}/SlicerTargets.cmake")
# Configure SlicerConfig.cmake for the build tree.
CONFIGURE_FILE(
${Slicer_SOURCE_DIR}/SlicerConfig.cmake.in
${Slicer_BINARY_DIR}/SlicerConfig.cmake @ONLY)
......
......@@ -73,14 +73,20 @@ ENDFOREACH()
# Since there is inconsistency between library name and project/dir name,
# let's tweak the list of generated library names
STRING(REPLACE MGHImageIO MGHIO libs "${libs}")
STRING(REPLACE MRMLIDImageIO MRMLIDIO libs "${libs}")
LIST(REMOVE_ITEM libs SlicerExecutionModel) # Not a library
#STRING(REPLACE MGHImageIO MGHIO libs "${libs}")
#STRING(REPLACE MRMLIDImageIO MRMLIDIO libs "${libs}")
#LIST(REMOVE_ITEM libs SlicerExecutionModel) # Not a library
# Anticipating the move of MRML related libraries to a standalone project,
# let's group these libraries.
# Note also that since MRMLIDImageIO is an ITK plugin it is NOT added to that list.
SET(MRML_LIBRARIES
MRML MRMLCLI MRMLLogic MRMLDisplayableManager
CACHE INTERNAL "MRML libraries" FORCE)
#-----------------------------------------------------------------------------
# Set variable Slicer_Libs_LIBRARIES and Slicer_Libs_INCLUDE_DIRS
# Set variable Slicer_Libs_INCLUDE_DIRS
#-----------------------------------------------------------------------------
SET(Slicer_Libs_LIBRARIES ${libs} CACHE INTERNAL "Slicer Libs libraries" FORCE)
SET(Slicer_Libs_INCLUDE_DIRS ${include_dirs} CACHE INTERNAL "Slicer Libs includes" FORCE)
#-----------------------------------------------------------------------------
......
......@@ -66,6 +66,7 @@ SET(module_mrml_SRCS
# Additional Target libraries
SET(module_mrml_target_libraries
${ITK_LIBRARIES}
${MRML_LIBRARIES}
)
SlicerMacroBuildModuleMRML(
......
......@@ -24,6 +24,7 @@ SET(module_mrml_SRCS
# Additional Target libraries
SET(module_mrml_target_libraries
${ITK_LIBRARIES}
${MRML_LIBRARIES}
)
SlicerMacroBuildModuleMRML(
......
......@@ -92,42 +92,27 @@ SET(Slicer_LOGOS_RESOURCE "@Slicer_LOGOS_RESOURCE@")
# Slicer home (top of the tree)
set(Slicer_HOME "@Slicer_HOME@")
# Slicer Libs libraries. Those listed here should
# automatically pull in their dependencies.
set(Slicer_Libs_LIBRARIES "@Slicer_Libs_LIBRARIES@")
# Slicer Core library
set(Slicer_CORE_LIBRARY @Slicer_CORE_LIBRARY_CONFIG@)
# Slicer GUI library
set(Slicer_GUI_LIBRARY @Slicer_GUI_LIBRARY_CONFIG@)
# MRML libraries
set(MRML_LIBRARIES @MRML_LIBRARIES@)
# Slicer Libs VTK wrapped libraries
set(Slicer_Libs_VTK_WRAPPED_LIBRARIES "@Slicer_Libs_VTK_WRAPPED_LIBRARIES@")
# Slicer Libs library directories.
set(Slicer_Libs_LIBRARY_DIRS "@Slicer_Libs_LIBRARY_DIRS_CONFIG@")
# Slicer Libs include file directories.
set(Slicer_Libs_INCLUDE_DIRS "@Slicer_Libs_INCLUDE_DIRS_CONFIG@")
# Slicer Base libraries. Those listed here should
# automatically pull in their dependencies.
set(Slicer_Base_LIBRARIES "@Slicer_Base_LIBRARIES@")
# Slicer Base library directories.
set(Slicer_Base_LIBRARY_DIRS "@Slicer_Base_LIBRARY_DIRS_CONFIG@")
# Slicer Base include file directories.
set(Slicer_Base_INCLUDE_DIRS "@Slicer_BINARY_DIR@" "@Slicer_Base_INCLUDE_DIRS_CONFIG@")
# Slicer Module logic libraries. Those listed here should
# automatically pull in their dependencies.
set(Slicer_ModuleLogic_LIBRARIES "@Slicer_ModuleLogic_LIBRARIES@")
# Slicer Module logic library directories.
set(Slicer_ModuleLogic_LIBRARY_DIRS "@Slicer_ModuleLogic_LIBRARY_DIRS_CONFIG@")
# Slicer Module logic include file directories.
set(Slicer_ModuleLogic_INCLUDE_DIRS "@Slicer_ModuleLogic_INCLUDE_DIRS_CONFIG@")
# Slicer Module MRML library directories.
set(Slicer_ModuleMRML_LIBRARY_DIRS "@Slicer_ModuleMRML_LIBRARY_DIRS_CONFIG@")
# Slicer Module MRML include file directories.
set(Slicer_ModuleMRML_INCLUDE_DIRS "@Slicer_ModuleMRML_INCLUDE_DIRS_CONFIG@")
......@@ -157,3 +142,8 @@ ENDIF()
# The Slicer install prefix (*not* defined in the install tree)
set(Slicer_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
# The Slicer targets file.
IF(EXISTS "@Slicer_TARGETS_FILE@")
INCLUDE("@Slicer_TARGETS_FILE@")
ENDIF()
......@@ -46,10 +46,6 @@ get_filename_component(Slicer_HOME ${Slicer_HOME} ABSOLUTE)
# The CMake macros dir.
set(Slicer_CMAKE_DIR "${Slicer_HOME}/@Slicer_INSTALL_LIB_DIR@/CMake")
# Slicer Libs libraries. Those listed here should
# automatically pull in their dependencies.
set(Slicer_Libs_LIBRARIES "@Slicer_Libs_LIBRARIES@")
# Slicer Libs library directories.
set(Slicer_Libs_LIBRARY_DIRS
"${Slicer_HOME}/lib/FreeSurfer"
......@@ -85,10 +81,6 @@ set(Slicer_Libs_INCLUDE_DIRS
"${Slicer_HOME}/include/vtkTeem"
)
# Slicer Base libraries. Those listed here should
# automatically pull in their dependencies.
set(Slicer_Base_LIBRARIES "@Slicer_Base_LIBRARIES@")
# Slicer Base library directories.
set(Slicer_Base_LIBRARY_DIRS
"${Slicer_HOME}/@Slicer_INSTALL_LIB_DIR@"
......
......@@ -44,19 +44,12 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${Slicer_REQUIRED_C_FLAGS} ${ITK_REQUIR
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${Slicer_REQUIRED_CXX_FLAGS} ${ITK_REQUIRED_CXX_FLAGS} ${VTK_REQUIRED_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}" CACHE STRING "CMake CXX Flags" FORCE)
#-----------------------------------------------------------------------------
# Link directories
# Static or Shared library
#------------------------------------------------------------------------------
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ${Slicer_BUILD_SHARED})
endif()
link_directories(
${Slicer_Libs_LIBRARY_DIRS}
${Slicer_Base_LIBRARY_DIRS}
${Slicer_ModuleLogic_LIBRARY_DIRS}
${Slicer_ModuleMRML_LIBRARY_DIRS}
)
#-----------------------------------------------------------------------------
# Include directories - See SlicerMacroBuildQtModule
#------------------------------------------------------------------------------
......
......@@ -28,10 +28,15 @@
# end of CMakeLists processing, i.e. instead of waiting until some variables
# are configured in SUBDIRS.
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
${Slicer_SOURCE_DIR}/UseSlicer.cmake.in
${Slicer_BINARY_DIR}/UseSlicer.cmake COPYONLY)
#-----------------------------------------------------------------------------
GET_PROPERTY(Slicer_TARGETS GLOBAL PROPERTY Slicer_TARGETS)
EXPORT(TARGETS ${Slicer_TARGETS} APPEND FILE ${Slicer_BINARY_DIR}/SlicerTargets.cmake)
#-----------------------------------------------------------------------------
# Create the SlicerConfig.cmake file containing the Slicer configuration.
# Since it might generate configuration file depending
......
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