| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 | #############################################################################  Library:   CTK##  Copyright (c) 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.apache.org/licenses/LICENSE-2.0.txt##  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.4)#-----------------------------------------------------------------------------# 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()#-----------------------------------------------------------------------------if(APPLE)  # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,  #       we ensure that the bitness will be properly detected.  include(${CMAKE_SOURCE_DIR}/CMake/ctkBlockSetCMakeOSXVariables.cmake)endif()#-----------------------------------------------------------------------------project(CTK)#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Library mode: SHARED (default) or STATIC#set(CTK_LIBRARY_MODE "SHARED")option(CTK_BUILD_SHARED_LIBS "Build CTK libraries as shared module." ON)mark_as_advanced(CTK_BUILD_SHARED_LIBS)if(NOT CTK_BUILD_SHARED_LIBS)  set(CTK_LIBRARY_MODE "STATIC")endif()#-----------------------------------------------------------------------------# Set a default build type if none was specified#if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)  message(STATUS "Setting build type to 'Debug' as none was specified.")  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)  mark_as_advanced(CMAKE_BUILD_TYPE)  # Set the possible values of build type for cmake-gui  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"    "MinSizeRel" "RelWithDebInfo")endif()#-----------------------------------------------------------------------------# 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)#-----------------------------------------------------------------------------# Output directories.#foreach(type LIBRARY RUNTIME ARCHIVE)  # Make sure the directory exists  if(DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY     AND NOT EXISTS ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})    message(FATAL_ERROR "CTK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${CTK_CMAKE_${type}_OUTPUT_DIRECTORY}]")  endif()  if(CTK_SUPERBUILD)    set(output_dir ${CTK_BINARY_DIR}/bin)    if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)      set(CTK_CMAKE_${type}_OUTPUT_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)    endif()  else()    if(NOT DEFINED CTK_CMAKE_${type}_OUTPUT_DIRECTORY)      set(output_dir ${CTK_BINARY_DIR}/bin)    else()      set(output_dir ${CTK_CMAKE_${type}_OUTPUT_DIRECTORY})    endif()  endif()  set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")  if(NOT DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY)    set(CTK_PLUGIN_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})  endif()endforeach()#-----------------------------------------------------------------------------# CTK version number.  An even minor number corresponds to releases.#set(CTK_MAJOR_VERSION 0)set(CTK_MINOR_VERSION 1)set(CTK_PATCH_VERSION 0)set(CTK_VERSION    "${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}.${CTK_PATCH_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()#-----------------------------------------------------------------------------# Install directories, used for install rules.#if(NOT CTK_INSTALL_BIN_DIR)  set(CTK_INSTALL_BIN_DIR "bin")endif()if(NOT CTK_INSTALL_LIB_DIR)  set(CTK_INSTALL_LIB_DIR "lib/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")endif()if(NOT CTK_INSTALL_INCLUDE_DIR)  set(CTK_INSTALL_INCLUDE_DIR "include/ctk-${CTK_MAJOR_VERSION}.${CTK_MINOR_VERSION}")endif()if(NOT CTK_INSTALL_DOC_DIR)  set(CTK_INSTALL_DOC_DIR "doc")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, CTK_BASE_LIBRARIES and CTK_WRAPPED_LIBRARIES_PYTHONQT#set(CTK_BASE_LIBRARIES CACHE INTERNAL "CTK base libraries" FORCE)set(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)set(CTK_WRAPPED_LIBRARIES_PYTHONQT CACHE INTERNAL "CTK libraries wrapped using PythonQt" FORCE)# Variable use in CTKConfig.cmake.inset(CTK_LIBRARIES CACHE INTERNAL "CTK libraries" FORCE)set(${PROJECT_NAME}_PLUGIN_LIBRARIES CACHE INTERNAL "CTK plugins" FORCE)# Used by CTKGenerateCTKConfig.cmake and also used to reference script from other scriptsset(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)set(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)#-----------------------------------------------------------------------------# CMake function(s) and macro(s)#include(CMake/ctkMacroParseArguments.cmake)include(CMake/ctkMacroSetPaths.cmake)include(CMake/ctkMacroListFilter.cmake)include(CMake/ctkMacroOptionUtils.cmake)include(CMake/ctkMacroBuildLib.cmake)include(CMake/ctkMacroBuildLibWrapper.cmake)include(CMake/ctkMacroBuildPlugin.cmake)include(CMake/ctkMacroBuildApp.cmake)include(CMake/ctkMacroCompilePythonScript.cmake)include(CMake/ctkMacroWrapPythonQt.cmake)include(CMake/ctkMacroSetupQt.cmake)include(CMake/ctkMacroTargetLibraries.cmake) # Import multiple macrosinclude(CMake/ctkFunctionExtractOptionNameAndValue.cmake)include(CMake/ctkMacroValidateBuildOptions.cmake)include(CMake/ctkMacroAddCtkLibraryOptions.cmake)include(CMake/ctkFunctionGenerateDGraphInput.cmake)include(CMake/ctkFunctionGenerateProjectXml.cmake)include(CMake/ctkFunctionGeneratePluginManifest.cmake)include(CMake/ctkMacroGeneratePluginResourceFile.cmake)include(CMake/ctkFunctionCheckCompilerFlags.cmake)include(CMake/ctkFunctionGetIncludeDirs.cmake)include(CMake/ctkFunctionGetLibraryDirs.cmake)include(CMake/ctkFunctionGetGccVersion.cmake)#-----------------------------------------------------------------------------# Testing#option(BUILD_TESTING "Test the project" OFF)mark_as_advanced(BUILD_TESTING)if(BUILD_TESTING)  enable_testing()  include(CTest)  set(CPP_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})  mark_as_advanced(TCL_TCLSH DART_ROOT)  include(CMake/ctkMacroSimpleTest.cmake)  include(CMake/ctkMacroSimpleTestWithData.cmake)  # 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)mark_as_advanced(WITH_COVERAGE)#-----------------------------------------------------------------------------# Documentation#option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Where documentation archives should be stored")mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)#-----------------------------------------------------------------------------# 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#ctkFunctionGetGccversion(${CMAKE_CXX_COMPILER} GCC_VERSION)# MinGW does not export all symbols automatically, so no need to set flags.## With gcc < 4.5, RTTI symbols from classes declared in third-party libraries# which are not "gcc visibility aware" are marked with hidden visibility in# DSOs which include the class declaration and which are compiled with# hidden visibility. This leads to dynamic_cast and exception handling problems.# While this problem could be worked around by sandwiching the include# directives for the third-party headers between "#pragma visibility push/pop"# statements, it is generally safer to just use default visibility with# gcc < 4.5.if(CMAKE_COMPILER_IS_GNUCXX AND NOT ${GCC_VERSION} VERSION_LESS "4.5" AND NOT MINGW)  set(VISIBILITY_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")endif()#-----------------------------------------------------------------------------# Set coverage Flags#if(WITH_COVERAGE)  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")    set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")    set(COVERAGE_CXX_FLAGS ${coverage_flags})    set(COVERAGE_C_FLAGS ${coverage_flags})  endif()endif()#-----------------------------------------------------------------------------# CTK C/CXX Flags#set(CTK_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}")set(CTK_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}")if(CMAKE_COMPILER_IS_GNUCXX)  set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2")  ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)  ctkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags)  # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so  # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag.  # Doing so should allow to build package made for distribution using older linux distro.  if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0"))    ctkFunctionCheckCompilerFlags("-fstack-protector-all" cflags)  endif()  if(MINGW)    # suppress warnings about auto imported symbols    set(CTK_CXX_FLAGS "-Wl,--enable-auto-import ${CTK_CXX_FLAGS}")  endif()  set(CTK_C_FLAGS "${cflags} ${CTK_C_FLAGS}")  set(CTK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${CTK_CXX_FLAGS}")endif()if(MSVC)  set(msvc_suppressed_warnings    "/wd4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)  )  set(CTK_CXX_FLAGS "${CTK_CXX_FLAGS} ${msvc_suppressed_warnings}")endif()#-----------------------------------------------------------------------------# QT#ctkMacroSetupQt()# Update CTK_BASE_LIBRARIES with QT librariesif(QT4_FOUND)  set(CTK_BASE_LIBRARIES ${CTK_BASE_LIBRARIES} ${QT_LIBRARIES} CACHE INTERNAL "CTK base libraries" FORCE)endif()#-----------------------------------------------------------------------------# To make options show up in both CTK-SuperBuild and CTK regular build, let's add them# before the SuperBuild script is included##-----------------------------------------------------------------------------# High-Level CTK options# The ctk_enable_option macro expects a logical expression after the first# three arguments. This expression should only contain build option names# which belong to leafs in the required dependency tree.# The CTK infrastructure for high-level DICOM support. This includes# DICOM indexing, networking, and GUI widgets.ctk_enable_option(DICOM "Enable default DICOM support" OFF                  CTK_LIB_DICOM/Widgets)# The CTK infrastructure for building a DICOM Part 19 compliant application# host and/or hosted application. This will not enable any example plugins# or executables (enable CTK_ENABLE_EXAMPLES for that).ctk_enable_option(DICOMApplicationHosting "Enable DICOM Part 19 Application Hosting support" OFF                  CTK_PLUGIN_org.commontk.dah.host AND CTK_PLUGIN_org.commontk.dah.app)# The CTK Qt Widgets. This will enable the Qt Widget library only.# It might trigger the enabling of other widget libraries in combination# with other enabled options.ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF                  CTK_LIB_Widgets)# The CTK Plugin Framework, a dynamic component system based on OSGi.# This will enable only the framework itself.                  ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF                  CTK_LIB_PluginFramework)#-----------------------------------------------------------------------------# Other options# The CTK Python Wrappingctk_enable_option(Python_Wrapping "Wrap CTK classes using Qt meta-object system into Python language" OFF                  CTK_LIB_Scripting/Python/Core)# Build examples# Create the logical expression containing the minium set of required options# for the CTK_BUILD_EXAMPLES option to be ONset(_build_examples_logical_expr)foreach(_app ${CTK_ENABLED_APPS})  list(APPEND _build_examples_logical_expr CTK_APP_${_app} AND)endforeach()if(_build_examples_logical_expr)  list(REMOVE_AT _build_examples_logical_expr -1)endif()ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF                  ${_build_examples_logical_expr})# Git protocol optionoption(CTK_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)mark_as_advanced(CTK_USE_GIT_PROTOCOL)set(git_protocol "git")if(NOT CTK_USE_GIT_PROTOCOL)  set(git_protocol "http")endif()# Let's mark as advanced some default propertiesmark_as_advanced(CMAKE_INSTALL_PREFIX)mark_as_advanced(DART_TESTING_TIMEOUT)# KWStyleoption(CTK_USE_KWSTYLE     "Enable sourcecode-based style tests." OFF)mark_as_advanced(CTK_USE_KWSTYLE)# Qt Designer Pluginsoption(CTK_BUILD_QTDESIGNER_PLUGINS "Build Qt Designer plugins" ON)mark_as_advanced(CTK_BUILD_QTDESIGNER_PLUGINS)if(CTK_BUILD_QTDESIGNER_PLUGINS)  include(CMake/ctkMacroBuildQtDesignerPlugin.cmake)endif()#-----------------------------------------------------------------------------# CTK Libraries#ctk_lib_option(Core               "Build the Core library" ON)ctk_lib_option(PluginFramework               "Build the Plugin Framework" OFF               CTK_ENABLE_PluginFramework)ctk_lib_option(Widgets               "Build the Widgets library" OFF               CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))               ctk_lib_option(DICOM/Core               "Build the DICOM Core library" OFF               CTK_ENABLE_DICOM OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))               ctk_lib_option(DICOM/Widgets               "Build the DICOM Widgets library" OFF               CTK_ENABLE_DICOM AND CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))               ctk_lib_option(ImageProcessing/ITK/Core               "Build the ITK Core library" OFF)               ctk_lib_option(Scripting/Python/Core               "Build the Python Core library" OFF)               ctk_lib_option(Scripting/Python/Widgets               "Build the Python Widgets library" OFF               CTK_LIB_Widgets AND CTK_ENABLE_Python_Wrapping)               ctk_lib_option(Visualization/VTK/Core               "Build the VTK Core library" OFF)               ctk_lib_option(Visualization/VTK/Widgets               "Build the VTK Widgets library" OFF)               #ctk_lib_option(ModuleDescription#               "Build the Command Line Module Description library" OFF)#ctk_lib_option(Visualization/XIP#               "Build the XIP library" OFF)#-----------------------------------------------------------------------------# CTK Applications - Use ON or OFF to indicate if the application should be built by default# #ctk_app_option(ctkCLIPluginExplorer "Build the CLI Plugin Explorer" OFF)ctk_app_option(ctkDICOM               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMIndexer               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMDemoSCU               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMQuery               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMRetrieve               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMQueryRetrieve               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkExampleHost               "Build the DICOM example application" OFF               CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkExampleHostedApp               "Build the DICOM example application" OFF               CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkEventBusDemo               "Build the DICOM example application" OFF               CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkPluginBrowser               "Build the DICOM example application" OFF               CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkPluginGenerator               "Build the DICOM example application" OFF               CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkDICOMObjectViewer               "Build the DICOM example application" OFF               CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)               ctk_app_option(ctkSimplePythonShell               "Build the DICOM example application" OFF               CTK_ENABLE_Python_Wrapping AND CTK_BUILD_EXAMPLES)# Save the set of enabled apps in a cache fileset(_enabled_apps)foreach(_app ${CTK_APPS})  if(CTK_APP_${_app})    list(APPEND _enabled_apps ${_app})  endif()endforeach()set(CTK_ENABLED_APPS ${_enabled_apps} CACHE INTERNAL "" FORCE)#-----------------------------------------------------------------------------# CTK Plugins - none of them is build by default## Plugins in the list below are not build by defaultset(plugin_list  # Optional plug-ins implementings interfaces in PluginFramework/service/  org.commontk.configadmin  org.commontk.eventadmin  org.commontk.log  org.commontk.log4qt  org.commontk.metatype  # Misc  org.commontk.slicermodule  )foreach(_plugin ${plugin_list})    ctk_plugin_option(${_plugin} "Build the ${_plugin} plugin." OFF)endforeach()# Plug-ins related to the PluginGenerator applicationctk_plugin_option(org.commontk.plugingenerator.core "Build the org.commontk.plugingenerator.core plugin." OFF)ctk_plugin_option(org.commontk.plugingenerator.ui                  "Build the org.commontk.plugingenerator.ui plugin." OFF                  CTK_APP_ctkPluginGenerator)# Plug-ins related to DICOM WG23 (Application Hosting)ctk_plugin_option(org.commontk.dah.core "Build the org.commontk.dah.core plugin." OFF)ctk_plugin_option(org.commontk.dah.app "Build the org.commontk.dah.app plugin." OFF                  CTK_ENABLE_DICOMApplicationHosting)ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin." OFF                  CTK_ENABLE_DICOMApplicationHosting)                  ctk_plugin_option(org.commontk.dah.exampleapp                  "Build the org.commontk.dah.exampleapp plugin." OFF                  CTK_APP_ctkExampleHostedApp)                  ctk_plugin_option(org.commontk.dah.examplehost                  "Build the org.commontk.dah.examplehost plugin." OFF                  CTK_APP_ctkExampleHost)# Plug-ins related to the EventBus demo applicationctk_plugin_option(org.commontk.eventbus                  "Build the org.commontk.eventbus plugin." OFF                  CTK_APP_ctkEventBusDemo)#-----------------------------------------------------------------------------# Generate target_directories list - List of directory corresponding to the different# libraries, plugins and applications associated with the corresponding option name.## The following FOREACH loops are used to:#   1) Update either CTK_LIBS_SUBDIRS, CTK_PLUGINS_SUBDIRS or CTK_APPS_SUBDIRS variables## For CTK libraries, if the file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake exists,# 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)## The file Libs/<DIR>/<LIBNAME>/ctk_library_options.cmake should look like:##     set(ctk_library_options#       OPT1:OFF#       OPT2:ON#       )# Create list of directories corresponding to the enabled targetsset(target_directories)set(ctk_lib_options_list) # This list will be updated in ctkMacroAddCtkLibraryOptionsforeach(lib ${CTK_LIBS})  if(CTK_LIB_${lib})    ctkMacroAddCtkLibraryOptions(${lib})  endif()  list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}^^CTK_LIB_${lib}")endforeach()foreach(plugin ${CTK_PLUGINS})  list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${plugin}^^CTK_PLUGIN_${plugin}")endforeach()foreach(app ${CTK_APPS})  list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${app}^^CTK_APP_${app}")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                -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}                -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}                -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}                -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}")ctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_EXTERNALS)ctkMacroValidateBuildOptions("${CTK_BINARY_DIR}" "${DGraph_EXECUTABLE}" "${target_directories}")#-----------------------------------------------------------------------------# CTK Python wrapping# Enable CTK_LIB_Scripting/Python/Core if either CTK_ENABLE_Python_Wrapping OR CTK_WRAP_PYTHONQT_FULL#set(CTK_WRAP_PYTHONQT_LIGHT ${CTK_ENABLE_Python_Wrapping})option(CTK_WRAP_PYTHONQT_FULL "Experimental - Wrap CTK classes using Qt meta-object system into Python language" OFF)mark_as_advanced(CTK_WRAP_PYTHONQT_FULL)if(CTK_WRAP_PYTHONQT_FULL AND CTK_WRAP_PYTHONQT_LIGHT)  message(FATAL_ERROR "CTK_ENABLE_Python_Wrapping AND CTK_WRAP_PYTHONQT_FULL options are mutually exclusive. Please enable only one !")endif()set(logical_expr CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL)if((${logical_expr}) AND NOT CTK_LIB_Scripting/Python/Core)  set(CTK_LIB_Scripting/Python/Core ON CACHE BOOL "Build the Python Core library" FORCE)  set(enabling_msg)  ctk_option_logical_expression_to_message(enabling_msg "${logical_expr}")  message("Enabling [CTK_LIB_Scripting/Python/Core] because of [${enabling_msg}] evaluates to True")endif()# Check if dependencies are satisfiedif(CTK_LIB_Scripting/Python/Core)  find_package(PythonInterp)  if(NOT PYTHONINTERP_FOUND)    message(FATAL_ERROR "PYTHON_EXECUTABLE variable should be set to build CTK_LIB_Scripting/Python")  endif()  find_package(PythonLibs)  if(NOT PYTHONLIBS_FOUND)    message(FATAL_ERROR "PYTHON_LIBRARIES and PYTHON_INCLUDE_DIRS should be set to build CTK_LIB_Scripting/Python")  endif()endif()#-----------------------------------------------------------------------------# DGraph## Generate DGraph input file expected by DGraphctkFunctionGenerateDGraphInput(${CTK_BINARY_DIR} "${target_directories}" WITH_OPTION)# Obtain list of target ordered topologicallyctkMacroSetPaths("${QT_INSTALLED_LIBRARY_DIR}")execute_process(  COMMAND "${DGraph_EXECUTABLE}" "${CTK_BINARY_DIR}/DGraphInput.txt"  WORKING_DIRECTORY ${CTK_BINARY_DIR}  RESULT_VARIABLE RESULT_VAR  OUTPUT_VARIABLE CTEST_PROJECT_SUBPROJECTS_OUTPUT  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()# Convert 'CTEST_PROJECT_SUBPROJECTS_OUTPUT' to a liststring(REPLACE " " "\\;" CTEST_PROJECT_SUBPROJECTS "${CTEST_PROJECT_SUBPROJECTS_OUTPUT}")set(CTEST_PROJECT_SUBPROJECTS ${CTEST_PROJECT_SUBPROJECTS})# If the list of subproject is empty, let's at least build CTKCorelist(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 scriptsconfigure_file(${CTK_SOURCE_DIR}/CTestConfigSubProject.cmake.in               ${CTK_BINARY_DIR}/CTestConfigSubProject.cmake)#-----------------------------------------------------------------------------# Project.xml## Generate Project.xml file expected by the CTest driver scriptctkFunctionGenerateProjectXml(${CTK_BINARY_DIR} ${PROJECT_NAME} "${target_directories}" ${CTK_SUPERBUILD})#-----------------------------------------------------------------------------# CTK dependencies - Projects should be TOPOLOGICALLY ordered#-----------------------------------------------------------------------------set(CTK_POSSIBLE_DEPENDENCIES  CTKData  Log4Qt  KWStyle  VTK  PythonQt  PythonQtGenerator # Should be added after PythonQt - See comment in CMakeExternals/PythonQtGenerator.cmake  DCMTK  ZMQ  QtSOAP  qxmlrpc  OpenIGTLink  XIP  ITK  )set(CTK_DEPENDENCIES) # This variable will contain the list of required CTK dependenciesinclude(CMake/ctkBlockCheckDependencies.cmake)#-----------------------------------------------------------------------------# Superbuild script#if(CTK_SUPERBUILD)  include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")  return()endif()#-----------------------------------------------------------------------------# Expand variables containing include and library directories for external projects# This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptionsforeach(_external_target ${EXTERNAL_TARGETS})  if(${_external_target}_FIND_PACKAGE_CMD)    #message("Calling find_package(${${_external_target}_FIND_PACKAGE_CMD})")    find_package(${${_external_target}_FIND_PACKAGE_CMD} REQUIRED)  endif()endforeach()foreach(_external_target ${EXTERNAL_TARGETS})  if(${_external_target}_INCLUDE_DIRS)    #message("[${_external_target}] Resolving include variables: ${${_external_target}_INCLUDE_DIRS}")    foreach(_include_variable ${${_external_target}_INCLUDE_DIRS})      #message("[${_external_target}] Appending ${${_include_variable}}")      if(${_include_variable})        list(APPEND ${_external_target}_INCLUDE_DIRS ${${_include_variable}})      else()        list(APPEND ${_external_target}_INCLUDE_DIRS ${_include_variable})      endif()      #message("[${_external_target}] New dirs: ${${_external_target}_INCLUDE_DIRS}")    endforeach()    #message("[${_external_target}] Appended dirs: ${${_external_target}_INCLUDE_DIRS}")  endif()  if(${_external_target}_LIBRARY_DIRS)    #message("[${_external_target}] Resolving library variables: ${${_external_target}_LIBRARY_DIRS}")    foreach(_library_variable ${${_external_target}_LIBRARY_DIRS})      #message("[${_external_target}] Appending ${${_library_variable}}")      if(${_library_variable})        list(APPEND ${_external_target}_LIBRARY_DIRS ${${_library_variable}})      else()        list(APPEND ${_external_target}_LIBRARY_DIRS ${_library_variable})      endif()      #message("[${_external_target}] New dirs: ${${_external_target}_LIBRARY_DIRS}")    endforeach()    #message("[${_external_target}] Appended dirs: ${${_external_target}_LIBRARY_DIRS}")  endif()endforeach()# Since PYTHONQT_USE_VTK library option can be enabled independently of# Visualization/VTK/Core, let's make sure VTK has been properly discoveredif(CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)  find_package(VTK REQUIRED)endif()set(CTK_WRAP_PYTHONQT_USE_VTK ${CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK})#-----------------------------------------------------------------------------# 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_DIRif(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(CTK_CONFIG_H_INCLUDE_DIR ${CTK_BINARY_DIR})#-----------------------------------------------------------------------------# Set C/CXX Flags#set(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS} CACHE STRING "CMake C Flags" FORCE)set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)#-----------------------------------------------------------------------------# Set the header template which defines custom export/import macros# for shared libraries#set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")#-----------------------------------------------------------------------------# Setup testing environment before Libs are added#if(BUILD_TESTING)  add_subdirectory(Libs/Testing)endif()#-----------------------------------------------------------------------------# Add CTK library subdirectories#foreach(lib ${CTK_LIBS})  IF (CTK_LIB_${lib})    add_subdirectory(Libs/${lib})  endif()endforeach()#-----------------------------------------------------------------------------# Add CTK plugin subdirectories#foreach(plugin ${CTK_PLUGINS})  if(CTK_PLUGIN_${plugin})    add_subdirectory(Plugins/${plugin})  endif()endforeach()#-----------------------------------------------------------------------------# Add CTK application subdirectories#foreach(app ${CTK_APPS})  IF (CTK_APP_${app})    add_subdirectory(Applications/${app})  endif()endforeach()if(BUILD_TESTING)  add_subdirectory(Applications/Testing)endif()#-----------------------------------------------------------------------------# Add general purpose subdirectories##add_subdirectory(Testing)#add_subdirectory(Examples)#-----------------------------------------------------------------------------# Style Checking configuration#include(Utilities/KWStyle/KWStyle.cmake)#---------------------------------------------------------------------------# Documentation#add_subdirectory( Documentation )#-----------------------------------------------------------------------------# 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)
 |