소스 검색

ENH: Remove ZMQ code from CTK source tree. Using CMake patch version from git://github.com/PatrickCheng/zeromq2.git. Adding skeleton classes for messaging services components based on zeroMQ

Patrick Cheng 15 년 전
부모
커밋
cd65a1502e

+ 20 - 17
CMakeExternals/ZMQ.cmake

@@ -1,18 +1,21 @@
-#
-# ZMQ
-#
-SET(ZMQ_DEPENDS)
-ctkMacroShouldAddExternalProject(ZMQ_LIBRARIES add_project)
-IF(${add_project})
-  SET(proj ZMQ)
-#   MESSAGE(STATUS "Adding project:${proj}")
-  SET(ZMQ_DEPENDS ${proj})
-  ExternalProject_Add(${proj}
-      DOWNLOAD_COMMAND ""
-      INSTALL_COMMAND ""
-      CMAKE_GENERATOR ${gen}
-      SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ZMQ
-      CMAKE_ARGS
-        ${ep_common_args}
-      )
+#
+# ZMQ
+#
+SET(ZMQ_DEPENDS)
+ctkMacroShouldAddExternalProject(ZMQ_LIBRARIES add_project)
+IF(${add_project})
+  SET(proj ZMQ)
+#   MESSAGE(STATUS "Adding project:${proj}")
+  SET(ZMQ_DEPENDS ${proj})
+  ExternalProject_Add(${proj}
+      GIT_REPOSITORY git://github.com/PatrickCheng/zeromq2.git
+      INSTALL_COMMAND ""
+      CMAKE_GENERATOR ${gen}
+      CMAKE_ARGS
+        ${ep_common_args}
+		-DBUILD_SHARED_LIBS:BOOL=ON 
+		-DZMQ_BUILD_DEVICES:BOOL=ON
+		-DZMQ_BUILD_PERFORMANCE_TESTS:BOOL=ON
+      )
+	  SET(ZMQ_DIR ${ep_build_dir}/${proj})
 ENDIF()

+ 487 - 486
CMakeLists.txt

@@ -1,486 +1,487 @@
-###########################################################################
-#
-#  Library:   CTK
-# 
-#  Copyright (c) 2010  Kitware Inc.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.commontk.org/LICENSE
-#
-#  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.
-# 
-###########################################################################
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-
-#-----------------------------------------------------------------------------
-# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
-#
-
-SET(project_policies
-  CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
-  CMP0002 # NEW: Logical target names must be globally unique.
-  CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
-  CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
-  CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
-  CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
-  CMP0007 # NEW: List command no longer ignores empty elements.
-  CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
-  CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
-  CMP0010 # NEW: Bad variable reference syntax is an error.
-  CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
-  CMP0012 # NEW: if() recognizes numbers and boolean constants.
-  CMP0013 # NEW: Duplicate binary directories are not allowed.
-  CMP0014 # NEW: Input directories must have CMakeLists.txt
-  )
-FOREACH(policy ${project_policies})
-  IF(POLICY ${policy})
-    CMAKE_POLICY(SET ${policy} NEW)
-  ENDIF()
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-PROJECT(CTK)
-#-----------------------------------------------------------------------------
-
-# Default to shared library
-SET(CTK_LIBRARY_MODE "SHARED")
-SET(CTK_BUILD_SHARED_LIBS TRUE)
-
-#-----------------------------------------------------------------------------
-# Output directories.
-#
-IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
-  SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
-ENDIF()
-IF(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
-  SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
-ENDIF()
-IF(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
-  SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Install directories, used for install rules.
-#
-SET(CTK_INSTALL_BIN_DIR "bin")
-SET(CTK_INSTALL_LIB_DIR "lib")
-SET(CTK_INSTALL_INCLUDE_DIR "include")
-SET(CTK_INSTALL_DOC_DIR "doc")
-
-#-----------------------------------------------------------------------------
-# CTK version number.  An even minor number corresponds to releases.
-#
-SET(CTK_MAJOR_VERSION 0)
-SET(CTK_MINOR_VERSION 1)
-SET(CTK_BUILD_VERSION 0)
-SET(CTK_VERSION
-    "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_BUILD_VERSION}")
-
-# Append the library version information to the library target
-# properties.  A parent project may set its own properties and/or may
-# block this.
-IF(NOT CTK_NO_LIBRARY_VERSION)
-  SET(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
-    VERSION "${CTK_VERSION}"
-    SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
-    )
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Update CMake module path
-# Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
-#
-SET(CMAKE_MODULE_PATH
-  "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
-  "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
-  ${CMAKE_MODULE_PATH})
-
-#-----------------------------------------------------------------------------
-# Clear CTK_BASE_INCLUDE_DIRS and CTK_BASE_LIBRARIES
-#
-SET(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
-SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
-
-# Variable use in CTKConfig.cmake.in
-SET(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
-
-#-----------------------------------------------------------------------------
-# CMake Function(s) and Macro(s)
-#
-INCLUDE(CMake/ctkMacroParseArguments.cmake)
-INCLUDE(CMake/ctkMacroListFilter.cmake)
-INCLUDE(CMake/ctkMacroBuildLib.cmake)
-INCLUDE(CMake/ctkMacroBuildPlugin.cmake)
-INCLUDE(CMake/ctkMacroBuildApp.cmake)
-INCLUDE(CMake/ctkMacroBuildQtDesignerPlugin.cmake)
-INCLUDE(CMake/ctkMacroSetupQt.cmake)
-INCLUDE(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macros
-INCLUDE(CMake/ctkFunctionExtractOptionNameAndValue.cmake)
-INCLUDE(CMake/ctkFunctionExecuteProcess.cmake)
-INCLUDE(CMake/ctkMacroValidateBuildOptions.cmake)
-INCLUDE(CMake/ctkMacroAddCtkLibraryOptions.cmake)
-INCLUDE(CMake/ctkFunctionGenerateDGraphInput.cmake)
-INCLUDE(CMake/ctkFunctionGenerateProjectXml.cmake)
-
-# Used by CTKGenerateCTKConfig.cmake
-SET(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
-SET(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
-
-#-----------------------------------------------------------------------------
-# Testing
-#
-OPTION(BUILD_TESTING "Test the project" ON)
-IF(BUILD_TESTING)
-  ENABLE_TESTING()
-  INCLUDE(CTest)
-  SET(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-  MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
-    
-  # Setup file for setting custom ctest vars
-  CONFIGURE_FILE(
-    CMake/CTestCustom.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
-    @ONLY
-    )
-
-  # Configuration for the CMake-generated test driver
-  SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
-  SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
-    try
-      {")
-  SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN "    }
-      catch( std::exception & excp )
-        {
-        fprintf(stderr,\"%s\\n\",excp.what());
-        return EXIT_FAILURE;
-        }
-      catch( ... )
-        {
-        printf(\"Exception caught in the test driver\\n\");
-        return EXIT_FAILURE;
-        }
-      ")
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Coverage
-#
-OPTION(WITH_COVERAGE "Enable/Disable coverage" OFF)
-
-#-----------------------------------------------------------------------------
-# Documentation
-#
-OPTION(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
-MARK_AS_ADVANCED(DOCUMENTATION_TARGET_IN_ALL)
-
-#-----------------------------------------------------------------------------
-# Additional CXX/C Flags
-#
-SET(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
-MARK_AS_ADVANCED(ADDITIONAL_C_FLAGS)
-SET(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
-MARK_AS_ADVANCED(ADDITIONAL_CXX_FLAGS)
-
-#-----------------------------------------------------------------------------
-# Set symbol visibility Flags
-#
-IF(CMAKE_CXX_COMPILER_ID)
-  # Set the default symbol visibility to hidden for gcc
-  IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
-    SET(VISIBILITY_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
-  ENDIF()
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Set coverage Flags
-#
-IF(WITH_COVERAGE)
-  IF(CMAKE_CXX_COMPILER_ID AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
-    SET(coverage_flags "-g -fdiagnostics-show-option -fprofile-arcs -ftest-coverage -O3 -DNDEBUG")
-    SET(COVERAGE_CXX_FLAGS ${coverage_flags})
-    SET(COVERAGE_C_FLAGS ${coverage_flags})
-  ENDIF()
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# CTK C/CXX Flags
-#
-SET(CTK_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
-SET(CTK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
-
-#-----------------------------------------------------------------------------
-# QT
-#
-ctkMacroSetupQt()
-
-# Update CTK_BASE_LIBRARIES with QT libraries
-IF(QT4_FOUND)
-  SET(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# CTK Libraries - Use ON or OFF to indicate if the library should be built by default
-#
-SET(CTK_LIBS
-  Core:ON
-  Widgets:OFF
-  DICOM/Core:OFF
-  DICOM/Widgets:OFF
-  Scripting/Python/Core:OFF
-  Scripting/Python/Widgets:OFF
-  Visualization/VTK/Core:OFF
-  Visualization/VTK/Widgets:OFF
-  Visualization/XIP:OFF
-  )
-
-#-----------------------------------------------------------------------------
-# CTK Plugins - Use ON or OFF to indicate if the plugin should be built by default
-#
-SET(CTK_PLUGINS
-  #org.commontk.cli:OFF
-  )
-
-#-----------------------------------------------------------------------------
-# CTK Applications - Use ON or OFF to indicate if the application should be built by default
-#
-SET(CTK_APPLICATIONS
-  ctkDICOM:OFF
-  ctkDICOMIndexer:OFF
-  )
-  
-#-----------------------------------------------------------------------------
-# To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
-# before the SuperBuild script is included
-#
-
-# Let's mark as advanced some default properties
-MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
-MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
-
-# KWStyle
-OPTION(CTK_USE_KWSTYLE     "Enable sourcecode-based style tests." OFF)
-#MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
-
-#---------------------------------------------------------------------------
-# Documentation
-ADD_SUBDIRECTORY( Documentation )
-
-#---------------------------------------------------------------------------
-# Will contain a list of sub-directory without option ON or OFF
-#
-SET(CTK_LIBS_SUBDIRS )
-SET(CTK_PLUGINS_SUBDIRS )
-SET(CTK_APPLICATIONS_SUBDIRS )
-
-#-----------------------------------------------------------------------------
-# Build options associated with CTK libraries
-# Note also that if
-# the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists and look like:
-#
-#     SET(ctk_library_options
-#       OPT1:OFF
-#       OPT2:ON
-#       )
-#
-# In addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
-# will also be available in CMake configure menu:
-#  CTK_LIB_<DIR>/<LIBNAME>_OPT1  (set to OFF)
-#  CTK_LIB_<DIR>/<LIBNAME>_OPT2  (set to ON)
-#
-FOREACH(lib ${CTK_LIBS})
-  ctkFunctionExtractOptionNameAndValue(${lib} lib_name lib_value)
-  OPTION(CTK_LIB_${lib_name} "Enable ${lib_name} Library." ${lib_value})
-  ctkMacroAddCtkLibraryOptions(${lib_name})
-  LIST(APPEND CTK_LIBS_SUBDIRS "${lib_name}")
-ENDFOREACH()
-
-# Build options associated with CTK plugins
-FOREACH(plugin ${CTK_PLUGINS})
-  ctkFunctionExtractOptionNameAndValue(${plugin} plugin_name plugin_value)
-  OPTION(CTK_PLUGIN_${plugin_name} "Build ${plugin_name} Plugin." ${plugin_value})
-  LIST(APPEND CTK_PLUGINS_SUBDIRS "${plugin_name}")
-ENDFOREACH()
-
-# Build options associated with CTK applications
-FOREACH(app ${CTK_APPLICATIONS})
-  ctkFunctionExtractOptionNameAndValue(${app} app_name app_value)
-  OPTION(CTK_APP_${app_name} "Build ${app_name} Application." ${app_value})
-  LIST(APPEND CTK_APPLICATIONS_SUBDIRS "${app_name}")
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# Superbuild Option - Enabled by default
-#
-OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
-MARK_AS_ADVANCED(CTK_SUPERBUILD)
-
-#-----------------------------------------------------------------------------
-# Generate target_directories list - List of directory corresponding to the different
-# libraries, plugins and applications associated with the corresponding option name.
-#
-
-# Create list of directories corresponding to the enabled targets
-SET(target_directories)
-
-FOREACH(lib ${CTK_LIBS_SUBDIRS})
-  SET(option_name CTK_LIB_${lib})
-  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^${option_name}")
-ENDFOREACH()
-
-FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
-  SET(option_name CTK_PLUGIN_${plugin})
-  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^${option_name}")
-ENDFOREACH()
-
-FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
-  SET(option_name CTK_APP_${app})
-  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^${option_name}")
-ENDFOREACH()
-
-#MESSAGE(STATUS target_directories:${target_directories})
-
-#-----------------------------------------------------------------------------
-# Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
-# topological order.
-TRY_COMPILE(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
-              DGraph
-              CMAKE_FLAGS
-                -DQT_QMAKE_EXECUTABLE:BOOL=${QT_QMAKE_EXECUTABLE}
-                -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
-              OUTPUT_VARIABLE output)
-IF(NOT RESULT_VAR)
-  MESSAGE(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
-ENDIF()
-FIND_PROGRAM(DGraph_EXECUTABLE DGraph
-  "${CTK_BINARY_DIR}/Utilities/DGraph/"
-  "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
-  "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
-  "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
-MARK_AS_ADVANCED(DGraph_EXECUTABLE)
-
-#-----------------------------------------------------------------------------
-# Let's make sure the enabled/disabled libraries, plugins or applications are coherent
-#
-ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" FALSE)
-ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
-
-#-----------------------------------------------------------------------------
-# DGraph
-#
-
-# Generate DGraph input file expected by DGraph
-ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" TRUE)
-
-# Obtain list of target ordered topologically
-ctkFunctionExecuteProcess(
-  COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
-  PATH_LIST \"${QT_INSTALLED_LIBRARY_DIR}\"
-  WORKING_DIRECTORY ${CTK_BINARY_DIR}
-  RESULT_VARIABLE RESULT_VAR
-  OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS
-  ERROR_VARIABLE error
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-  )
-IF(RESULT_VAR)
-  MESSAGE(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
-ENDIF()
-
-# If the list of subproject is empty, let's at least build CTKCore
-LIST(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
-IF (subproject_count EQUAL 0)
-  SET(CTEST_PROJECT_SUBPROJECTS CTKCore)
-ENDIF()
-
-# Configure CTestConfigSubProject.cmake used that could be used by CTest scripts
-CONFIGURE_FILE(${CTK_SOURCE_DIR}/CTestConfigSubProject.cmake.in
-               ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
-
-#-----------------------------------------------------------------------------
-# Project.xml
-#
-
-# Generate Project.xml file expected by the CTest driver script
-ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
-
-#-----------------------------------------------------------------------------
-# Superbuild script
-#
-
-IF(CTK_SUPERBUILD)
-  INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
-  RETURN()
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# CTK_SUPERBUILD_BINARY_DIR
-
-# If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
-# In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
-IF(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
-  SET(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Configure files with settings
-#
-
-CONFIGURE_FILE(${CTK_SOURCE_DIR}/UseCTK.cmake.in
-               ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
-               
-#-----------------------------------------------------------------------------
-# Set C/CXX Flags
-#
-SET(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS})
-SET(CMAKE_C_FLAGS ${CTK_C_FLAGS})
-
-#-----------------------------------------------------------------------------
-# Add CTK library subdirectories
-#
-FOREACH(lib ${CTK_LIBS_SUBDIRS})
-  IF (CTK_LIB_${lib})
-    ADD_SUBDIRECTORY(Libs/${lib})
-  ENDIF()
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# Add CTK plugin subdirectories
-#
-FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
-  IF (CTK_PLUGIN_${plugin})
-    ADD_SUBDIRECTORY(Plugins/${plugin})
-  ENDIF()
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# Add CTK application subdirectories
-#
-FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
-  IF (CTK_APP_${app})
-    ADD_SUBDIRECTORY(Applications/${app})
-  ENDIF()
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# Add general purpose subdirectories
-#
-#ADD_SUBDIRECTORY(Testing)
-#ADD_SUBDIRECTORY(Examples)
-
-#-----------------------------------------------------------------------------
-# Style Checking configuration
-#
-INCLUDE(Utilities/KWStyle/KWStyle.cmake)
-
-#-----------------------------------------------------------------------------
-# The commands in this directory are intended to be executed as
-# the end of the whole configuration process, as a "last step".
-# This directory is typically the last SUBDIRS in the main CMakeLists.txt.
-ADD_SUBDIRECTORY(Utilities/LastConfigureStep)
+###########################################################################
+#
+#  Library:   CTK
+# 
+#  Copyright (c) 2010  Kitware Inc.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.commontk.org/LICENSE
+#
+#  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.
+# 
+###########################################################################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+#-----------------------------------------------------------------------------
+# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
+#
+
+SET(project_policies
+  CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
+  CMP0002 # NEW: Logical target names must be globally unique.
+  CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
+  CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
+  CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
+  CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
+  CMP0007 # NEW: List command no longer ignores empty elements.
+  CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
+  CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
+  CMP0010 # NEW: Bad variable reference syntax is an error.
+  CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
+  CMP0012 # NEW: if() recognizes numbers and boolean constants.
+  CMP0013 # NEW: Duplicate binary directories are not allowed.
+  CMP0014 # NEW: Input directories must have CMakeLists.txt
+  )
+FOREACH(policy ${project_policies})
+  IF(POLICY ${policy})
+    CMAKE_POLICY(SET ${policy} NEW)
+  ENDIF()
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+PROJECT(CTK)
+#-----------------------------------------------------------------------------
+
+# Default to shared library
+SET(CTK_LIBRARY_MODE "SHARED")
+SET(CTK_BUILD_SHARED_LIBS TRUE)
+
+#-----------------------------------------------------------------------------
+# Output directories.
+#
+IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
+  SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
+ENDIF()
+IF(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+  SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
+ENDIF()
+IF(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
+  SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Install directories, used for install rules.
+#
+SET(CTK_INSTALL_BIN_DIR "bin")
+SET(CTK_INSTALL_LIB_DIR "lib")
+SET(CTK_INSTALL_INCLUDE_DIR "include")
+SET(CTK_INSTALL_DOC_DIR "doc")
+
+#-----------------------------------------------------------------------------
+# CTK version number.  An even minor number corresponds to releases.
+#
+SET(CTK_MAJOR_VERSION 0)
+SET(CTK_MINOR_VERSION 1)
+SET(CTK_BUILD_VERSION 0)
+SET(CTK_VERSION
+    "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_BUILD_VERSION}")
+
+# Append the library version information to the library target
+# properties.  A parent project may set its own properties and/or may
+# block this.
+IF(NOT CTK_NO_LIBRARY_VERSION)
+  SET(CTK_LIBRARY_PROPERTIES ${CTK_LIBRARY_PROPERTIES}
+    VERSION "${CTK_VERSION}"
+    SOVERSION "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}"
+    )
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Update CMake module path
+# Note: FindXXX.cmake script specific to utility should be copied into Utilities/CMake
+#
+SET(CMAKE_MODULE_PATH
+  "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/CMake"
+  "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
+  ${CMAKE_MODULE_PATH})
+
+#-----------------------------------------------------------------------------
+# Clear CTK_BASE_INCLUDE_DIRS and CTK_BASE_LIBRARIES
+#
+SET(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)
+SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
+
+# Variable use in CTKConfig.cmake.in
+SET(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)
+
+#-----------------------------------------------------------------------------
+# CMake Function(s) and Macro(s)
+#
+INCLUDE(CMake/ctkMacroParseArguments.cmake)
+INCLUDE(CMake/ctkMacroListFilter.cmake)
+INCLUDE(CMake/ctkMacroBuildLib.cmake)
+INCLUDE(CMake/ctkMacroBuildPlugin.cmake)
+INCLUDE(CMake/ctkMacroBuildApp.cmake)
+INCLUDE(CMake/ctkMacroBuildQtDesignerPlugin.cmake)
+INCLUDE(CMake/ctkMacroSetupQt.cmake)
+INCLUDE(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macros
+INCLUDE(CMake/ctkFunctionExtractOptionNameAndValue.cmake)
+INCLUDE(CMake/ctkFunctionExecuteProcess.cmake)
+INCLUDE(CMake/ctkMacroValidateBuildOptions.cmake)
+INCLUDE(CMake/ctkMacroAddCtkLibraryOptions.cmake)
+INCLUDE(CMake/ctkFunctionGenerateDGraphInput.cmake)
+INCLUDE(CMake/ctkFunctionGenerateProjectXml.cmake)
+
+# Used by CTKGenerateCTKConfig.cmake
+SET(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
+SET(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
+
+#-----------------------------------------------------------------------------
+# Testing
+#
+OPTION(BUILD_TESTING "Test the project" ON)
+IF(BUILD_TESTING)
+  ENABLE_TESTING()
+  INCLUDE(CTest)
+  SET(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+  MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
+    
+  # Setup file for setting custom ctest vars
+  CONFIGURE_FILE(
+    CMake/CTestCustom.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
+    @ONLY
+    )
+
+  # Configuration for the CMake-generated test driver
+  SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
+  SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
+    try
+      {")
+  SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN "    }
+      catch( std::exception & excp )
+        {
+        fprintf(stderr,\"%s\\n\",excp.what());
+        return EXIT_FAILURE;
+        }
+      catch( ... )
+        {
+        printf(\"Exception caught in the test driver\\n\");
+        return EXIT_FAILURE;
+        }
+      ")
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Coverage
+#
+OPTION(WITH_COVERAGE "Enable/Disable coverage" OFF)
+
+#-----------------------------------------------------------------------------
+# Documentation
+#
+OPTION(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
+MARK_AS_ADVANCED(DOCUMENTATION_TARGET_IN_ALL)
+
+#-----------------------------------------------------------------------------
+# Additional CXX/C Flags
+#
+SET(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
+MARK_AS_ADVANCED(ADDITIONAL_C_FLAGS)
+SET(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
+MARK_AS_ADVANCED(ADDITIONAL_CXX_FLAGS)
+
+#-----------------------------------------------------------------------------
+# Set symbol visibility Flags
+#
+IF(CMAKE_CXX_COMPILER_ID)
+  # Set the default symbol visibility to hidden for gcc
+  IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+    SET(VISIBILITY_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
+  ENDIF()
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Set coverage Flags
+#
+IF(WITH_COVERAGE)
+  IF(CMAKE_CXX_COMPILER_ID AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+    SET(coverage_flags "-g -fdiagnostics-show-option -fprofile-arcs -ftest-coverage -O3 -DNDEBUG")
+    SET(COVERAGE_CXX_FLAGS ${coverage_flags})
+    SET(COVERAGE_C_FLAGS ${coverage_flags})
+  ENDIF()
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# CTK C/CXX Flags
+#
+SET(CTK_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")
+SET(CTK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")
+
+#-----------------------------------------------------------------------------
+# QT
+#
+ctkMacroSetupQt()
+
+# Update CTK_BASE_LIBRARIES with QT libraries
+IF(QT4_FOUND)
+  SET(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# CTK Libraries - Use ON or OFF to indicate if the library should be built by default
+#
+SET(CTK_LIBS
+  Core:ON
+  Widgets:OFF
+  DICOM/Core:OFF
+  DICOM/Widgets:OFF
+  Messaging/Core:OFF
+  Scripting/Python/Core:OFF
+  Scripting/Python/Widgets:OFF
+  Visualization/VTK/Core:OFF
+  Visualization/VTK/Widgets:OFF
+  Visualization/XIP:OFF
+  )
+
+#-----------------------------------------------------------------------------
+# CTK Plugins - Use ON or OFF to indicate if the plugin should be built by default
+#
+SET(CTK_PLUGINS
+  #org.commontk.cli:OFF
+  )
+
+#-----------------------------------------------------------------------------
+# CTK Applications - Use ON or OFF to indicate if the application should be built by default
+#
+SET(CTK_APPLICATIONS
+  ctkDICOM:OFF
+  ctkDICOMIndexer:OFF
+  )
+  
+#-----------------------------------------------------------------------------
+# To make options show up in both CTK-SuperBuild and CTK regular build, let's add them
+# before the SuperBuild script is included
+#
+
+# Let's mark as advanced some default properties
+MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
+MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
+
+# KWStyle
+OPTION(CTK_USE_KWSTYLE     "Enable sourcecode-based style tests." OFF)
+#MARK_AS_ADVANCED(CTK_USE_KWSTYLE)
+
+#---------------------------------------------------------------------------
+# Documentation
+ADD_SUBDIRECTORY( Documentation )
+
+#---------------------------------------------------------------------------
+# Will contain a list of sub-directory without option ON or OFF
+#
+SET(CTK_LIBS_SUBDIRS )
+SET(CTK_PLUGINS_SUBDIRS )
+SET(CTK_APPLICATIONS_SUBDIRS )
+
+#-----------------------------------------------------------------------------
+# Build options associated with CTK libraries
+# Note also that if
+# the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists and look like:
+#
+#     SET(ctk_library_options
+#       OPT1:OFF
+#       OPT2:ON
+#       )
+#
+# In addition to 'CTK_LIB_<DIR>/<LIBNAME>' option, the following ones
+# will also be available in CMake configure menu:
+#  CTK_LIB_<DIR>/<LIBNAME>_OPT1  (set to OFF)
+#  CTK_LIB_<DIR>/<LIBNAME>_OPT2  (set to ON)
+#
+FOREACH(lib ${CTK_LIBS})
+  ctkFunctionExtractOptionNameAndValue(${lib} lib_name lib_value)
+  OPTION(CTK_LIB_${lib_name} "Enable ${lib_name} Library." ${lib_value})
+  ctkMacroAddCtkLibraryOptions(${lib_name})
+  LIST(APPEND CTK_LIBS_SUBDIRS "${lib_name}")
+ENDFOREACH()
+
+# Build options associated with CTK plugins
+FOREACH(plugin ${CTK_PLUGINS})
+  ctkFunctionExtractOptionNameAndValue(${plugin} plugin_name plugin_value)
+  OPTION(CTK_PLUGIN_${plugin_name} "Build ${plugin_name} Plugin." ${plugin_value})
+  LIST(APPEND CTK_PLUGINS_SUBDIRS "${plugin_name}")
+ENDFOREACH()
+
+# Build options associated with CTK applications
+FOREACH(app ${CTK_APPLICATIONS})
+  ctkFunctionExtractOptionNameAndValue(${app} app_name app_value)
+  OPTION(CTK_APP_${app_name} "Build ${app_name} Application." ${app_value})
+  LIST(APPEND CTK_APPLICATIONS_SUBDIRS "${app_name}")
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# Superbuild Option - Enabled by default
+#
+OPTION(CTK_SUPERBUILD "Build CTK and the projects it depends on via SuperBuild.cmake." ON)
+MARK_AS_ADVANCED(CTK_SUPERBUILD)
+
+#-----------------------------------------------------------------------------
+# Generate target_directories list - List of directory corresponding to the different
+# libraries, plugins and applications associated with the corresponding option name.
+#
+
+# Create list of directories corresponding to the enabled targets
+SET(target_directories)
+
+FOREACH(lib ${CTK_LIBS_SUBDIRS})
+  SET(option_name CTK_LIB_${lib})
+  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^${option_name}")
+ENDFOREACH()
+
+FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
+  SET(option_name CTK_PLUGIN_${plugin})
+  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^${option_name}")
+ENDFOREACH()
+
+FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
+  SET(option_name CTK_APP_${app})
+  LIST(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^${option_name}")
+ENDFOREACH()
+
+#MESSAGE(STATUS target_directories:${target_directories})
+
+#-----------------------------------------------------------------------------
+# Compile DGraph - An application allowing to check for cycle in DAG and also obtain the
+# topological order.
+TRY_COMPILE(RESULT_VAR ${CTK_BINARY_DIR}/Utilities/DGraph ${CTK_SOURCE_DIR}/Utilities/DGraph
+              DGraph
+              CMAKE_FLAGS
+                -DQT_QMAKE_EXECUTABLE:BOOL=${QT_QMAKE_EXECUTABLE}
+                -DCMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
+              OUTPUT_VARIABLE output)
+IF(NOT RESULT_VAR)
+  MESSAGE(FATAL_ERROR "Failed to compile DGraph application.\n${output}")
+ENDIF()
+FIND_PROGRAM(DGraph_EXECUTABLE DGraph
+  "${CTK_BINARY_DIR}/Utilities/DGraph/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/bin/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/Debug/"
+  "${CTK_BINARY_DIR}/Utilities/DGraph/Release/")
+MARK_AS_ADVANCED(DGraph_EXECUTABLE)
+
+#-----------------------------------------------------------------------------
+# Let's make sure the enabled/disabled libraries, plugins or applications are coherent
+#
+ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" FALSE)
+ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")
+
+#-----------------------------------------------------------------------------
+# DGraph
+#
+
+# Generate DGraph input file expected by DGraph
+ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" TRUE)
+
+# Obtain list of target ordered topologically
+ctkFunctionExecuteProcess(
+  COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"
+  PATH_LIST \"${QT_INSTALLED_LIBRARY_DIR}\"
+  WORKING_DIRECTORY ${CTK_BINARY_DIR}
+  RESULT_VARIABLE RESULT_VAR
+  OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS
+  ERROR_VARIABLE error
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+IF(RESULT_VAR)
+  MESSAGE(FATAL_ERROR "Failed to obtain list of target ordered topologically.\n${RESULT_VAR}\n${CTK_BINARY_DIR}\n${error}")
+ENDIF()
+
+# If the list of subproject is empty, let's at least build CTKCore
+LIST(LENGTH CTEST_PROJECT_SUBPROJECTS subproject_count)
+IF (subproject_count EQUAL 0)
+  SET(CTEST_PROJECT_SUBPROJECTS CTKCore)
+ENDIF()
+
+# Configure CTestConfigSubProject.cmake used that could be used by CTest scripts
+CONFIGURE_FILE(${CTK_SOURCE_DIR}/CTestConfigSubProject.cmake.in
+               ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)
+
+#-----------------------------------------------------------------------------
+# Project.xml
+#
+
+# Generate Project.xml file expected by the CTest driver script
+ctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})
+
+#-----------------------------------------------------------------------------
+# Superbuild script
+#
+
+IF(CTK_SUPERBUILD)
+  INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
+  RETURN()
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# CTK_SUPERBUILD_BINARY_DIR
+
+# If CTK_SUPERBUILD_BINARY_DIR isn't defined, it means CTK is *NOT* build using Superbuild.
+# In that specific case, CTK_SUPERBUILD_BINARY_DIR should default to CTK_BINARY_DIR
+IF(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
+  SET(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR})
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Configure files with settings
+#
+
+CONFIGURE_FILE(${CTK_SOURCE_DIR}/UseCTK.cmake.in
+               ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
+               
+#-----------------------------------------------------------------------------
+# Set C/CXX Flags
+#
+SET(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS})
+SET(CMAKE_C_FLAGS ${CTK_C_FLAGS})
+
+#-----------------------------------------------------------------------------
+# Add CTK library subdirectories
+#
+FOREACH(lib ${CTK_LIBS_SUBDIRS})
+  IF (CTK_LIB_${lib})
+    ADD_SUBDIRECTORY(Libs/${lib})
+  ENDIF()
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# Add CTK plugin subdirectories
+#
+FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
+  IF (CTK_PLUGIN_${plugin})
+    ADD_SUBDIRECTORY(Plugins/${plugin})
+  ENDIF()
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# Add CTK application subdirectories
+#
+FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
+  IF (CTK_APP_${app})
+    ADD_SUBDIRECTORY(Applications/${app})
+  ENDIF()
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# Add general purpose subdirectories
+#
+#ADD_SUBDIRECTORY(Testing)
+#ADD_SUBDIRECTORY(Examples)
+
+#-----------------------------------------------------------------------------
+# Style Checking configuration
+#
+INCLUDE(Utilities/KWStyle/KWStyle.cmake)
+
+#-----------------------------------------------------------------------------
+# The commands in this directory are intended to be executed as
+# the end of the whole configuration process, as a "last step".
+# This directory is typically the last SUBDIRS in the main CMakeLists.txt.
+ADD_SUBDIRECTORY(Utilities/LastConfigureStep)

+ 81 - 0
Libs/Messaging/Core/CMakeLists.txt

@@ -0,0 +1,81 @@
+PROJECT(CTKMessagingCore)
+
+#
+# 3rd party dependencies
+#
+
+FIND_PACKAGE(ZMQ)
+# TODO In case ZMQ is passed directly using ZMQ_DIR, check expected options
+IF(NOT ZMQ_FOUND)
+  MESSAGE(FATAL_ERROR "error: ZMQ package is required to build ${PROJECT_NAME}")
+ENDIF()
+INCLUDE(${ZMQ_USE_FILE})
+
+
+#FIND_PACKAGE(OpenIGTLink)
+# TODO In case OpenIGTLink is passed directly using OpenIGTLink_DIR, check expected options
+#IF(NOT OpenIGTLink_FOUND)
+#  MESSAGE(FATAL_ERROR "error: OpenIGTLink package is required to build ${PROJECT_NAME}")
+#ENDIF()
+#INCLUDE(${OpenIGTLink_USE_FILE})
+
+
+#
+# See CTK/CMake/ctkMacroBuildLib.cmake for details
+#
+
+SET(KIT_export_directive "CTK_MESSAGING_CORE_EXPORT")
+
+# Additional directories to include
+SET(KIT_include_directories
+  )
+  
+# Source files
+SET(KIT_SRCS
+  ctkMessagingServer.h
+  ctkMessagingServer.cpp
+  ctkMessagingClient.h
+  ctkMessagingClient.cpp
+  )
+
+# Headers that should run through moc
+SET(KIT_MOC_SRCS
+  )
+
+# UI files
+SET(KIT_UI_FORMS
+  )
+
+# Resources
+SET(KIT_resources
+  )
+
+# Set VTK_LIBRARIES variable
+#SET(ZMQ_LIBRARIES
+#  vtkCommon
+#  vtkFiltering
+#  )
+
+# Target libraries - See CMake/ctkMacroGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkMacroGetTargetLibraries(KIT_target_libraries)
+
+ctkMacroBuildLib(
+  NAME ${PROJECT_NAME}
+  EXPORT_DIRECTIVE ${KIT_export_directive}
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+  )
+
+# Plugins
+#ADD_SUBDIRECTORY(Plugins)
+
+# Testing
+IF(BUILD_TESTING)
+  ADD_SUBDIRECTORY(Testing)
+ENDIF(BUILD_TESTING)

+ 30 - 0
Libs/Messaging/Core/Testing/CMakeLists.txt

@@ -0,0 +1,30 @@
+SET(KIT ${PROJECT_NAME})
+
+CREATE_TEST_SOURCELIST(Tests ${KIT}CppTests.cpp
+  ctkMessagingServerTest1.cpp
+  #EXTRA_INCLUDE TestingMacros.h
+  )
+
+SET (TestsToRun ${Tests})
+REMOVE (TestsToRun ${KIT}CppTests.cpp)
+
+SET(LIBRARY_NAME ${PROJECT_NAME})
+
+ADD_EXECUTABLE(${KIT}CppTests ${Tests})
+TARGET_LINK_LIBRARIES(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})
+
+SET( KIT_TESTS ${CPP_TEST_PATH}/${KIT}CppTests)
+IF(WIN32)
+  SET(KIT_TESTS ${CPP_TEST_PATH}/${CMAKE_BUILD_TYPE}/${KIT}CppTests)
+ENDIF(WIN32)
+
+MACRO( SIMPLE_TEST  TESTNAME )
+  ADD_TEST( ${TESTNAME} ${KIT_TESTS} ${TESTNAME} )
+  SET_PROPERTY(TEST ${TESTNAME} PROPERTY LABELS ${PROJECT_NAME})
+ENDMACRO( SIMPLE_TEST  )
+
+#
+# Add Tests
+#
+
+SIMPLE_TEST( ctkMessagingServerTest1 )

+ 36 - 0
Libs/Messaging/Core/Testing/ctkMessagingServerTest1.cpp

@@ -0,0 +1,36 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  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.
+ 
+=========================================================================*/
+
+// CTK includes
+#include "ctkMessagingServer.h"
+#include "ctkModelTester.h"
+
+// STD includes
+#include <iostream>
+
+//-----------------------------------------------------------------------------
+int ctkMessagingServerTest1(int argc, char * argv [] )
+{
+  
+  ctkMessagingServer * server = new ctkMessagingServer;
+
+  return EXIT_SUCCESS;
+}
+

+ 39 - 0
Libs/Messaging/Core/ctkMessagingClient.cpp

@@ -0,0 +1,39 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  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.
+ 
+=========================================================================*/
+
+// ZMQ includes
+
+// ctkDICOM includes
+#include "ctkMessagingClient.h"
+
+// STD includes
+#include <iostream>
+
+
+//------------------------------------------------------------------------------
+ctkMessagingClient::ctkMessagingClient()
+{
+}
+
+//----------------------------------------------------------------------------
+ctkMessagingClient::~ctkMessagingClient()
+{
+}
+

+ 43 - 0
Libs/Messaging/Core/ctkMessagingClient.h

@@ -0,0 +1,43 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  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.
+ 
+=========================================================================*/
+
+#ifndef __ctkMessagingClient_h
+#define __ctkMessagingClient_h
+
+// ZMQ includes 
+#include <zmq.hpp>
+#include "ctkMessagingCoreExport.h"
+
+//class ctkMessagingClientPrivate;
+
+class CTK_MESSAGING_CORE_EXPORT ctkMessagingClient
+{
+public:
+  //typedef QObject Superclass;
+  explicit ctkMessagingClient();
+  virtual ~ctkMessagingClient();
+  
+
+private:
+//  CTK_DECLARE_PRIVATE(ctkMessagingClient);
+
+};
+
+#endif

+ 44 - 0
Libs/Messaging/Core/ctkMessagingServer.cpp

@@ -0,0 +1,44 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  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.
+ 
+=========================================================================*/
+
+// ZMQ includes
+
+// ctkDICOM includes
+#include "ctkMessagingServer.h"
+
+// STD includes
+#include <iostream>
+
+
+//------------------------------------------------------------------------------
+ctkMessagingServer::ctkMessagingServer()
+{
+  zmq::context_t ctx (1, 1);
+
+  // Create a PUB socket for port 5555 on the lo interface
+  zmq::socket_t s(ctx, ZMQ_PUB);
+  //s.bind ("tcp://lo0:5555");
+}
+
+//----------------------------------------------------------------------------
+ctkMessagingServer::~ctkMessagingServer()
+{
+}
+

+ 43 - 0
Libs/Messaging/Core/ctkMessagingServer.h

@@ -0,0 +1,43 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  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.
+ 
+=========================================================================*/
+
+#ifndef __ctkMessagingServer_h
+#define __ctkMessagingServer_h
+
+// ZMQ includes 
+#include <zmq.hpp>
+#include "ctkMessagingCoreExport.h"
+
+//class ctkMessagingServerPrivate;
+
+class CTK_MESSAGING_CORE_EXPORT ctkMessagingServer
+{
+public:
+  //typedef QObject Superclass;
+  explicit ctkMessagingServer();
+  virtual ~ctkMessagingServer();
+  
+
+private:
+//  CTK_DECLARE_PRIVATE(ctkMessagingServer);
+
+};
+
+#endif

+ 11 - 0
Libs/Messaging/Core/target_libraries.cmake

@@ -0,0 +1,11 @@
+#
+# See CMake/ctkMacroGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK libraries
+#
+
+SET(target_libraries
+  #OpenIGTLink_LIBRARIES
+  ZMQ_LIBRARIES
+  CTKCore
+  )

+ 246 - 244
SuperBuild.cmake

@@ -1,244 +1,246 @@
-###########################################################################
-#
-#  Library:   CTK
-# 
-#  Copyright (c) 2010  Kitware Inc.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.commontk.org/LICENSE
-#
-#  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.
-# 
-###########################################################################
-
-SET(cmake_version_required "2.8")
-SET(cmake_version_required_dash "2-8")
-
-CMAKE_MINIMUM_REQUIRED(VERSION ${cmake_version_required})
-
-# 
-# CTK_KWSTYLE_EXECUTABLE
-# DCMTK_DIR
-# QT_QMAKE_EXECUTABLE
-# VTK_DIR
-# PYTHONQT_INSTALL_DIR
-# PYTHON_LIBRARY
-# PYTHON_INCLUDE_DIR
-#
-
-#-----------------------------------------------------------------------------
-# Enable and setup External project global properties
-#
-INCLUDE(ExternalProject)
-
-SET(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals")
-SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base})
-
-SET(ep_install_dir ${ep_base}/Install)
-SET(ep_build_dir ${ep_base}/Build)
-SET(ep_source_dir ${ep_base}/Source)
-#SET(ep_parallelism_level)
-SET(ep_build_shared_libs ON)
-SET(ep_build_testing OFF)
-
-SET(ep_common_args
-  -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
-  -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-  -DBUILD_TESTING:BOOL=${ep_build_testing}
-  )
-
-# Compute -G arg for configuring external projects with the same CMake generator:
-IF(CMAKE_EXTRA_GENERATOR)
-  SET(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
-ELSE()
-  SET(gen "${CMAKE_GENERATOR}")
-ENDIF()
-
-# Use this value where semi-colons are needed in ep_add args:
-set(sep "^^")
-
-#-----------------------------------------------------------------------------
-# Update CMake module path
-#
-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
-
-#-----------------------------------------------------------------------------
-# Collect CTK library target dependencies
-#
-
-ctkMacroCollectAllTargetLibraries("${CTK_LIBS_SUBDIRS}" "Libs" ALL_TARGET_LIBRARIES)
-ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS_SUBDIRS}" "Plugins" ALL_TARGET_LIBRARIES)
-ctkMacroCollectAllTargetLibraries("${CTK_APPLICATIONS_SUBDIRS}" "Applications" ALL_TARGET_LIBRARIES)
-#MESSAGE(STATUS ALL_TARGET_LIBRARIES:${ALL_TARGET_LIBRARIES})
-
-#-----------------------------------------------------------------------------
-# Initialize NON_CTK_DEPENDENCIES variable
-#
-# Using the variable ALL_TARGET_LIBRARIES initialized above with the help
-# of the macro ctkMacroCollectAllTargetLibraries, let's get the list of all Non-CTK dependencies.
-# NON_CTK_DEPENDENCIES is expected by the macro ctkMacroShouldAddExternalProject
-ctkMacroGetAllNonCTKTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCIES)
-#MESSAGE(STATUS NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})
-
-#-----------------------------------------------------------------------------
-# Qt is expected to be setup by CTK/CMakeLists.txt just before it includes the SuperBuild script
-#
-
-#-----------------------------------------------------------------------------
-# ExternalProjects
-#
-SET(external_projects
-  KWStyle
-  PythonQt
-  DCMTK
-  ZMQ
-  QtMobility
-  OpenIGTLink
-  VTK
-  XIP
-  )
-
-# Include external projects
-FOREACH(p ${external_projects})
-  INCLUDE(CMakeExternals/${p}.cmake)
-ENDFOREACH()
-   
-#-----------------------------------------------------------------------------
-# CTK Utilities
-#
-set(proj CTK-Utilities)
-ExternalProject_Add(${proj}
-  DOWNLOAD_COMMAND ""
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND ""
-  INSTALL_COMMAND ""
-  DEPENDS
-    # Mandatory dependencies
-    #  - none
-    # Optionnal dependencies
-    ${QtMobility_DEPENDS}
-    ${kwstyle_DEPENDS}
-    ${DCMTK_DEPENDS}
-    ${PythonQt_DEPENDS}
-    ${ZMQ_DEPENDS}
-    ${OpenIGTLink_DEPENDS}
-    ${VTK_DEPENDS}
-    ${XIP_DEPENDS}
-)
-
-#-----------------------------------------------------------------------------
-# Generate cmake variable name corresponding to Libs, Plugins and Applications
-#
-SET(ctk_libs_bool_vars)
-FOREACH(lib ${CTK_LIBS_SUBDIRS})
-  LIST(APPEND ctk_libs_bool_vars CTK_LIB_${lib})
-ENDFOREACH()
-
-SET(ctk_plugins_bool_vars)
-FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
-  LIST(APPEND ctk_plugins_bool_vars CTK_PLUGIN_${plugin})
-ENDFOREACH()
-
-SET(ctk_applications_bool_vars)
-FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
-  LIST(APPEND ctk_applications_bool_vars CTK_APP_${app})
-ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# Convenient macro allowing to define superbuild arg
-#
-MACRO(ctk_set_superbuild_boolean_arg ctk_cmake_var)
-  SET(superbuild_${ctk_cmake_var} ON)
-  IF(DEFINED ${ctk_cmake_var} AND NOT ${ctk_cmake_var})
-    SET(superbuild_${ctk_cmake_var} OFF)
-  ENDIF()
-ENDMACRO()
-
-#-----------------------------------------------------------------------------
-# Set superbuild boolean args
-#
-
-SET(ctk_cmake_boolean_args
-  BUILD_TESTING
-  CTK_USE_KWSTYLE
-  ${ctk_libs_bool_vars}
-  ${ctk_plugins_bool_vars}
-  ${ctk_applications_bool_vars}
-  )
-
-SET(ctk_superbuild_boolean_args)
-FOREACH(ctk_cmake_arg ${ctk_cmake_boolean_args})
-  ctk_set_superbuild_boolean_arg(${ctk_cmake_arg})
-  LIST(APPEND ctk_superbuild_boolean_args -D${ctk_cmake_arg}:BOOL=${superbuild_${ctk_cmake_arg}})
-ENDFOREACH()
-
-# MESSAGE("CMake args:")
-# FOREACH(arg ${ctk_superbuild_boolean_args})
-#   MESSAGE("  ${arg}")
-# ENDFOREACH()
-
-#-----------------------------------------------------------------------------
-# CTK Configure
-#
-SET(proj CTK-Configure)
-
-ExternalProject_Add(${proj}
-  DOWNLOAD_COMMAND ""
-  CMAKE_GENERATOR ${gen}
-  CMAKE_ARGS
-    ${ctk_superbuild_boolean_args}
-    -DCTK_SUPERBUILD:BOOL=OFF
-    -DWITH_COVERAGE:BOOL=${WITH_COVERAGE}
-    -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}
-    -DCTK_SUPERBUILD_BINARY_DIR:PATH=${CTK_BINARY_DIR}
-    -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
-    -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-    -DCTK_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
-    -DCTK_C_FLAGS:STRING=${CTK_C_FLAGS}
-    -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
-    -DCTK_KWSTYLE_EXECUTABLE:FILEPATH=${CTK_KWSTYLE_EXECUTABLE}
-    -DDCMTK_DIR:PATH=${DCMTK_DIR} # FindDCMTK expects DCMTK_DIR
-    -DVTK_DIR:PATH=${VTK_DIR}     # FindVTK expects VTK_DIR
-    -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}    # FindPythonQt expects PYTHON_INCLUDE_DIR
-    -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}        # FindPythonQt expects PYTHON_LIBRARY
-    -DPYTHONQT_INSTALL_DIR:PATH=${PYTHONQT_INSTALL_DIR} # FindPythonQt expects PYTHONQT_INSTALL_DIR
-  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
-  BINARY_DIR ${CMAKE_BINARY_DIR}/CTK-build
-  BUILD_COMMAND ""
-  INSTALL_COMMAND ""
-  DEPENDS
-    "CTK-Utilities"
-  )
-
-
-#-----------------------------------------------------------------------------
-# CTK
-#
-#MESSAGE(STATUS SUPERBUILD_EXCLUDE_CTKBUILD_TARGET:${SUPERBUILD_EXCLUDE_CTKBUILD_TARGET})
-IF(NOT DEFINED SUPERBUILD_EXCLUDE_CTKBUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_CTKBUILD_TARGET)
-  SET(proj CTK-build)
-  ExternalProject_Add(${proj}
-    DOWNLOAD_COMMAND ""
-    CMAKE_GENERATOR ${gen}
-    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
-    BINARY_DIR CTK-build
-    INSTALL_COMMAND ""
-    DEPENDS
-      "CTK-Configure"
-    )
-ENDIF()
-
-#-----------------------------------------------------------------------------
-# Custom target allowing to drive the build of CTK project itself
-#
-ADD_CUSTOM_TARGET(CTK
-  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
-  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
-  )
+###########################################################################
+#
+#  Library:   CTK
+# 
+#  Copyright (c) 2010  Kitware Inc.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.commontk.org/LICENSE
+#
+#  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.
+# 
+###########################################################################
+
+SET(cmake_version_required "2.8")
+SET(cmake_version_required_dash "2-8")
+
+CMAKE_MINIMUM_REQUIRED(VERSION ${cmake_version_required})
+
+# 
+# CTK_KWSTYLE_EXECUTABLE
+# DCMTK_DIR
+# QT_QMAKE_EXECUTABLE
+# VTK_DIR
+# PYTHONQT_INSTALL_DIR
+# PYTHON_LIBRARY
+# PYTHON_INCLUDE_DIR
+#
+
+#-----------------------------------------------------------------------------
+# Enable and setup External project global properties
+#
+INCLUDE(ExternalProject)
+
+SET(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals")
+SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base})
+
+SET(ep_install_dir ${ep_base}/Install)
+SET(ep_build_dir ${ep_base}/Build)
+SET(ep_source_dir ${ep_base}/Source)
+#SET(ep_parallelism_level)
+SET(ep_build_shared_libs ON)
+SET(ep_build_testing OFF)
+
+SET(ep_common_args
+  -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
+  -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+  -DBUILD_TESTING:BOOL=${ep_build_testing}
+  )
+
+# Compute -G arg for configuring external projects with the same CMake generator:
+IF(CMAKE_EXTRA_GENERATOR)
+  SET(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
+ELSE()
+  SET(gen "${CMAKE_GENERATOR}")
+ENDIF()
+
+# Use this value where semi-colons are needed in ep_add args:
+set(sep "^^")
+
+#-----------------------------------------------------------------------------
+# Update CMake module path
+#
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
+
+#-----------------------------------------------------------------------------
+# Collect CTK library target dependencies
+#
+
+ctkMacroCollectAllTargetLibraries("${CTK_LIBS_SUBDIRS}" "Libs" ALL_TARGET_LIBRARIES)
+ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS_SUBDIRS}" "Plugins" ALL_TARGET_LIBRARIES)
+ctkMacroCollectAllTargetLibraries("${CTK_APPLICATIONS_SUBDIRS}" "Applications" ALL_TARGET_LIBRARIES)
+#MESSAGE(STATUS ALL_TARGET_LIBRARIES:${ALL_TARGET_LIBRARIES})
+
+#-----------------------------------------------------------------------------
+# Initialize NON_CTK_DEPENDENCIES variable
+#
+# Using the variable ALL_TARGET_LIBRARIES initialized above with the help
+# of the macro ctkMacroCollectAllTargetLibraries, let's get the list of all Non-CTK dependencies.
+# NON_CTK_DEPENDENCIES is expected by the macro ctkMacroShouldAddExternalProject
+ctkMacroGetAllNonCTKTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCIES)
+#MESSAGE(STATUS NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})
+
+#-----------------------------------------------------------------------------
+# Qt is expected to be setup by CTK/CMakeLists.txt just before it includes the SuperBuild script
+#
+
+#-----------------------------------------------------------------------------
+# ExternalProjects
+#
+SET(external_projects
+  KWStyle
+  PythonQt
+  DCMTK
+  ZMQ
+  QtMobility
+  OpenIGTLink
+  VTK
+  XIP
+  )
+
+# Include external projects
+FOREACH(p ${external_projects})
+  INCLUDE(CMakeExternals/${p}.cmake)
+ENDFOREACH()
+   
+#-----------------------------------------------------------------------------
+# CTK Utilities
+#
+set(proj CTK-Utilities)
+ExternalProject_Add(${proj}
+  DOWNLOAD_COMMAND ""
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND ""
+  INSTALL_COMMAND ""
+  DEPENDS
+    # Mandatory dependencies
+    #  - none
+    # Optionnal dependencies
+    ${QtMobility_DEPENDS}
+    ${kwstyle_DEPENDS}
+    ${DCMTK_DEPENDS}
+    ${PythonQt_DEPENDS}
+    ${ZMQ_DEPENDS}
+    ${OpenIGTLink_DEPENDS}
+    ${VTK_DEPENDS}
+    ${XIP_DEPENDS}
+)
+
+#-----------------------------------------------------------------------------
+# Generate cmake variable name corresponding to Libs, Plugins and Applications
+#
+SET(ctk_libs_bool_vars)
+FOREACH(lib ${CTK_LIBS_SUBDIRS})
+  LIST(APPEND ctk_libs_bool_vars CTK_LIB_${lib})
+ENDFOREACH()
+
+SET(ctk_plugins_bool_vars)
+FOREACH(plugin ${CTK_PLUGINS_SUBDIRS})
+  LIST(APPEND ctk_plugins_bool_vars CTK_PLUGIN_${plugin})
+ENDFOREACH()
+
+SET(ctk_applications_bool_vars)
+FOREACH(app ${CTK_APPLICATIONS_SUBDIRS})
+  LIST(APPEND ctk_applications_bool_vars CTK_APP_${app})
+ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# Convenient macro allowing to define superbuild arg
+#
+MACRO(ctk_set_superbuild_boolean_arg ctk_cmake_var)
+  SET(superbuild_${ctk_cmake_var} ON)
+  IF(DEFINED ${ctk_cmake_var} AND NOT ${ctk_cmake_var})
+    SET(superbuild_${ctk_cmake_var} OFF)
+  ENDIF()
+ENDMACRO()
+
+#-----------------------------------------------------------------------------
+# Set superbuild boolean args
+#
+
+SET(ctk_cmake_boolean_args
+  BUILD_TESTING
+  CTK_USE_KWSTYLE
+  ${ctk_libs_bool_vars}
+  ${ctk_plugins_bool_vars}
+  ${ctk_applications_bool_vars}
+  )
+
+SET(ctk_superbuild_boolean_args)
+FOREACH(ctk_cmake_arg ${ctk_cmake_boolean_args})
+  ctk_set_superbuild_boolean_arg(${ctk_cmake_arg})
+  LIST(APPEND ctk_superbuild_boolean_args -D${ctk_cmake_arg}:BOOL=${superbuild_${ctk_cmake_arg}})
+ENDFOREACH()
+
+# MESSAGE("CMake args:")
+# FOREACH(arg ${ctk_superbuild_boolean_args})
+#   MESSAGE("  ${arg}")
+# ENDFOREACH()
+
+#-----------------------------------------------------------------------------
+# CTK Configure
+#
+SET(proj CTK-Configure)
+
+ExternalProject_Add(${proj}
+  DOWNLOAD_COMMAND ""
+  CMAKE_GENERATOR ${gen}
+  CMAKE_ARGS
+    ${ctk_superbuild_boolean_args}
+    -DCTK_SUPERBUILD:BOOL=OFF
+    -DWITH_COVERAGE:BOOL=${WITH_COVERAGE}
+    -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}
+    -DCTK_SUPERBUILD_BINARY_DIR:PATH=${CTK_BINARY_DIR}
+    -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
+    -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+    -DCTK_CXX_FLAGS:STRING=${CTK_CXX_FLAGS}
+    -DCTK_C_FLAGS:STRING=${CTK_C_FLAGS}
+    -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
+    -DCTK_KWSTYLE_EXECUTABLE:FILEPATH=${CTK_KWSTYLE_EXECUTABLE}
+    -DDCMTK_DIR:PATH=${DCMTK_DIR} # FindDCMTK expects DCMTK_DIR
+    -DVTK_DIR:PATH=${VTK_DIR}     # FindVTK expects VTK_DIR
+	-DZMQ_DIR:PATH=${ZMQ_DIR}     # FindVTK expects VTK_DIR
+	-DOpenIGTLink_DIR:PATH=${OpenIGTLink_DIR}     # FindVTK expects VTK_DIR
+    -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}    # FindPythonQt expects PYTHON_INCLUDE_DIR
+    -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}        # FindPythonQt expects PYTHON_LIBRARY
+    -DPYTHONQT_INSTALL_DIR:PATH=${PYTHONQT_INSTALL_DIR} # FindPythonQt expects PYTHONQT_INSTALL_DIR
+  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+  BINARY_DIR ${CMAKE_BINARY_DIR}/CTK-build
+  BUILD_COMMAND ""
+  INSTALL_COMMAND ""
+  DEPENDS
+    "CTK-Utilities"
+  )
+
+
+#-----------------------------------------------------------------------------
+# CTK
+#
+#MESSAGE(STATUS SUPERBUILD_EXCLUDE_CTKBUILD_TARGET:${SUPERBUILD_EXCLUDE_CTKBUILD_TARGET})
+IF(NOT DEFINED SUPERBUILD_EXCLUDE_CTKBUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_CTKBUILD_TARGET)
+  SET(proj CTK-build)
+  ExternalProject_Add(${proj}
+    DOWNLOAD_COMMAND ""
+    CMAKE_GENERATOR ${gen}
+    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+    BINARY_DIR CTK-build
+    INSTALL_COMMAND ""
+    DEPENDS
+      "CTK-Configure"
+    )
+ENDIF()
+
+#-----------------------------------------------------------------------------
+# Custom target allowing to drive the build of CTK project itself
+#
+ADD_CUSTOM_TARGET(CTK
+  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CTK-build
+  )