Commit b3b4cc13 authored by lassoan's avatar lassoan

ENH: Generate (Extension)Config.cmake

Generate (Extension)Config.cmake to allow an extension import targets from another extension.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@25944 3bd1e089-480b-0410-8dfb-8563597acbee
parent 4d9cc575
......@@ -166,6 +166,9 @@ set(Slicer_README_FILE "@Slicer_README_FILE_CONFIG@")
set(Slicer_CXX_MODULE_TEST_TEMPLATES_DIR "@Slicer_CXX_MODULE_TEST_TEMPLATES_DIR_CONFIG@")
set(Slicer_PYTHON_MODULE_TEST_TEMPLATES_DIR "@Slicer_PYTHON_MODULE_TEST_TEMPLATES_DIR_CONFIG@")
# Script for generating <Extension>Config.cmake
set(Slicer_EXTENSION_GENERATE_CONFIG "@Slicer_EXTENSION_GENERATE_CONFIG@")
# Path to extension CPack script
set(Slicer_EXTENSION_CPACK "@Slicer_EXTENSION_CPACK_CONFIG@")
set(Slicer_EXTENSION_CPACK_BUNDLE_FIXUP "@Slicer_EXTENSION_CPACK_BUNDLE_FIXUP_CONFIG@")
......
#
# This file makes available modules implemented in this extension to other extensions.
#
@EXTENSION_SOURCE_DIR_CONFIG@
@EXTENSION_CUSTOM_CONFIG@
# --------------------------------------------------------------------------
# Include directories
# Extension include directories for module
@EXTENSION_INCLUDE_MODULE_DIRS_CONFIG@
# Extension include directories for module logic
@EXTENSION_INCLUDE_MODULE_LOGIC_DIRS_CONFIG@
# Extension include directories for module mrml
@EXTENSION_INCLUDE_MODULE_MRML_DIRS_CONFIG@
# Extension include directories for module Widget
@EXTENSION_INCLUDE_MODULE_WIDGET_DIRS_CONFIG@
# Extension Module logic include file directories.
set(@EXTENSION_NAME@_ModuleLogic_INCLUDE_DIRS "@EXTENSION_ModuleLogic_INCLUDE_DIRS_CONFIG@"
CACHE INTERNAL "Extension Module logic includes" FORCE)
# Extension Module MRML include file directories.
set(@EXTENSION_NAME@_ModuleMRML_INCLUDE_DIRS "@EXTENSION_ModuleMRML_INCLUDE_DIRS_CONFIG@"
CACHE INTERNAL "Extension Module MRML includes" FORCE)
# Extension Module Widgets include file directories.
set(@EXTENSION_NAME@_ModuleWidgets_INCLUDE_DIRS "@EXTENSION_ModuleWidgets_INCLUDE_DIRS_CONFIG@"
CACHE INTERNAL "Extension Module widgets includes" FORCE)
# --------------------------------------------------------------------------
# Target definitions
if(EXISTS "@EXTENSION_TARGETS_FILE@")
include("@EXTENSION_TARGETS_FILE@")
endif()
# Generate the <Extension>Config.cmake file in the build tree.
# This file makes it possible for an extension to depend on targets defined
# in other extensions.
# This file is based on SlicerGenerateSlicerConfig.cmake.
#
# Example:
#
# Add these lines near the end of top-level CMakeLists.txt in Sequences extension
# to allow other extensions to use it.
#
# # Pass some custom content to the SequencesConfig.cmake file (optional)
# set(Sequences_CUSTOM_CONFIG "message(STATUS \"Test\")")
#
# # Generate SequencesConfig.cmake
# include(${Slicer_EXTENSION_GENERATE_CONFIG})
#
# Add these lines to the CMakeLists.txt to use vtkMRMLSequenceNode
# implemented in Sequences extension:
#
# find_package(Sequences REQUIRED)
# ...
# set(MODULE_INCLUDE_DIRECTORIES
# ...
# ${vtkSlicerSequencesModuleMRML_INCLUDE_DIRS}
# )
# ...
# set(MODULE_TARGET_LIBRARIES
# ...
# vtkSlicerSequencesModuleMRML
# )
#
get_property(_module_targets GLOBAL PROPERTY SLICER_MODULE_TARGETS)
if(_module_targets)
foreach(target ${_module_targets})
set(EXTENSION_INCLUDE_MODULE_DIRS_CONFIG
"${EXTENSION_INCLUDE_MODULE_DIRS_CONFIG}
set(${target}_INCLUDE_DIRS
\"${${target}_INCLUDE_DIRS}\")"
)
endforeach()
endif()
get_property(_module_logic_targets GLOBAL PROPERTY SLICER_MODULE_LOGIC_TARGETS)
if(_module_logic_targets)
foreach(target ${_module_logic_targets})
set(EXTENSION_INCLUDE_MODULE_LOGIC_DIRS_CONFIG
"${EXTENSION_INCLUDE_MODULE_LOGIC_DIRS_CONFIG}
set(${target}_INCLUDE_DIRS
\"${${target}_INCLUDE_DIRS}\")"
)
list(APPEND EXTENSION_ModuleLogic_INCLUDE_DIRS_CONFIG "\${${target}_INCLUDE_DIRS}")
endforeach()
endif()
get_property(_module_mrml_targets GLOBAL PROPERTY SLICER_MODULE_MRML_TARGETS)
if(_module_mrml_targets)
foreach(target ${_module_mrml_targets})
set(EXTENSION_INCLUDE_MODULE_MRML_DIRS_CONFIG
"${EXTENSION_INCLUDE_MODULE_MRML_DIRS_CONFIG}
set(${target}_INCLUDE_DIRS
\"${${target}_INCLUDE_DIRS}\")"
)
list(APPEND EXTENSION_ModuleMRML_INCLUDE_DIRS_CONFIG "\${${target}_INCLUDE_DIRS}")
endforeach()
endif()
get_property(_module_widget_targets GLOBAL PROPERTY SLICER_MODULE_WIDGET_TARGETS)
if(_module_widget_targets)
foreach(target ${_module_widget_targets})
set(EXTENSION_INCLUDE_MODULE_WIDGET_DIRS_CONFIG
"${EXTENSION_INCLUDE_MODULE_WIDGET_DIRS_CONFIG}
set(${target}_INCLUDE_DIRS
\"${${target}_INCLUDE_DIRS}\")"
)
list(APPEND EXTENSION_ModuleWidgets_INCLUDE_DIRS_CONFIG "\${${target}_INCLUDE_DIRS}")
endforeach()
endif()
set(EXTENSION_SOURCE_DIR_CONFIG "set(${EXTENSION_NAME}_SOURCE_DIR \"${${EXTENSION_NAME}_SOURCE_DIR}\")")
# Allow extensions to add some custom content.
if(${EXTENSION_NAME}_CUSTOM_CONFIG)
set(EXTENSION_CUSTOM_CONFIG "${${EXTENSION_NAME}_CUSTOM_CONFIG}")
else()
set(EXTENSION_CUSTOM_CONFIG "")
endif()
# Export Targets file.
set(EXTENSION_TARGETS_FILE "${EXTENSION_SUPERBUILD_BINARY_DIR}/${EXTENSION_NAME}Targets.cmake")
get_property(Slicer_TARGETS GLOBAL PROPERTY Slicer_TARGETS)
export(TARGETS ${Slicer_TARGETS} FILE ${EXTENSION_TARGETS_FILE})
# Configure <Extension>Config.cmake for the build tree.
configure_file(
${Slicer_CMAKE_DIR}/SlicerExtensionConfig.cmake.in
${EXTENSION_SUPERBUILD_BINARY_DIR}/${EXTENSION_NAME}Config.cmake @ONLY)
......@@ -987,6 +987,7 @@ configure_file(
${Slicer_SOURCE_DIR}/CMake/SlicerConfigVersion.cmake.in
${Slicer_BINARY_DIR}/SlicerConfigVersion.cmake @ONLY)
set(Slicer_EXTENSION_GENERATE_CONFIG ${Slicer_SOURCE_DIR}/CMake/SlicerExtensionGenerateConfig.cmake)
set(Slicer_EXTENSION_CPACK ${Slicer_SOURCE_DIR}/CMake/SlicerExtensionCPack.cmake)
......
......@@ -22,4 +22,5 @@ include(${Slicer_USE_FILE})
## NEXT_MODULE
#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
......@@ -40,4 +40,5 @@ endif()
#-----------------------------------------------------------------------------
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};ALL;/")
#set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${Foo_DIR};Foo;RuntimeLibraries;/")
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
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