Commit 157465c9 authored by jcfr's avatar jcfr
Browse files

ENH: Update ExtensionTemplate CMakeLists.txt to consider UseSlicer and generate the s4ext file

It also possible to package the extension building the 'package' target

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16395 3bd1e089-480b-0410-8dfb-8563597acbee
parent 369ec8e4
......@@ -2,46 +2,43 @@
cmake_minimum_required(VERSION 2.8.2)
#-----------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Slicer Package
#------------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
#-----------------------------------------------------------------------------
if(POLICY CMP0016)
CMAKE_POLICY(SET CMP0016 NEW)
endif()
if(POLICY CMP0017)
CMAKE_POLICY(SET CMP0017 OLD)
endif()
IF (Slicer_SOURCE_DIR)
MESSAGE("Slicer_INCLUDE_DIR: ${Slicer_INCLUDE_DIR}")
ELSE (Slicer_SOURCE_DIR)
FIND_PACKAGE(Slicer REQUIRED)
INCLUDE(${Slicer_USE_FILE})
ENDIF (Slicer_SOURCE_DIR)
# Module name (usually identique to the directory name)
SET(EXTENSION_NAME ExtensionTemplate)
#------------------------------------------------------------------------------
# Qt Package
#------------------------------------------------------------------------------
SET(minimum_required_qt_version "4.6.2")
IF(NOT Slicer_SOURCE_DIR)
# Module name (usually identique to the directory name)
FIND_PACKAGE(Qt4)
IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "error: Qt >= ${minimum_required_qt_version} was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable.")
ENDIF()
SET(qt_module_name ExtensionTemplate)
SET(EXTENSION_HOMEPAGE "http://www.slicer.org/slicerWiki/index.php/Slicer4:Developers:Projects:QtSlicer/Tutorials/ExtensionWriting")
SET(EXTENSION_CATEGORY "Examples")
SET(EXTENSION_STATUS "Beta")
SET(EXTENSION_DESCRIPTION "This is an example of Qt loadable module built as an extension")
# Check version, note that ${QT_VERSION_PATCH} could also be used
IF("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" VERSION_LESS "${minimum_required_qt_version}")
MESSAGE(FATAL_ERROR "error: Slicer requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}. ${extra_error_message}")
ENDIF()
FIND_PACKAGE(Slicer REQUIRED)
SET(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional ${EXTENSION_NAME} C Flags")
SET(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional ${EXTENSION_NAME} CXX Flags")
INCLUDE(${Slicer_USE_FILE})
SET(EXTENSION_LICENSE_FILE ${Slicer_LICENSE_FILE})
SET(EXTENSION_README_FILE ${Slicer_README_FILE})
MESSAGE(STATUS "Configuring Slicer with Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
ENDIF()
# Includes Qt headers
INCLUDE(${QT_USE_FILE})
# Add subdirectories
ADD_SUBDIRECTORY(Logic)
SET(qt_module_export_directive "Q_SLICER_QTMODULES_EXTENSIONTEMPLATE_EXPORT")
# Module name (usually identique to the directory name)
SET(qt_module_name "ExtensionTest")
# Additional includes - Current_{source,binary} and Slicer_{Libs,Base} already included
SET(qt_module_include_directories
......@@ -79,7 +76,7 @@ SET(qt_module_resources
)
slicerMacroBuildQtModule(
NAME ${qt_module_name}
NAME ${EXTENSION_NAME}
EXPORT_DIRECTIVE ${qt_module_export_directive}
INCLUDE_DIRECTORIES ${qt_module_include_directories}
SRCS ${qt_module_SRCS}
......@@ -93,3 +90,18 @@ slicerMacroBuildQtModule(
if(BUILD_TESTING)
#add_subdirectory(Testing)
endif(BUILD_TESTING)
IF(NOT Slicer_SOURCE_DIR)
INCLUDE(SlicerFunctionGenerateExtensionDescription)
slicerFunctionGenerateExtensionDescription(
EXTENSION_NAME ${EXTENSION_NAME}
EXTENSION_CATEGORY ${EXTENSION_CATEGORY}
EXTENSION_STATUS ${EXTENSION_STATUS}
EXTENSION_HOMEPAGE ${EXTENSION_HOMEPAGE}
EXTENSION_DESCRIPTION ${EXTENSION_DESCRIPTION}
DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR}
SLICER_WC_REVISION ${Slicer_WC_REVISION}
SLICER_WC_ROOT ${Slicer_WC_ROOT}
)
INCLUDE(${Slicer_EXTENSION_CPACK})
ENDIF()
project(vtkSlicerExtensionTestModuleLogic)
PROJECT(vtkSlicer${EXTENSION_NAME}ModuleLogic)
#
# See CMake/SlicerMacroBuildModuleLogic.cmake for details
......@@ -7,7 +7,7 @@ project(vtkSlicerExtensionTestModuleLogic)
SET(module_logic_name "${PROJECT_NAME}")
# The header '${PROJECT_NAME}Export.h' will be automatically configured.
SET(module_logic_export_directive "VTK_SLICER_EXTENSIONTEST_MODULE_LOGIC_EXPORT")
SET(module_logic_export_directive "VTK_SLICER_EXTENSIONTEMPLATE_MODULE_LOGIC_EXPORT")
# Additional directories to include
SET(module_logic_include_directories
......@@ -21,14 +21,17 @@ SET(module_logic_SRCS
# Additional Target libraries
SET(module_logic_target_libraries
${CTK_LIBRARIES}
${ITK_LIBRARIES}
${QT_LIBRARIES}
${VTK_LIBRARIES}
)
SlicerMacroBuildModuleLogic(
NAME ${module_logic_name}
EXPORT_DIRECTIVE ${module_logic_export_directive}
INCLUDE_DIRECTORIES ${module_logic_include_directories}
SRCS ${module_logic_SRCS}
TARGET_LIBRARIES ${module_logic_target_libraries}
DISABLE_WRAP_PYTHON
)
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) 2010 Kitware Inc.
#
# See Doc/copyright/copyright.txt
# or http://www.slicer.org/copyright/copyright.txt for details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 3P41RR013218-12S1
#
################################################################################
# -------------------------------------------------------------------------
# Sanity checks
# -------------------------------------------------------------------------
SET(expected_nonempty_vars EXTENSION_NAME EXTENSION_DESCRIPTION Slicer_WC_REVISION Slicer_BUILD)
FOREACH(var ${expected_nonempty_vars})
IF("${${var}}" STREQUAL "")
MESSAGE(FATAL_ERROR "error: ${var} is either NOT defined or empty.")
ENDIF()
ENDFOREACH()
SET(expected_existing_vars EXTENSION_README_FILE EXTENSION_LICENSE_FILE)
FOREACH(var ${expected_existing_vars})
IF(NOT EXISTS ${${var}})
MESSAGE(FATAL_ERROR "error: ${var} points to an inexistent file: ${${var}}")
ENDIF()
ENDFOREACH()
#-----------------------------------------------------------------------------
# Get sytem name and architecture
#-----------------------------------------------------------------------------
INCLUDE(SlicerMacroDiscoverSystemNameAndBits)
SlicerMacroDiscoverSystemNameAndBits(VAR_PREFIX ${EXTENSION_NAME})
#-----------------------------------------------------------------------------
# Get working copy information
#-----------------------------------------------------------------------------
SlicerMacroExtractRepositoryInfo(VAR_PREFIX ${EXTENSION_NAME})
#-----------------------------------------------------------------------------
# Get today's date
#-----------------------------------------------------------------------------
INCLUDE(SlicerFunctionToday)
TODAY(${EXTENSION_NAME}_BUILDDATE)
# -------------------------------------------------------------------------
# Package properties
# -------------------------------------------------------------------------
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${EXTENSION_DESCRIPTION}")
SET(CPACK_MONOLITHIC_INSTALL ON)
set(CMAKE_PROJECT_NAME ${EXTENSION_NAME})
set(CPACK_PACKAGE_VENDOR "NA-MIC")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${EXTENSION_README_FILE}")
set(CPACK_RESOURCE_FILE_LICENSE "${EXTENSION_LICENSE_FILE}")
set(CPACK_PACKAGE_FILE_NAME "${Slicer_WC_REVISION}-${Slicer_BUILD}-${EXTENSION_NAME}-${${EXTENSION_NAME}_WC_TYPE}${${EXTENSION_NAME}_WC_REVISION}-${${EXTENSION_NAME}_BUILDDATE}-${${EXTENSION_NAME}_BUILD}")
#set(CPACK_PACKAGE_VERSION_MAJOR "${Slicer_VERSION_MAJOR}")
#set(CPACK_PACKAGE_VERSION_MINOR "${Slicer_VERSION_MINOR}")
#set(CPACK_PACKAGE_VERSION_PATCH "${Slicer_VERSION_PATCH}")
#if(APPLE)
# set(CPACK_PACKAGE_ICON "${Slicer_SOURCE_DIR}/Applications/SlicerQT/Resources/Slicer.icns")
#endif()
# Slicer does *NOT* require setting the windows path
set(CPACK_NSIS_MODIFY_PATH OFF)
# -------------------------------------------------------------------------
# Disable generator enabled by default
# -------------------------------------------------------------------------
set(CPACK_BINARY_TZ OFF CACHE BOOL "Enable to build TZ packages")
set(CPACK_BINARY_STGZ OFF CACHE BOOL "Enable to build STGZ packages")
set(CPACK_SOURCE_TBZ2 OFF CACHE BOOL "Enable to build TBZ2 source packages")
set(CPACK_SOURCE_TZ OFF CACHE BOOL "Enable to build TZ source packages")
include(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