diff --git a/CMake/mitkFunctionCreateModule.cmake b/CMake/mitkFunctionCreateModule.cmake index 594c9f1c34..d9880b4ed2 100644 --- a/CMake/mitkFunctionCreateModule.cmake +++ b/CMake/mitkFunctionCreateModule.cmake @@ -1,609 +1,633 @@ function(_link_directories_for_packages) set(ALL_LIBRARY_DIRS ) foreach(package ${ARGN}) if(NOT ${package} MATCHES "^(Qt[45].*|ITK|VTK)$") foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) if(EXISTS "${dir}/MITK_${package}_Config.cmake") include("${dir}/MITK_${package}_Config.cmake") break() endif() endforeach() endif() endforeach() if(ALL_LIBRARY_DIRS) list(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) link_directories(${ALL_LIBRARY_DIRS}) endif() endfunction() ################################################################## # # mitk_create_module # #! Creates a module for the automatic module dependency system within MITK. #! Configurations are generated in the moduleConf directory. #! #! USAGE: #! #! \code -#! MITK_CREATE_MODULE([] +#! mitk_create_module([] #! [INCLUDE_DIRS ] #! [INTERNAL_INCLUDE_DIRS ] #! [DEPENDS ] #! [PACKAGE_DEPENDS ] #! [TARGET_DEPENDS #! [EXPORT_DEFINE ] -#! [QT_MODULE] #! [HEADERS_ONLY] #! [WARNINGS_AS_ERRORS] #! \endcode #! #! The parameter specifies the name of the module which is used -#! create a logical target name. The parameter is options in case the +#! to create a logical target name. The parameter is optional in case the #! MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME variable evaluates to TRUE. The #! module name will then be derived from the directory name in which this -#! macro is called. +#! function is called. #! #! If set, the following variables will be used to validate the module name: #! #! MITK_MODULE_NAME_REGEX_MATCH The module name must match this regular expression. #! MITK_MODULE_NAME_REGEX_NOT_MATCH The module name must not match this regular expression. #! #! If the MITK_MODULE_NAME_PREFIX variable is set, the module name will be prefixed #! with its contents. #! #! A modules source files are specified in a separate CMake file usually #! called files.cmake, located in the module root directory. The #! mitk_create_module() macro evaluates the following CMake variables #! from the files.cmake file: #! #! - CPP_FILES A list of .cpp files #! - H_FILES A list of .h files without a corresponding .cpp file #! - TXX_FILES A list of .txx files #! - RESOURCE_FILES A list of files (resources) which are embedded into the module #! - MOC_H_FILES A list of Qt header files which should be processed by the MOC #! - UI_FILES A list of .ui Qt UI files #! - QRC_FILES A list of .qrc Qt resource files #! - DOX_FILES A list of .dox Doxygen files #! #! List of variables available after the function is called: #! - MODULE_NAME #! - MODULE_TARGET #! - MODULE_IS_ENABLED #! - MODULE_SUBPROJECTS #! - ALL_META_DEPENDENCIES #! -#! \param QT_MODULE deprecated. Just use Qt4 or Qt5 in the PACKAGE_DEPENDS argument. -#! \param HEADERS_ONLY specify this if the modules just contains header files. +#! \sa mitk_create_executable +#! +#! Parameters (all optional): +#! +#! \param The module name (also used as target name) +#! \param SUBPROJECTS List of CDash labels +#! \param VERSION Module version number, e.g. "1.2.0" +#! \param INCLUDE_DIRS Public include dirs (used in mitkMacroCreateModuleConf.cmake) +#! \param INTERNAL_INCLUDE_DIRS Private include dirs internal to this module +#! \param DEPENDS List of public module dependencies +#! \param DEPENDS_INTERNAL List of private module dependencies +#! \param PACKAGE_DEPENDS List of public packages dependencies (e.g. Qt, VTK, etc.). +#! Package dependencies have the following syntax: +#! \verbatim +#! PACKAGE[|COMPONENT1[+COMPONENT2]...] +#! \endverbatim +#! \param TARGET_DEPENDS List of CMake targets this module depends on +#! \param EXPORT_DEFINE Export macro name for public symbols of this module +#! \param AUTOLOAD_WITH A module target name identifying the module which will +#! trigger the automatic loading of this module +#! \param ADDITIONAL_LIBS List of addidtional libraries linked to this module +#! \param FILES_CMAKE File name of a CMake file setting source list variables +#! (defaults to files.cmake) +#! \param DEPRECATED_SINCE Marks this modules as deprecated since +#! \param DESCRIPTION A description for this module +#! +#! Options (optional) +#! +#! \param FORCE_STATIC Force building this module as a static library +#! \param HEADERS_ONLY This module is a headers-only library +#! \param GCC_DEFAULT_VISIBILITY Do not use gcc visibility flags - all +#! symbols will be exported +#! \param NO_INIT Do not create CppMicroServices initialization code +#! \param NO_FEATURE_INFO Do not create a feature info by calling add_feature_info() +#! \param WARNINGS_AS_ERRORS Treat compiler warnings as errors +# ################################################################## function(mitk_create_module) set(_macro_params SUBPROJECTS # list of CDash labels VERSION # module version number, e.g. "1.2.0" INCLUDE_DIRS # exported include dirs (used in mitkMacroCreateModuleConf.cmake) INTERNAL_INCLUDE_DIRS # include dirs internal to this module DEPENDS # list of modules this module depends on DEPENDS_INTERNAL # list of modules this module internally depends on PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.) TARGET_DEPENDS # list of CMake targets this module should depend on EXPORT_DEFINE # export macro name for public symbols of this module AUTOLOAD_WITH # a module target name identifying the module which will trigger the # automatic loading of this module ADDITIONAL_LIBS # list of addidtional libraries linked to this module FILES_CMAKE # file name of a CMake file setting source list variables # (defaults to files.cmake) - GENERATED_CPP # not used (?) DEPRECATED_SINCE # marks this modules as deprecated DESCRIPTION # a description for this module ) set(_macro_options - QT_MODULE # the module makes use of Qt4 features and needs moc and ui generated files FORCE_STATIC # force building this module as a static library HEADERS_ONLY # this module is a headers-only library GCC_DEFAULT_VISIBILITY # do not use gcc visibility flags - all symbols will be exported NO_INIT # do not create CppMicroServices initialization code NO_FEATURE_INFO # do not create a feature info by calling add_feature_info() WARNINGS_AS_ERRORS # treat all compiler warnings as errors EXECUTABLE # create an executable; do not use directly, use mitk_create_executable() instead ) MACRO_PARSE_ARGUMENTS(MODULE "${_macro_params}" "${_macro_options}" ${ARGN}) set(MODULE_NAME ${MODULE_DEFAULT_ARGS}) if(NOT MODULE_NAME) if(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME) get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) else() message(SEND_ERROR "The module name must not be empty") endif() endif() set(_module_type module) set(_Module_type Module) if(MODULE_EXECUTABLE) set(_module_type executable) set(_Module_type Executable) endif() if(MITK_MODULE_NAME_REGEX_MATCH) if(NOT ${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_MATCH}) message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" does not match the regular expression \"${MITK_MODULE_NAME_REGEX_MATCH}\".") endif() endif() if(MITK_MODULE_NAME_REGEX_NOT_MATCH) if(${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_NOT_MATCH}) message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" must not match the regular expression \"${MITK_MODULE_NAME_REGEX_NOT_MATCH}\".") endif() endif() if(MITK_MODULE_NAME_PREFIX AND NOT MODULE_NAME MATCHES "^${MITK_MODULE_NAME_PREFIX}.*$") set(MODULE_NAME "${MITK_MODULE_NAME_PREFIX}${MODULE_NAME}") endif() if(NOT MODULE_FILES_CMAKE) set(MODULE_FILES_CMAKE files.cmake) endif() if(NOT IS_ABSOLUTE ${MODULE_FILES_CMAKE}) set(MODULE_FILES_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE}) endif() - if (MODULE_QT_MODULE) - message(WARNING "QT_MODULE keyword is deprecated (in ${_module_type} ${MODULE_NAME}). Please use PACKAGE_DEPENDS Qt4|QtCore and/or PACKAGE_DEPENDS Qt5|Core instead") - if (NOT "${MODULE_PACKAGE_DEPENDS}" MATCHES "^.*Qt4.*$") - list(APPEND MODULE_PACKAGE_DEPENDS Qt4|QtGui) - endif() - endif() - if(MODULE_HEADERS_ONLY) set(MODULE_TARGET ) if(MODULE_AUTOLOAD_WITH) message(SEND_ERROR "A headers only module cannot be auto-loaded") endif() else() set(MODULE_TARGET ${MODULE_NAME}) endif() if(MODULE_DEPRECATED_SINCE) set(MODULE_IS_DEPRECATED 1) else() set(MODULE_IS_DEPRECATED 0) endif() if(NOT MODULE_SUBPROJECTS) if(MITK_DEFAULT_SUBPROJECTS) set(MODULE_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS}) endif() endif() # check if the subprojects exist as targets if(MODULE_SUBPROJECTS) foreach(subproject ${MODULE_SUBPROJECTS}) if(NOT TARGET ${subproject}) message(SEND_ERROR "The subproject ${subproject} does not have a corresponding target") endif() endforeach() endif() # assume worst case set(MODULE_IS_ENABLED 0) # first we check if we have an explicit module build list if(MITK_MODULES_TO_BUILD) list(FIND MITK_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX) if(_MOD_INDEX EQUAL -1) set(MODULE_IS_EXCLUDED 1) endif() endif() if(NOT MODULE_IS_EXCLUDED) # first of all we check for the dependencies _mitk_parse_package_args(${MODULE_PACKAGE_DEPENDS}) mitk_check_module_dependencies(MODULES ${MODULE_DEPENDS} PACKAGES ${PACKAGE_NAMES} MISSING_DEPENDENCIES_VAR _MISSING_DEP PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES) if(_MISSING_DEP) if(MODULE_NO_FEATURE_INFO) message("${_Module_type} ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") endif() set(MODULE_IS_ENABLED 0) else() set(MODULE_IS_ENABLED 1) # now check for every package if it is enabled. This overlaps a bit with # MITK_CHECK_MODULE ... foreach(_package ${PACKAGE_NAMES}) if((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package})) message("${_Module_type} ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.") set(MODULE_IS_ENABLED 0) break() endif() endforeach() if(MODULE_IS_ENABLED) # clear variables defined in files.cmake set(RESOURCE_FILES ) set(CPP_FILES ) set(H_FILES ) set(TXX_FILES ) set(DOX_FILES ) set(UI_FILES ) set(MOC_H_FILES ) set(QRC_FILES ) # clear other variables set(Q${KITNAME}_GENERATED_CPP ) set(Q${KITNAME}_GENERATED_MOC_CPP ) set(Q${KITNAME}_GENERATED_QRC_CPP ) set(Q${KITNAME}_GENERATED_UI_CPP ) # check and set-up auto-loading if(MODULE_AUTOLOAD_WITH) if(NOT TARGET "${MODULE_AUTOLOAD_WITH}") message(SEND_ERROR "The module target \"${MODULE_AUTOLOAD_WITH}\" specified as the auto-loading module for \"${MODULE_NAME}\" does not exist") endif() set(_module_autoload_meta_target "${MODULE_AUTOLOAD_WITH}-autoload") # create a meta-target if it does not already exist if(NOT TARGET ${_module_autoload_meta_target}) add_custom_target(${_module_autoload_meta_target}) endif() endif() # Convert relative include dirs to absolute dirs set(_include_dirs . ${MODULE_INCLUDE_DIRS}) set(MODULE_INCLUDE_DIRS) foreach(dir ${_include_dirs}) get_filename_component(_abs_dir ${dir} ABSOLUTE) list(APPEND MODULE_INCLUDE_DIRS ${_abs_dir}) endforeach() list(APPEND MODULE_INCLUDE_DIRS ${MITK_BINARY_DIR} ${MODULES_CONF_DIRS}) # Convert relative internal include dirs to absolute dirs set(_include_dirs ${MODULE_INTERNAL_INCLUDE_DIRS}) set(MODULE_INTERNAL_INCLUDE_DIRS) foreach(dir ${_include_dirs}) get_filename_component(_abs_dir ${dir} ABSOLUTE) list(APPEND MODULE_INTERNAL_INCLUDE_DIRS ${_abs_dir}) endforeach() # Qt generates headers in the binary tree list(APPEND MODULE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) # Add the module specific include dirs include_directories(${MODULE_INCLUDE_DIRS} ${MODULE_INTERNAL_INCLUDE_DIRS}) if(NOT MODULE_EXECUTABLE) _MITK_CREATE_MODULE_CONF() endif() if(NOT MODULE_EXPORT_DEFINE) set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT) endif(NOT MODULE_EXPORT_DEFINE) if(MITK_GENERATE_MODULE_DOT) message("MODULEDOTNAME ${MODULE_NAME}") foreach(dep ${MODULE_DEPENDS}) message("MODULEDOT \"${MODULE_NAME}\" -> \"${dep}\" ; ") endforeach(dep) endif(MITK_GENERATE_MODULE_DOT) # ok, now create the module itself include(${MODULE_FILES_CMAKE}) set(module_c_flags ) set(module_c_flags_debug ) set(module_c_flags_release ) set(module_cxx_flags ) set(module_cxx_flags_debug ) set(module_cxx_flags_release ) if(MODULE_GCC_DEFAULT_VISIBILITY) set(use_visibility_flags 0) else() # We only support hidden visibility for gcc for now. Clang 3.0 still has troubles with # correctly marking template declarations and explicit template instantiations as exported. # See http://comments.gmane.org/gmane.comp.compilers.clang.scm/50028 # and http://llvm.org/bugs/show_bug.cgi?id=10113 if(CMAKE_COMPILER_IS_GNUCXX) set(use_visibility_flags 1) else() # set(use_visibility_flags 0) endif() endif() if(CMAKE_COMPILER_IS_GNUCXX) # 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(${GCC_VERSION} VERSION_LESS "4.5" OR MINGW) set(use_visibility_flags 0) endif() endif() if(use_visibility_flags) mitkFunctionCheckCAndCXXCompilerFlags("-fvisibility=hidden" module_c_flags module_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-fvisibility-inlines-hidden" module_c_flags module_cxx_flags) endif() configure_file(${MITK_SOURCE_DIR}/CMake/moduleExports.h.in ${CMAKE_BINARY_DIR}/${MODULES_CONF_DIRNAME}/${MODULE_NAME}Exports.h @ONLY) if(MODULE_WARNINGS_AS_ERRORS) if(MSVC_VERSION) mitkFunctionCheckCAndCXXCompilerFlags("/WX" module_c_flags module_cxx_flags) else() mitkFunctionCheckCAndCXXCompilerFlags("-Werror" module_c_flags module_cxx_flags) # The flag "c++0x-static-nonintegral-init" has been renamed in newer Clang # versions to "static-member-init", see # http://clang-developers.42468.n3.nabble.com/Wc-0x-static-nonintegral-init-gone-td3999651.html # # Also, older Clang and seemingly all gcc versions do not warn if unknown # "-no-*" flags are used, so CMake will happily append any -Wno-* flag to the # command line. This may get confusing if unrelated compiler errors happen and # the error output then additionally contains errors about unknown flags (which # is not the case if there were no compile errors). # # So instead of using -Wno-* we use -Wno-error=*, which will be properly rejected by # the compiler and if applicable, prints the specific warning as a real warning and # not as an error (although -Werror was given). mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=c++0x-static-nonintegral-init" module_c_flags module_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=static-member-init" module_c_flags module_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unknown-warning" module_c_flags module_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=gnu" module_c_flags module_cxx_flags) # VNL headers throw a lot of these, not fixable for us at least in ITK 3 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unused-parameter" module_c_flags module_cxx_flags) # Some DICOM header file in ITK mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=cast-align" module_c_flags module_cxx_flags) endif() endif(MODULE_WARNINGS_AS_ERRORS) if(MODULE_FORCE_STATIC) set(_STATIC STATIC) else() set(_STATIC ) endif(MODULE_FORCE_STATIC) # create a meta-target for auto-loaded modules add_custom_target(${MODULE_NAME}-autoload) if(NOT MODULE_HEADERS_ONLY) if(NOT MODULE_NO_INIT OR RESOURCE_FILES) find_package(CppMicroServices QUIET NO_MODULE REQUIRED) endif() if(NOT MODULE_NO_INIT) usFunctionGenerateModuleInit(CPP_FILES) endif() set(binary_res_files ) set(source_res_files ) if(RESOURCE_FILES) set(res_dir Resources) foreach(res_file ${RESOURCE_FILES}) if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}/${res_file}) list(APPEND binary_res_files "${res_file}") else() list(APPEND source_res_files "${res_file}") endif() endforeach() # Add a source level dependencies on resource files usFunctionGetResourceSource(TARGET ${MODULE_TARGET} OUT CPP_FILES) endif() endif() # Qt 4 case if(MITK_USE_Qt4) if(UI_FILES) qt4_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES}) endif() if(MOC_H_FILES) qt4_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) endif() if(QRC_FILES) qt4_add_resources(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES}) endif() endif() # all the same for Qt 5 if(MITK_USE_Qt5) if(UI_FILES) qt5_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES}) endif() if(MOC_H_FILES) qt5_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) endif() if(QRC_FILES) qt5_add_resources(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES}) endif() endif() set(Q${KITNAME}_GENERATED_CPP ${Q${KITNAME}_GENERATED_CPP} ${Q${KITNAME}_GENERATED_UI_CPP} ${Q${KITNAME}_GENERATED_MOC_CPP} ${Q${KITNAME}_GENERATED_QRC_CPP}) ORGANIZE_SOURCES(SOURCE ${CPP_FILES} HEADER ${H_FILES} TXX ${TXX_FILES} DOC ${DOX_FILES} UI ${UI_FILES} QRC ${QRC_FILES} MOC ${Q${KITNAME}_GENERATED_MOC_CPP} GEN_QRC ${Q${KITNAME}_GENERATED_QRC_CPP} GEN_UI ${Q${KITNAME}_GENERATED_UI_CPP}) set(coverage_sources ${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES} ${TOOL_CPPS} ${TOOL_GUI_CPPS}) if(MODULE_SUBPROJECTS) set_property(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() if(NOT MODULE_HEADERS_ONLY) # We have to include the MITK__Config.cmake files here because # some external packages do not provide exported targets with an # absolute path to link to. So we need to add link directories *before* # add_library() or add_executable() is called. So far, this is needed only # for GDCM and ACVD. _link_directories_for_packages(${PACKAGE_NAMES}) # Apply properties to the module target. # We cannot use set_target_properties like below since there is no way to # differentiate C/C++ and Releas/Debug flags using target properties. # See http://www.cmake.org/Bug/view.php?id=6493 #set_target_properties(${MODULE_TARGET} PROPERTIES # COMPILE_FLAGS "${module_compile_flags}") # # Strangely, we need to set the variables below in the parent scope # (outside of the function) to be picked up by the target. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${module_c_flags}" PARENT_SCOPE) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${module_c_flags_debug}" PARENT_SCOPE) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${module_c_flags_release}" PARENT_SCOPE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${module_cxx_flags}" PARENT_SCOPE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${module_cxx_flags_debug}" PARENT_SCOPE) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${module_cxx_flags_release}" PARENT_SCOPE) if(MODULE_EXECUTABLE) add_executable(${MODULE_TARGET} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) set(_us_module_name main) else() add_library(${MODULE_TARGET} ${_STATIC} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) set(_us_module_name ${MODULE_TARGET}) endif() set_property(TARGET ${MODULE_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=${_us_module_name}) set_property(TARGET ${MODULE_TARGET} PROPERTY US_MODULE_NAME ${_us_module_name}) if(MODULE_TARGET_DEPENDS) add_dependencies(${MODULE_TARGET} ${MODULE_TARGET_DEPENDS}) endif() if(MODULE_SUBPROJECTS) set_property(TARGET ${MODULE_TARGET} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) foreach(subproject ${MODULE_SUBPROJECTS}) add_dependencies(${subproject} ${MODULE_TARGET}) endforeach() endif() set(DEPENDS "${MODULE_DEPENDS}") if(NOT MODULE_NO_INIT) # Add a CppMicroServices dependency implicitly, since it is # needed for the generated "module initialization" code. set(DEPENDS "CppMicroServices;${DEPENDS}") endif() if(DEPENDS OR MODULE_PACKAGE_DEPENDS) mitk_use_modules(TARGET ${MODULE_TARGET} MODULES ${DEPENDS} PACKAGES ${MODULE_PACKAGE_DEPENDS} ) endif() if(MINGW) target_link_libraries(${MODULE_TARGET} ssp) # add stack smash protection lib endif() # Add additional library search directories to a global property which # can be evaluated by other CMake macros, e.g. our install scripts. if(MODULE_ADDITIONAL_LIBS) target_link_libraries(${MODULE_TARGET} ${MODULE_ADDITIONAL_LIBS}) get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) foreach(_lib_filepath ${MODULE_ADDITIONAL_LIBS}) get_filename_component(_search_path "${_lib_filepath}" PATH) if(_search_path) list(APPEND _mitk_additional_library_search_paths "${_search_path}") endif() endforeach() if(_mitk_additional_library_search_paths) list(REMOVE_DUPLICATES _mitk_additional_library_search_paths) set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths}) endif() endif() # add the target name to a global property which is used in the top-level # CMakeLists.txt file to export the target set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS ${MODULE_TARGET}) if(MODULE_AUTOLOAD_WITH) # for auto-loaded modules, adapt the output directory add_dependencies(${_module_autoload_meta_target} ${MODULE_TARGET}) if(WIN32) set(_module_output_prop RUNTIME_OUTPUT_DIRECTORY) else() set(_module_output_prop LIBRARY_OUTPUT_DIRECTORY) endif() set(_module_output_dir ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH}) get_target_property(_module_is_imported ${MODULE_AUTOLOAD_WITH} IMPORTED) if(NOT _module_is_imported) # if the auto-loading module is not imported, get its location # and put the auto-load module relative to it. get_target_property(_module_output_dir ${MODULE_AUTOLOAD_WITH} ${_module_output_prop}) set_target_properties(${MODULE_TARGET} PROPERTIES ${_module_output_prop} ${_module_output_dir}/${MODULE_AUTOLOAD_WITH}) else() set_target_properties(${MODULE_TARGET} PROPERTIES ${_module_output_prop} ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH}) endif() set_target_properties(${MODULE_TARGET} PROPERTIES MITK_AUTOLOAD_DIRECTORY ${MODULE_AUTOLOAD_WITH}) # add the auto-load module name as a property set_property(TARGET ${MODULE_AUTOLOAD_WITH} APPEND PROPERTY MITK_AUTOLOAD_TARGETS ${MODULE_TARGET}) endif() if(binary_res_files) usFunctionAddResources(TARGET ${MODULE_TARGET} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${res_dir} FILES ${binary_res_files}) endif() if(source_res_files) usFunctionAddResources(TARGET ${MODULE_TARGET} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${res_dir} FILES ${source_res_files}) endif() if(binary_res_files OR source_res_files) usFunctionEmbedResources(TARGET ${MODULE_TARGET}) endif() endif() endif() endif() endif() if(NOT MODULE_IS_ENABLED AND NOT MODULE_EXECUTABLE) _MITK_CREATE_MODULE_CONF() endif() if(_MISSING_DEP) if(MODULE_DESCRIPTION) set(MODULE_DESCRIPTION "${MODULE_DESCRIPTION} (missing dependencies: ${_MISSING_DEP})") else() set(MODULE_DESCRIPTION "(missing dependencies: ${_MISSING_DEP})") endif() endif() if(NOT MODULE_NO_FEATURE_INFO) add_feature_info(${MODULE_NAME} MODULE_IS_ENABLED "${MODULE_DESCRIPTION}") endif() set(MODULE_NAME ${MODULE_NAME} PARENT_SCOPE) set(MODULE_TARGET ${MODULE_TARGET} PARENT_SCOPE) set(MODULE_IS_ENABLED ${MODULE_IS_ENABLED} PARENT_SCOPE) set(MODULE_SUBPROJECTS ${MODULE_SUBPROJECTS} PARENT_SCOPE) set(ALL_META_DEPENDENCIES ${ALL_META_DEPENDENCIES} PARENT_SCOPE) endfunction() diff --git a/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox b/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox index 5312629307..167bd4f7e0 100644 --- a/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox +++ b/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox @@ -1,215 +1,272 @@ /** \page BuildInstructionsPage Build Instructions \tableofcontents \section BuildInstructions_Introduction Introduction -The MITK build system (which is based on CMake) supports a "superbuild" process, meaning that it will download, configure, and build -all required third-party libraries (except Qt) automatically. These instructions will show you how to use the MITK superbuild. +The MITK build system (which is based on CMake) supports a "superbuild" process, +meaning that it will download, configure, and build all required third-party +libraries (except Qt) automatically. These instructions will show you how to use +the MITK superbuild. -\note This page explains explicitly how to build MITK itself. If you want to create your own project based on MITK, the process -described below is completely automated. Please see \ref HowToNewProject. +\note This page explains explicitly how to build MITK itself. If you want to +create your own project based on MITK, the process described below is completely +automated. Please see \ref HowToNewProject. -For more advanced users, the last sections explain how to inject custom build libraries into the superbuild process. +For more advanced users, the last sections explain how to inject custom build +libraries into the superbuild process. \section BuildInstructions_Prerequisites Prerequisites You need: - -# Git from http://git-scm.com (there are also numerous third-party graphical clients available). We recomment using - Git, but see below for a way how to get the current source code without using it. + -# Git from http://git-scm.com (there are also numerous third-party graphical + clients available). We recomment using Git, but see below for a way how to + get the current source code without using it. -# CMake (version \minimumCMakeVersion or higher) - -# Qt 4.x if you plan to develop Qt-based applications - (version \minimumQt4Version or above is required, Qt 5.x is only supported experimentally for a very limited number of modules) - -# If you are using Mac OS X you need an Xcode installation as this provides the neccessary compilers and SDKs + -# Qt 4.x if you plan to develop Qt-based + applications (version \minimumQt4Version or above is required, Qt 5.x is only + supported experimentally for a very limited number of modules) + -# If you are using Mac OS X you need an Xcode installation as this + provides the neccessary compilers and SDKs \section BuildInstructions_Qt A note about Qt -Nokia provides several binary packages for Qt. You must make sure that the package you download matches -your toolchain. On Linux, getting Qt by installing the packages provided by your Linux package manager is the preferred way. +Nokia provides several binary packages for Qt. You must make sure that the package +you download matches your toolchain. On Linux, getting Qt by installing the +packages provided by your Linux package manager is the preferred way. -On Windows, the Nokia provided binaries are compiled for 32bit architectures. You cannot build your own project for a 64bit machine and +On Windows, the Nokia provided binaries are compiled for 32bit architectures. +You cannot build your own project for a 64bit machine and use the 32bit Qt libraries. You have two options for a 64bit Qt-based application: - -# Download an inofficial 64bit installer, for example here. Note - that we cannot offer support for problems with MITK due to the usage of this kind of installers. + + -# Download an inofficial 64bit installer, for example + here. Note + that we cannot offer support for problems with MITK due to the usage of + this kind of installers. -# Compile Qt yourself. This is shortly described below. To compile Qt on Windows using Visual Studio, follow the steps below: - -# Download the Qt sources and unpack them, e.g. to C:/qt-everywhere-opensource-src-4.7.4 - -# Open a Visual Studio command prompt. Make sure to use the appropriate command prompt for either a 32 bit or 64 bit build. - Note that Visual Studio Express does not come with 64bit compilers out of the box (the Professional version does). - -# Configure Qt by executing the configure.exe command in your Qt source directory. The following configure options will - build a Qt compatible with MITK: + -# Download the Qt sources and unpack them, e.g. to + C:/qt-everywhere-opensource-src-4.7.4 + -# Open a Visual Studio command prompt. Make sure to use the appropriate + command prompt for either a 32 bit or 64 bit build. + Note that Visual Studio Express does not come with 64bit compilers out + of the box (the Professional version does). + -# Configure Qt by executing the configure.exe command in your Qt source + directory. The following configure options will build a Qt compatible + with MITK: \verbatim configure.exe -prefix C:\Qt\4.7.4_vc9_x64 -debug-and-release -qt-sql-sqlite -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-declarative -mp -nomake examples -nomake demos -nomake docs \endverbatim -# Build and install the Qt libraries \verbatim nmake nmake install \endverbatim -After "nmake install" completed successfully, you may delete your Qt source directory. +After "nmake install" completed successfully, you may delete your Qt source +directory. \section BuildInstructions_Get_Source Get a source tree Since MITK is under active development we recommend to use git to check out -the latest stable release from the homepage. If you decide to use the most current nightly -release, make sure to get a stable tree: Check the +the latest stable release from the homepage. If you decide to use the most +current nightly release, make sure to get a stable tree: Check the MITK dashboard before checking out. If the build tree is not clean, you can specify an older revision for the checkout or get a stable tar ball from www.mitk.org. -If you don't want to use Git, you may also download the current source code (or any other older version) -as a tar.gz package by clicking on the -snapshot link. You can then -skip the clone step below. +If you don't want to use Git, you may also download the current source code +(or any other older version) as a tar.gz package by clicking on the +snapshot +link. You can then skip the clone step below. To clone MITK's current git repository do: \code git clone http://git.mitk.org/MITK.git \endcode \section BuildInstructions_Build_With_CMake Build MITK with CMake Create a new directory for the superbuild binary tree, change to it and call CMake: In the shell (assuming you current directory is the same as the one where you issued the git clone command): \code mkdir MITK-superbuild cd MITK-superbuild ccmake ../MITK \endcode -If you use Windows, then you just start the CMake GUI and enter the location of the source and of the binary tree, -choose a suitable generator and configure the project. +If you use Windows, then you just start the CMake GUI and enter the +location of the source and of the binary tree, choose a suitable generator +and configure the project. If you use Mac OS X you will have to tweak the CMake configuration: - First of all you have to check the selected compilers, i.e.: - CMAKE_CXX_COMPILER - CMAKE_C_COMPILER - both should be either apple's clang or apple's gcc compiler - - Next you have to assure hat CMAKE_OSX_SYSROOT points to the correct SDK location: - - This is either /Developer/SDKs/Developer/SDKs/MacOSX10.7.sdk or if you have installed Xcode 4.3+ it is located in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ + - Next you have to assure hat CMAKE_OSX_SYSROOT points to + the correct SDK location: + - This is either /Developer/SDKs/Developer/SDKs/MacOSX10.7.sdk or if you + have installed Xcode 4.3+ it is located in + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ CMake will present you a couple of options, these are the most important ones: - - MITK_USE_ACVD Build MITK code which depends on ACVD (this will download and build ACVD) + - MITK_USE_ACVD Build MITK code which depends on ACVD (this + will download and build ACVD) - MITK_USE_BLUEBERRY Build the BlueBerry application framework - - MITK_USE_Boost Build MITK code which depends on Boost (this will download Boost 1.56) - - MITK_USE_Boost_LIBRARIES If you need binary Boost libraries, specify them here. - - MITK_USE_OpenCV Build MITK code which depends on OpenCV (this will download and build OpenCV 2.4) - - MITK_USE_Python Enables Python wrapping in MITK. This will also configure ITK, VTK, and OpenCV (if enabled) to build Python wrappers. + - MITK_USE_Boost Build MITK code which depends on Boost (this + will download Boost 1.56) + - MITK_USE_Boost_LIBRARIES If you need binary Boost libraries, + specify them here. + - MITK_USE_OpenCV Build MITK code which depends on OpenCV (this + will download and build OpenCV 2.4) + - MITK_USE_Python Enables Python wrapping in MITK. This will also + configure ITK, VTK, and OpenCV (if enabled) to build Python wrappers. - MITK_USE_QT Build MITK code which depends on Qt - - MITK_USE_SOFA Build MITK code which depends on SOFA (this will download and build SOFA) - - QT_QMAKE_EXECUTABLE The path to the qmake executable of your Qt installation - -You may also choose to build with either Qt4 or Qt5. When building with Qt5, the BlueBerry -application framework and hence the MITK Workbench application will not be available. Further, many -Qt-depdendent MITK modules have not been migrated to Qt5 yet. In case of Qt4 you may point CMake -to a certain Qt4 installation directory by setting the QT_QMAKE_EXECUTABLE variable. + - MITK_USE_SOFA Build MITK code which depends on SOFA (this will + download and build SOFA) + - QT_QMAKE_EXECUTABLE The path to the qmake executable of your Qt + installation + +You may also choose to build with either Qt4 or Qt5. When building with Qt5, +the BlueBerry application framework and hence the MITK Workbench application +will not be available. Further, many Qt-depdendent MITK modules have not been +migrated to Qt5 yet. In case of Qt4 you may point CMake to a certain Qt4 +installation directory by setting the QT_QMAKE_EXECUTABLE variable. When building against Qt5, the following variables are important: - DESIRED_QT_VERSION Set this to "5" for building with Qt5. - - CMAKE_PREFIX_PATH If Qt5 is not found automatically, set this variable - to the base directory of your Qt5 installation. + - CMAKE_PREFIX_PATH If Qt5 is not found automatically, set + this variable to the base directory of your Qt5 installation. -If you are satisfied with the configuration of your MITK superbuild, generate the project files with -CMake by pressing "Generate". +If you are satisfied with the configuration of your MITK superbuild, generate +the project files with CMake by pressing "Generate". -Linux and Mac OS X users usually just enter "make" (optionally supplying the number threads to be used for -a parallel build): +Linux and Mac OS X users usually just enter "make" (optionally +supplying the number threads to be used for a parallel build): \code make -j4 \endcode -\note On Mac OS X: If you follow these steps CMake will produce Makefiles and therefore you cannot use Xcode but you have to use e.g. the QtCreator for programming. At the moment developing MITK with Xcode is not supported and using Xcode the superbuild doesn't complete without errors. +\note On Mac OS X: If you follow these steps CMake will produce Makefiles +and therefore you cannot use Xcode but you have to use e.g. the QtCreator for +programming. At the moment developing MITK with Xcode is not supported and using +Xcode the superbuild doesn't complete without errors. -Windows users using Visual Studio can open the generated MITK-superbuild.sln solution file -in the MITK-superbuild directory and start the build by building the BUILD_ALL project. +Windows users using Visual Studio can open the generated +MITK-superbuild.sln solution file in the MITK-superbuild +directory and start the build by building the BUILD_ALL project. \section BuildInstructions_Customize Customize your MITK superbuild -The MITK superbuild configured MITK with all needed external libraries. The build directories of these libraries, -and of MITK itself are located inside the MITK-superbuild directory. For example, the directory layout may +The MITK superbuild configured MITK with all needed external libraries. The +build directories of these libraries, and of MITK itself are located inside +the MITK-superbuild directory. For example, the directory layout may look like: \code MITK-superbuild |- ITK-build |- VTK-build |- MITK-build \endcode -To change the configuration of the MITK build, choose the MITK-build directory as the binary directory in the -CMake GUI. After generating the project files, build the MITK project by either issuing "make" in the MITK-build -directory (Linux), or by opening MITK-build/MITK.sln and building the project with Visual Studio. +To change the configuration of the MITK build, choose the MITK-build directory +as the binary directory in the CMake GUI. After generating the project files, +build the MITK project by either issuing "make" in the MITK-build directory +(Linux), or by opening MITK-build/MITK.sln and building the project with +Visual Studio. -You may also change the configuration of any project configured via the superbuild process. Make sure to also build -the changed project and also the projects which depend on it. +You may also change the configuration of any project configured via the +superbuild process. Make sure to also build the changed project and also the +projects which depend on it. \section BuildInstructions_Running Running Applications -On Linux, just execute the application you want to run. MITK executables are located in -MITK-superbuild/MITK-build/bin +On Linux, just execute the application you want to run. MITK executables are +located in MITK-superbuild/MITK-build/bin -On Windows, the PATH environment variable must contain the directories containging third-party libraries. -The MITK build system generated Windows Batch files in the MITK-build directory which set up a correct -environment and opens the appropriate Visual Studio solution file. Use (and maybe modify/enhance) these Batch files -to be able to start and debug MITK applications from inside Visual Studio. +On Windows, the PATH environment variable must contain the directories +containging third-party libraries. The MITK build system generated Windows Batch +files in the MITK-build directory which set up a correct environment +and opens the appropriate Visual Studio solution file. Use (and maybe +modify/enhance) these Batch files to be able to start and debug MITK applications +from inside Visual Studio. \section BuildInstructions_Documentation Documentation -If you have the Doxygen documentation tool installed, you get a new project -(Visual Studio) or "make" target named "doc". You can build this to generate the HTML documentation of MITK in -the Documentation/Doxygen directory of your MITK-build binary tree or in the MITK_DOXYGEN_OUTPUT_DIR CMake variable -(if specified). +If you have the Doxygen documentation tool +installed, you get a new project (Visual Studio) or "make" target named "doc". +You can build this to generate the HTML documentation of MITK in the +Documentation/Doxygen directory of your MITK-build binary tree or in the +MITK_DOXYGEN_OUTPUT_DIR CMake variable (if specified). \section BuildInstructions_Extending Extend MITK on your own (using the application framework BlueBerry) Please see \ref NewPluginPage \section BuildInstructions_As_Toolkit Use MITK in your own project (as a toolkit) -To use MITK in your external project, add the CMake command find_package(MITK REQUIRED) -to your CMakeLists.txt and make use of the CMake macros MITK_CHECK_MODULE(result_var ) - and MITK_USE_MODULE() provided by MITK. +To use MITK in your external project, add the CMake command +find_package(MITK REQUIRED) to your CMakeLists.txt and make use of +the CMake macros mitk_create_module() and +mitk_create_executable() provided by MITK. -Here is an example CMakeLists.txt (from the Examples/QtAppExample/ directory) which allows you -to create a Qt based application using MITK to display an image. +Here is an example CMakeLists.txt (from the Examples/QtAppExample/ directory) +which allows you to create a Qt based application using MITK to display an image. \include QtAppExample/CMakeLists.txt \section BuildInstructions_Advanced_Customization Superbuild Customization -You can inject pre-build third-party libraries into the MITK superbuild by setting certain CMake variables before -the first configure step. MITK will then use these third-party libraries instead of downloading and building them -itself. Note you must take care to configure those libraries with all options MITK requires. - -The variables listed below are provided for injecting third-party libraries. Their occurrence in the CMake GUI or -in ccmake may depend on specific MITK_USE_* options set to ON. You may also use the variable names below without the -EXTERNAL_ prefix, for example when providing their values on a command line call to CMake. - - - EXTERNAL_BOOST_ROOT Set this variable to your custom Boost installation - - EXTERNAL_CTK_DIR Set this variable to your CTK binary tree (the directory containing the CTKConfig.cmake file) - - EXTERNAL_CableSwig_DIR Set this variable to your CableSwig binary tree for Python wrapping (the directory containing the CableSwigConfig.cmake file) - - EXTERNAL_DCMTK_DIR Set this variable to your DCMTK binary tree (the directory containing the DCMTKConfig.cmake file) - - EXTERNAL_GDCM_DIR Set this variable to your GDCM binary tree (the directory containing the GDCMConfig.cmake file) - - EXTERNAL_ITK_DIR Set this variable to your ITK binary tree (the directory containing the ITKConfig.cmake file) - - EXTERNAL_OpenCV_DIR Set this variable to your OpenCV binary tree (the directory containing the OpenCVConfig.cmake file) - - EXTERNAL_SOFA_DIR Set this variable to your SOFA binary tree (the directory containing the SOFAConfig.cmake file) - - EXTERNAL_VTK_DIR Set this variable to your VTK binary tree (the directory containing the VTKConfig.cmake file) - -To set CMake options before the first configure step is invoked, supply them on the command line, i.e. +You can inject pre-build third-party libraries into the MITK superbuild by +setting certain CMake variables before the first configure step. MITK will +then use these third-party libraries instead of downloading and building them +itself. Note you must take care to configure those libraries with all options +MITK requires. + +The variables listed below are provided for injecting third-party libraries. +Their occurrence in the CMake GUI or in ccmake may depend on specific +MITK_USE_* options set to ON. You may also use the variable names below without +the EXTERNAL_ prefix, for example when providing their values on a +command line call to CMake. + + - EXTERNAL_BOOST_ROOT Set this variable to your custom Boost + installation + - EXTERNAL_CTK_DIR Set this variable to your CTK binary tree + (the directory containing the CTKConfig.cmake file) + - EXTERNAL_CableSwig_DIR Set this variable to your CableSwig + binary tree for Python wrapping (the directory containing the + CableSwigConfig.cmake file) + - EXTERNAL_DCMTK_DIR Set this variable to your DCMTK binary + tree (the directory containing the DCMTKConfig.cmake file) + - EXTERNAL_GDCM_DIR Set this variable to your GDCM binary + tree (the directory containing the GDCMConfig.cmake file) + - EXTERNAL_ITK_DIR Set this variable to your ITK binary tree + (the directory containing the ITKConfig.cmake file) + - EXTERNAL_OpenCV_DIR Set this variable to your OpenCV binary + tree (the directory containing the OpenCVConfig.cmake file) + - EXTERNAL_SOFA_DIR Set this variable to your SOFA binary tree + (the directory containing the SOFAConfig.cmake file) + - EXTERNAL_VTK_DIR Set this variable to your VTK binary tree + (the directory containing the VTKConfig.cmake file) + +To set CMake options before the first configure step is invoked, supply them +on the command line, i.e. \code ccmake -DITK_DIR:PATH=/opt/ITK-release ../MITK \endcode -See the following link for more information about how to configure third-party libraries: +See the following link for more information about how to configure third-party +libraries: \subpage BuildToolkits "How to build ITK, VTK and QT" */ diff --git a/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/HowToNewProject.dox b/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/HowToNewProject.dox index 9185a3dd8f..108183b08b 100644 --- a/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/HowToNewProject.dox +++ b/Documentation/Doxygen/DeveloperManual/Starting/SettingUpMITK/HowToNewProject.dox @@ -1,163 +1,258 @@ /** \page HowToNewProject Creating a new MITK project \tableofcontents -This page is intended to give a comprehensive guide to setting up your own MITK based project. It will use the application framework provided by MITK and is probably the preferred way for most users. +This page is intended to give a comprehensive guide to setting up your own MITK based +project. It will use the application framework provided by MITK and is probably the +preferred way for most users. -The first part of this document is a tutorial aimed at newcomers to MITK and possibly %CMake and tries to give as much help as possible on setting up your own project. If you are looking for more technical information about customizing MITK, the structure of the superbuild or packaging you might want to read the \ref HowToNewProjectAdvancedInformation. +The first part of this document is a tutorial aimed at newcomers to MITK and possibly +%CMake and tries to give as much help as possible on setting up your own project. If +you are looking for more technical information about customizing MITK, the structure +of the superbuild or packaging you might want to read the +\ref HowToNewProjectAdvancedInformation. -If you have set up your MITK project already and want to start developing you could take a look at \ref TutorialPage. +If you have set up your MITK project already and want to start developing you could +take a look at \ref TutorialPage. \section HowToNewProjectGettingStarted Getting Started To bootstrap your project MITK offers two convenient options:
    -
  1. Use the MITK Plugin Generator, a command line tool used to generate a customized MITK project and/or MITK plug-ins (available for download here). -
  2. Use the MITK project template as an example project. +
  3. Use the MITK Plugin Generator, a command line tool used to generate a customized + MITK project and/or MITK plug-ins (available for download + here). +
  4. Use the MITK project template + as an example project.
-Both options will provide you with a project which contains a "superbuild" mechanism to automatically download, configure, and build MITK as a dependency of your own project. +Both options will provide you with a project which contains a "superbuild" mechanism +to automatically download, configure, and build MITK as a dependency of your own project. -The MITK Plugin Generator generates code using the supplied command line arguments, whereas the MITK project template needs immediate modifications to customize it to your naming schemes. However, the project template will potentially contain more code demonstrating features of MITK. +The MITK Plugin Generator generates code using the supplied command line arguments, +whereas the MITK project template needs immediate modifications to customize it to +your naming schemes. However, the project template will potentially contain more +code demonstrating features of MITK. \note Using the MITK Plugin Generator is recommended for beginners. \section HowToNewProjectPrerequisites Prerequisites -What ever option you choose, a MITK-based project needs essentially the same prerequisites as MITK itself. Please see \ref BuildInstructions_Prerequisites for details. -\note If you use one of the two options above you will \b not \b need to build MITK yourself. This will be done automatically. +What ever option you choose, a MITK-based project needs essentially the same +prerequisites as MITK itself. Please see \ref BuildInstructions_Prerequisites for +details. +\note If you use one of the two options above you will \b not \b need to build MITK +yourself. This will be done automatically. \section HowToNewProjectCreatingSourceDir Preparing your source directory -In order to start developing with MITK, you first have to set up the source directory for your project. +In order to start developing with MITK, you first have to set up the source directory +for your project. \subsection HowToNewProjectSourceUsingGenerator Using the MITK Plugin Generator -The usage of the Plugin Generator for creating a new project is described in \ref NewPluginWithProject, please have a look there. +The usage of the Plugin Generator for creating a new project is described in +\ref NewPluginWithProject, please have a look there. \subsection HowToNewProjectSourceUsingTemplate Using the MITK Project Template -Download the project as a tarball or zipball and extract it to your desired source directory. +Download the project as a tarball or zipball and extract it to your desired source +directory. -\note This is a \b template \b. You must modify it such that it fits the needs of your particular project. Especially you should do a global search and replace for the string "awesome" to rename the template application and plug-in. You may want to rename some files too. +\note This is a \b template \b. You must modify it such that it fits the needs of +your particular project. Especially you should do a global search and replace for +the string "awesome" to rename the template application and plug-in. You may want +to rename some files too. \section HowToNewProjectGeneratingCMake Generating your binary with CMake -After you have set up your source directory you can proceed to generate your binary directory using %CMake. Depending on your operating system and preferences you might want to use "cmake-gui" or "ccmake" (shell). This document assumes you are using cmake-gui. +After you have set up your source directory you can proceed to generate your binary +directory using %CMake. Depending on your operating system and preferences you might +want to use "cmake-gui" or "ccmake" (shell). This document assumes you are using +cmake-gui.
    -
  1. Start "cmake-gui" and enter your source (e.g. "D:\AwesomeProject") and binary directory (e.g. "D:\AwesomeProject-superbuild"). -
  2. Upon first pressing "Configure" you will be prompted to select your generator. This determines what project files will be generated by %CMake. Set this to the development tool you are intending to use (e.g. "Visual Studio 2010 64Bit" or "linux makefiles". -
  3. Press "Configure" until no new variables appear and then "Generate". Now all project files have been generated into your binary directory. +
  4. Start "cmake-gui" and enter your source (e.g. "D:\AwesomeProject") and binary + directory (e.g. "D:\AwesomeProject-superbuild"). +
  5. Upon first pressing "Configure" you will be prompted to select your generator. + This determines what project files will be generated by %CMake. Set this to the + development tool you are intending to use (e.g. "Visual Studio 2010 64Bit" or + "linux makefiles". +
  6. Press "Configure" until no new variables appear and then "Generate". Now all + project files have been generated into your binary directory.
  7. Double-check that the right Qt version is used.
-Now you are ready to compile your code. Depending on your choice of tool this will be done differently, we cover two possibilities here. +Now you are ready to compile your code. Depending on your choice of tool this will +be done differently, we cover two possibilities here. \subsection HowToNewProjectCompilingLinuxMakefiles Compiling using linux makefiles
  1. In the shell, switch to your binary directory.
  2. type "make" and hit enter
\subsection HowToNewProjectCompilingVisualStudio Compiling using visual studio -We assume your application is called "AwesomeApp" and your project "AwesomeProject" and your binary directory is "D:\AwesomeProject-superbuild\". Replace names and paths accordingly. +We assume your application is called "AwesomeApp" and your project "AwesomeProject" +and your binary directory is "D:\AwesomeProject-superbuild\". Replace names and +paths accordingly.
    -
  1. Close %CMake and open "D:\AwesomeProject-superbuild\AwesomeProject-superbuild.sln" . Your Visual Studio should appear and by pressing F7 you start the compilation. This will clone the MITK source code, build it, and then start building your own project. -
  2. After the superbuild compilation has finished, close the solution file and start the batch file "D:\AwesomeProject-superbuild\AwesomeProject-build\StartVS_debug.bat" (or _release.bat if you built in Release mode) which opens the "D:\AwesomeProject-superbuild\AweseomeProject-build\AwesomeProject.sln" solution. -
  3. Set the "AwesomeApp" project as start-up project (right click > "Set as StartUp Project") and press "F5" to start your MITK AwesomeApp. +
  4. Close %CMake and open "D:\AwesomeProject-superbuild\AwesomeProject-superbuild.sln". + Your Visual Studio should appear and by pressing F7 you start the compilation. + This will clone the MITK source code, build it, and then start building your own + project. +
  5. After the superbuild compilation has finished, close the solution file and start + the batch file "D:\AwesomeProject-superbuild\AwesomeProject-build\StartVS_debug.bat" + (or _release.bat if you built in Release mode) which opens the + "D:\AwesomeProject-superbuild\AweseomeProject-build\AwesomeProject.sln" solution. +
  6. Set the "AwesomeApp" project as start-up project (right click > "Set as StartUp + Project") and press "F5" to start your MITK AwesomeApp.
-\note Just opening AwesomeProject.sln from your explorer by double-cliking won`t allow you to start or debug your application because the required environment variables would be missing. Use the supplied batch files or set your PATH variable accordingly. +\note Just opening AwesomeProject.sln from your explorer by double-cliking won`t +allow you to start or debug your application because the required environment +variables would be missing. Use the supplied batch files or set your PATH variable +accordingly. -\section HowToNewProjectAddingMITKFunctionality I want to use some MITK plugin but it is not available +\section HowToNewProjectAddingMITKFunctionality I want to use some MITK plugin but +it is not available -Due to the sheer number of MITK plugins not every plugin is activated by default. To activate a specific plugin (again replace paths as needed): +Due to the sheer number of MITK plugins not every plugin is activated by default. +To activate a specific plugin (again replace paths as needed):
    -
  1. Start "cmake-gui" and set the binary directory to "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\", the source will adjust automatically and you will see new settings appear. -
  2. Navigate to the plugin you want to use (e.g. "MITK_BUILD_org.mitk.gui.qt.segmentation") and tick the checkbox behind it +
  3. Start "cmake-gui" and set the binary directory to + "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\", the source will + adjust automatically and you will see new settings appear. +
  4. Navigate to the plugin you want to use (e.g. "MITK_BUILD_org.mitk.gui.qt.segmentation") + and tick the checkbox behind it
  5. Press "Configure" until no new variables appear and then "Generate". -
  6. Build MITK using your development tool (as in \ref HowToNewProjectCompilingLinuxMakefiles or \ref HowToNewProjectCompilingVisualStudio only in the "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\" directory ) -
  7. Start "cmake-gui" and set the binary directory to "D:\AwesomeProject-superbuild\AwesomeProject-build\", the source will adjust automatically and you will see new settings appear. +
  8. Build MITK using your development tool (as in + \ref HowToNewProjectCompilingLinuxMakefiles or \ref HowToNewProjectCompilingVisualStudio + only in the "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\" directory ) +
  9. Start "cmake-gui" and set the binary directory to + "D:\AwesomeProject-superbuild\AwesomeProject-build\", the source will adjust + automatically and you will see new settings appear.
  10. Press "Configure" until no new variables appear and then "Generate".
  11. Build your project
  12. Start your application
-\note If you want to use an application provided by MITK (e.g. MITK Workbench) you have to tick the appropriate checkbox as well (in this case MITK_BUILD_APP_mitkWorkbench ) and build MITK. Do note, that this application will be located in the bin directory of the "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\" folder. +\note If you want to use an application provided by MITK (e.g. MITK Workbench) you +have to tick the appropriate checkbox as well (in this case MITK_BUILD_APP_mitkWorkbench) +and build MITK. Do note, that this application will be located in the bin directory +of the "D:\AwesomeProject-superbuild\MITK-superbuild\MITK-build\" folder. \section HowToNewProjectAdvancedInformation Information for advanced users \subsection HowToNewProjectCustomizingMITK Customizing MITK -The %CMake scripts from the Plugin Generator of the project template provide some handy options which allow you to customize the MITK build used in your project. You can either inject an already build MITK to be used by your project or configure some MITK options directly in your project's superbuild configuration if MITK is going to be build inside your project. +The %CMake scripts from the Plugin Generator of the project template provide some +handy options which allow you to customize the MITK build used in your project. +You can either inject an already build MITK to be used by your project or configure +some MITK options directly in your project's superbuild configuration if MITK is +going to be build inside your project. \subsubsection HowToNewProjectCustomizingMITKInjectMITK Inject a MITK build -By setting the \b EXTERNAL_MITK_DIR \b variable in your project's superbuild %CMake configuration to a MITK build directory (containing the MITKConfig.cmake) you can skip the MITK build process. +By setting the \b EXTERNAL_MITK_DIR \b variable in your project's superbuild +%CMake configuration to a MITK build directory (containing the MITKConfig.cmake) +you can skip the MITK build process. -If MITK is the only external project in your project, you might want to disable the superbuild of your project completely (set _USE_SUPERBUILD to OFF or edit your CMakeLists.txt file to set it to OFF by default) and set the \b MITK_DIR \b %CMake variable to your MITK build directory. +If MITK is the only external project in your project, you might want to disable +the superbuild of your project completely (set _USE_SUPERBUILD +to OFF or edit your CMakeLists.txt file to set it to OFF by default) and set +the \b MITK_DIR \b %CMake variable to your MITK build directory. \subsubsection HowToNewProjectCustomizingMITKConfigure Configure the MITK superbuild -If MITK is being build inside your project's superbuild process, you can enable the use of certain third-party libraries inside of MITK. The following variables control the MITK configuration: +If MITK is being build inside your project's superbuild process, you can enable +the use of certain third-party libraries inside of MITK. The following variables +control the MITK configuration:
  • \b MITK_USE_BLUEBERRY Enable the use of the BlueBerry application framework
  • \b MITK_USE_Boost Download and use Boost in MITK
  • \b MITK_USE_CTK Download, compile, and use CTK in MITK
  • \b MITK_USE_DCMTK Download, compile, and use DCMTK in MITK
  • \b MITK_USE_OpenCV Download, compile, and use OpenCV in MITK -
  • \b MITK_USE_Python Download and compile 1CableSwig and enable Python wrapping in ITK, VTK, OpenCV, and MITK +
  • \b MITK_USE_Python Download and compile 1CableSwig and enable Python + wrapping in ITK, VTK, OpenCV, and MITK
  • \b MITK_USE_QT Use the Qt framework in MITK
-You can also inject already build third-party libraries from inside your project's superbuild in the MITK superbuild by using any of the following %CMake variables: +You can also inject already build third-party libraries from inside your project's +superbuild in the MITK superbuild by using any of the following %CMake variables:
  • \b MITK_CTK_DIR Reuse a CTK build directory in MITK.
  • \b MITK_CableSwig_DIR Reuse a 1CableSwig build directory in MITK.
  • \b MITK_DCMTK_DIR Reuse a DCMKT build directory in MITK.
  • \b MITK_GDCM_DIR Reuse a GDCM build directory in MITK.
  • \b MITK_ITK_DIR Reuse a ITK build directory in MITK.
  • \b MITK_OpenCV_DIR Reuse a OpenCV build directory in MITK.
  • \b MITK_VTK_DIR Reuse a VTK build directory in MITK.
-If the corresponding \b MITK_USE_ \b option is set to on, the MITK superbuild will use the provided build directory instead of building the project itself. +If the corresponding \b MITK_USE_ \b option is set to on, the MITK +superbuild will use the provided build directory instead of building the +project itself. -You can also control the source code location for MITK in your project's superbuild configuration by using the following %CMake variables: +You can also control the source code location for MITK in your project's +superbuild configuration by using the following %CMake variables:
    -
  • \b MITK_SOURCE_DIR The path to the MITK source directory. If the value for this variable is non-empty, the variables below are ignored. +
  • \b MITK_SOURCE_DIR The path to the MITK source directory. If the value + for this variable is non-empty, the variables below are ignored.
  • \b MITK_GIT_REPOSITORY The Git repository containing the MITK source code. -
  • \b MITK_GIT_TAG The hash id, tag or branch name used for a checkout from MITK_GIT_REPOSITORY. +
  • \b MITK_GIT_TAG The hash id, tag or branch name used for a checkout + from MITK_GIT_REPOSITORY.
\subsubsection HowToNewProjectProjectStructure Project Structure -If you are using the superbuild feature of the generated project (the default), you might want to familiarise yourself with the layout of your build tree. The top-level build directory which you specified in %CMake when configuring your project will contain all the required dependencies. - -Suppose we call our project MyProject and the build directory is "C:\MyProject-superbuild". Then the layout looks something like this: - -MyProjectLayout.png The top-level directory contains the source code and the build directories from the dependencies of your project. In the current case, the only dependency of MyProject is MITK, which in turn has downloaded and built its own dependencies (CTK, DCMTK, ITK, etc.). The "real" build tree for your project is located in MyProject-superbuild/MyProject-build, so point the %CMake-GUI to this build directory if you want to change the set of enabled plug-ins for example. - -Further, you should open the MyProject.sln solution file (for Visual Studio) or execute "make" in the MyProject-superbuild/MyProject-build/ directory. Only for the very first time or if you want to update and newly build the project's dependencies should you use the project files in the MyProject-superbuild directory directly. - -The same applies for the MyProject-superbuild/MITK-superbuild directory. This directory contains the MITK superbuild, nested inside your project's superbuild. If you want to change %CMake options for MITK, use the MyProject-superbuild/MITK-superbuild/MITK-build build directory. +If you are using the superbuild feature of the generated project (the default), +you might want to familiarise yourself with the layout of your build tree. +The top-level build directory which you specified in %CMake when configuring +your project will contain all the required dependencies. + +Suppose we call our project MyProject and the build directory is +"C:\MyProject-superbuild". Then the layout looks something like this: + +MyProjectLayout.png The top-level directory contains the source code and the +build directories from the dependencies of your project. In the current case, +the only dependency of MyProject is MITK, which in turn has downloaded and built +its own dependencies (CTK, DCMTK, ITK, etc.). The "real" build tree for your +project is located in MyProject-superbuild/MyProject-build, so point the +%CMake-GUI to this build directory if you want to change the set of enabled +plug-ins for example. + +Further, you should open the MyProject.sln solution file (for Visual Studio) +or execute "make" in the MyProject-superbuild/MyProject-build/ directory. +Only for the very first time or if you want to update and newly build the +project's dependencies should you use the project files in the +MyProject-superbuild directory directly. + +The same applies for the MyProject-superbuild/MITK-superbuild directory. This +directory contains the MITK superbuild, nested inside your project's superbuild. +If you want to change %CMake options for MITK, use the +MyProject-superbuild/MITK-superbuild/MITK-build build directory. \imageMacro{HowToNewProject-MyProjectLayout.png,"Layout of MyProject",4.02} \subsubsection HowToNewProjectPackaging Packaging -The project template and the generated projects by the Plugin Generator come with full packaging support. You can create deployable packages of your project for all supported operating systems my building the PACKAGE target. On Linux, this will create a tarball, on MacOS a .dmg file, and on Windows a zipball and an NSIS installer (if NSIS is installed and found). +The project template and the generated projects by the Plugin Generator come +with full packaging support. You can create deployable packages of your project +for all supported operating systems my building the PACKAGE target. On Linux, +this will create a tarball, on MacOS a .dmg file, and on Windows a zipball and +an NSIS installer (if NSIS is installed and found). You can read more about deployment \ref DeploymentPage "here". -*/ \ No newline at end of file +*/