diff --git a/Applications/PluginGenerator/MITKCopyright.txt b/Applications/PluginGenerator/MITKCopyright.txt new file mode 100644 index 0000000000..70a3ffbe02 --- /dev/null +++ b/Applications/PluginGenerator/MITKCopyright.txt @@ -0,0 +1,35 @@ +/*========================================================================= + +Copyright (c) 2003-2010 German Cancer Research Center, Division of Medical +and Biological Informatics +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the German Cancer Research Center, nor the names of any + contributors, may be used to endorse or promote products derived from this + software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ diff --git a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt new file mode 100644 index 0000000000..5fd74fb0e3 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt @@ -0,0 +1,86 @@ +#----------------------------------------------------------------------------- +# Prerequesites +#----------------------------------------------------------------------------- + +find_package(Qt REQUIRED) + +#----------------------------------------------------------------------------- +# Include and linker directories +#----------------------------------------------------------------------------- + +include(${QT_USE_FILE}) + +include_directories( + ${org_blueberry_osgi_INCLUDE_DIRS} + ${Poco_INCLUDE_DIRS} + ${mbilog_INCLUDE_DIRS} + ${ALL_INCLUDE_DIRECTORIES} +) + +#----------------------------------------------------------------------------- +# Executable +#----------------------------------------------------------------------------- + +if(${MY_PROJECT_NAME}_SHOW_CONSOLE_WINDOW) + add_executable(${MY_APP_NAME} MACOSX_BUNDLE ${MY_APP_NAME}.cpp) +else() + add_executable(${MY_APP_NAME} MACOSX_BUNDLE WIN32 ${MY_APP_NAME}.cpp) +endif() + +target_link_libraries(${MY_APP_NAME} org_blueberry_osgi ${ALL_LIBRARIES}) +if(WIN32) + target_link_libraries(${MY_APP_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTMAIN_LIBRARY}) +endif() + +# Make sure all enabled plug-ins are up to date when building the application +ctkFunctionExtractPluginTargets("${PROJECT_PLUGINS}" ON PROJECT_ENABLED_PLUGINS) +if(PROJECT_ENABLED_PLUGINS) + add_dependencies(${MY_APP_NAME} ${PROJECT_ENABLED_PLUGINS}) +endif() + +#----------------------------------------------------------------------------- +# Additional files needed for the executable +#----------------------------------------------------------------------------- + +# Create a provisioning file, listing all enabled plug-ins +set(PROJECT_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MY_APP_NAME}.provisioning") +FunctionCreateProvisioningFile( + FILE ${PROJECT_PROVISIONING_FILE} + INCLUDE "${MITK_PLUGIN_PROVISIONING_FILE}" + PLUGIN_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" + PLUGINS ${PROJECT_PLUGINS} + ) + +# Create a .ini file for initial parameters +configure_file(${MY_APP_NAME}.ini + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MY_APP_NAME}.ini) + +# Create batch files for Windows platforms +if(WIN32) + foreach(BUILD_TYPE debug release) + mitkFunctionCreateWindowsBatchScript(start${MY_APP_NAME}.bat.in + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${MY_APP_NAME}_${BUILD_TYPE}.bat + ${BUILD_TYPE}) + endforeach() +endif() + +#----------------------------------------------------------------------------- +# Install support +#----------------------------------------------------------------------------- + +# This installs all enabled CTK plug-ins +FunctionInstallThirdPartyCTKPlugins(${CTK_PLUGIN_LIBRARIES}) + +# Install the executable and its provisioning file +MITK_INSTALL_TARGETS(EXECUTABLES ${MY_APP_NAME} GLOB_PLUGINS) +mitkFunctionInstallProvisioningFiles(${MITK_PROVISIONING_FILES} + ${PROJECT_PROVISIONING_FILE}) + +# On Linux, create a shell script to start a relocatable application +if(UNIX AND NOT APPLE) + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${MY_APP_NAME}.sh) +endif() + +# Tell cpack the executables that you want in the start menu as links +set(MITK_CPACK_PACKAGE_EXECUTABLES "${MITK_CPACK_PACKAGE_EXECUTABLES}" "${MY_APP_NAME};MITK - ${MY_APP_NAME} Application" CACHE INTERNAL "Collecting windows shortcuts to executables") + diff --git a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.cpp b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.cpp new file mode 100644 index 0000000000..58366de985 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.cpp @@ -0,0 +1,28 @@ +$(license) + +#include +#include + +#include + +int main(int argc, char** argv) +{ + // Create a QApplication instance first + QApplication myApp(argc, argv); + myApp.setApplicationName("$(project-app-name)"); + myApp.setOrganizationName("$(vendor)"); + + // These paths replace the .ini file and are tailored for installation + // packages created with CPack. If a .ini file is presented, it will + // overwrite the settings in MapConfiguration + Poco::Path basePath(argv[0]); + basePath.setFileName(""); + + Poco::Path provFile(basePath); + provFile.setFileName("$(project-app-name).provisioning"); + + Poco::Util::MapConfiguration* sbConfig(new Poco::Util::MapConfiguration()); + sbConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); + sbConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.extapplication"); + return berry::Starter::Run(argc, argv, sbConfig); +} diff --git a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.ini b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.ini new file mode 100644 index 0000000000..b0adfb0dbc --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/TemplateApp.ini @@ -0,0 +1,2 @@ +BlueBerry.home=@BLUEBERRY_BINARY_DIR@ +BlueBerry.provisioning=@PROJECT_PROVISIONING_FILE@ diff --git a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/startTemplateApp.bat.in b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/startTemplateApp.bat.in new file mode 100644 index 0000000000..1f31392d44 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/startTemplateApp.bat.in @@ -0,0 +1,2 @@ +PATH=@MITK_RUNTIME_PATH@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@\@VS_BUILD_TYPE@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@\plugins\@VS_BUILD_TYPE@;%PATH% +@VS_BUILD_TYPE@\@MY_APP_NAME@.exe diff --git a/Applications/PluginGenerator/ProjectTemplate/CMake/CPackSetup.cmake b/Applications/PluginGenerator/ProjectTemplate/CMake/CPackSetup.cmake new file mode 100644 index 0000000000..bfe678051b --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMake/CPackSetup.cmake @@ -0,0 +1,24 @@ +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is an awesome app") +set(CPACK_PACKAGE_VENDOR "$(vendor)") +set(CPACK_CREATE_DESKTOP_LINKS "${MY_APP_NAME}") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/Copyright.txt") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/Copyright.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") + +# append revision number if available +if(${PROJECT_NAME}_REVISION_ID) + if(${PROJECT_NAME}_WC_TYPE STREQUAL "git") + set(git_hash ${${PROJECT_NAME}_REVISION_ID}) + string(LENGTH "${git_hash}" hash_length) + if(hash_length GREATER 6) + string(SUBSTRING ${git_hash} 0 6 git_hash) + endif() + set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}_r${git_hash}") + else() + set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}_r${${PROJECT_NAME}_REVISION_ID}") + endif() +else() + set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}") +endif() diff --git a/Applications/PluginGenerator/ProjectTemplate/CMake/CTestCustom.cmake.in b/Applications/PluginGenerator/ProjectTemplate/CMake/CTestCustom.cmake.in new file mode 100644 index 0000000000..fb9b4d60f6 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMake/CTestCustom.cmake.in @@ -0,0 +1,80 @@ +set(CTEST_CUSTOM_COVERAGE_EXCLUDE + ${CTEST_CUSTOM_COVERAGE_EXCLUDE} + + # Exclude try_compile sources from coverage results: + "/CMakeFiles/CMakeTmp/" + + # Exclude files generated by the moc pre-compiler + ".*/moc_.*" + + # Exclude files generated by the uic pre-compiler + ".*/ui_.*" + + # Exclude files from the Testing directories + ".*/Testing/.*" + + ".*/CMakeExternals/.*" + + ) + +# The following tests should not be run under valgrind +set(CTEST_CUSTOM_MEMCHECK_IGNORE + + ) + +set(CTEST_CUSTOM_ERROR_MATCH + ${CTEST_CUSTOM_ERROR_MATCH} + "CMake Error[ :]" + ) + +set(CTEST_CUSTOM_WARNING_MATCH + ${CTEST_CUSTOM_WARNING_MATCH} + "CMake Warning[ :]" + ) + +set(CTEST_CUSTOM_WARNING_EXCEPTION + ${CTEST_CUSTOM_WARNING_EXCEPTION} + + # kwstyle suppressions + "[Kk][Ww][Ss]tyle.*kws.*cxx" + "[Kk][Ww][Ss]tyle.*kws.*h" + "[Kk][Ww][Ss]tyle.*metaCommand.*cxx" + + # vtk suppressions + "vtkfreetype" + "Utilities.vtktiff" + "VTK.*IO.vtkMySQLQuery.cxx" + "VTK.*Utilities.vtkexodus2" + "VTK.*Utilities.vtklibproj" + "VTK.*Utilities.vtksqlite" + "VTK.*Utilities.vtkmetaio" + "VTK.*warn_unused_result" + "VTK.*Filtering.*cxx" + "VTK.*IO.*cxx" + "VTK.*Infovis.*cxx" + + # qt suppressions from vtk... + # Some VTK dashboards include building bits of Qt which produce lots of + # the following warnings when built with the MS compilers. Qt guys should + # fix their code. Until they do, keep the Qt chatter off the VTK dashboard + # results: + "include.[Qq]t([Cc]ore|[Gg]ui).*warning C4127: conditional expression is constant" + "[Qq]t.*h.*warning.*declaration of .* shadows a member of .this" + "[Qq]t.*h.*warning.*(copy constructor|assignment operator) could not be generated" + + # Suppress warning caused when QT 'foreach' loops are combined + ".*warning: declaration of '_container_' shadows a previous local" + + # PythonQt suppressions + "PythonQt.*src.*PythonQt.*(cpp|h)" + "include.PythonQt.PythonQt.*h" + + # Suppressing warnings about duplicate libraries in Darwin + # At some point this may be addressed by CMake feature request: + # http://public.kitware.com/Bug/view.php?id=10179 + "ld: warning: duplicate dylib.*" + + # Visual studio spurious warnings... + "The following environment variables were not found" + + ) diff --git a/Applications/PluginGenerator/ProjectTemplate/CMake/MacroEmptyExternalProject.cmake b/Applications/PluginGenerator/ProjectTemplate/CMake/MacroEmptyExternalProject.cmake new file mode 100644 index 0000000000..fa19380a82 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMake/MacroEmptyExternalProject.cmake @@ -0,0 +1,18 @@ + +# +# Convenient macro allowing to define a "empty" project in case an external one is provided +# using for example _DIR. +# Doing so allows to keep the external project dependency system happy. +# +macro(MacroEmptyExternalProject proj dependencies) + + ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS + ${dependencies} + ) + +endmacro() diff --git a/Applications/PluginGenerator/ProjectTemplate/CMake/StartVS.bat.in b/Applications/PluginGenerator/ProjectTemplate/CMake/StartVS.bat.in new file mode 100644 index 0000000000..0b70b447cb --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMake/StartVS.bat.in @@ -0,0 +1,6 @@ +@set CL=/D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE +@set LINK=/LARGEADDRESSAWARE + +PATH=@MITK_RUNTIME_PATH@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/@VS_BUILD_TYPE@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/plugins/@VS_BUILD_TYPE@;%PATH% +"@VS_SOLUTION_FILE@" + diff --git a/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake b/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake new file mode 100644 index 0000000000..695a930245 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake @@ -0,0 +1,115 @@ +#----------------------------------------------------------------------------- +# MITK +#----------------------------------------------------------------------------- + +set(MITK_DEPENDS) +set(proj_DEPENDENCIES) +set(proj MITK) + +if(NOT MITK_DIR) + + #----------------------------------------------------------------------------- + # Generate cmake variable names for BlueBerry bundles + #----------------------------------------------------------------------------- + + option(MITK_USE_SUPERBUILD "Use superbuild for MITK" ON) + option(MITK_USE_BLUEBERRY "Build the BlueBerry platform in MITK" ON) + option(MITK_BUILD_TUTORIAL "Build the MITK tutorial" OFF) + option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) + option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_BLUEBERRY}) + option(MITK_USE_GDCMIO "Use the GDCMIO class instead of ImageIO2 for DICOM" ON) + option(MITK_USE_DCMTK "Use DCMTK in MITK" ON) + option(MITK_USE_QT "Use Trolltech's Qt library in MITK" ON) + option(MITK_USE_Boost "Use the Boost library in MITK" OFF) + option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) + + + mark_as_advanced(MITK_USE_SUPERBUILD + MITK_BUILD_ALL_PLUGINS + ) + + set(mitk_cmake_boolean_args + MITK_USE_SUPERBUILD + MITK_USE_BLUEBERRY + MITK_BUILD_TUTORIAL + MITK_BUILD_ALL_PLUGINS + MITK_USE_CTK + MITK_USE_GDCMIO + MITK_USE_DCMTK + MITK_USE_QT + MITK_USE_Boost + MITK_USE_OpenCV + ) + + #----------------------------------------------------------------------------- + # Create the final variable containing superbuild boolean args + #----------------------------------------------------------------------------- + + set(mitk_boolean_args) + foreach(mitk_cmake_arg ${mitk_cmake_boolean_args}) + list(APPEND mitk_boolean_args -D${mitk_cmake_arg}:BOOL=${${mitk_cmake_arg}}) + endforeach() + + #----------------------------------------------------------------------------- + # Additional MITK CMake variables + #----------------------------------------------------------------------------- + + set(additional_mitk_cmakevars ) + foreach(proj CTK DCMTK VTK ITK OpenCV) + if(${proj}_DIR) + list(APPEND additional_mitk_cmakevars "-D${proj}_DIR:PATH=${${proj}_DIR}") + endif() + endforeach() + + if(MITK_USE_QT AND QT_QMAKE_EXECUTABLE) + list(APPEND additional_mitk_cmakevars "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") + endif() + + if(BOOST_ROOT) + list(APPEND additional_mitk_cmakevars "-DBOOST_ROOT:INTERNAL=${BOOST_ROOT}") + endif() + + if(MITK_INITIAL_CACHE_FILE) + list(APPEND additional_mitk_cmakevars "-DMITK_INITIAL_CACHE_FILE:INTERNAL=${MITK_INITIAL_CACHE_FILE}") + endif() + + if(MITK_USE_SUPERBUILD) + set(MITK_BINARY_DIR ${proj}-superbuild) + else() + set(MITK_BINARY_DIR ${proj}-build) + endif() + + set(proj_DEPENDENCIES) + set(MITK_DEPENDS ${proj}) + + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} + BINARY_DIR ${MITK_BINARY_DIR} + PREFIX ${proj}${ep_suffix} + GIT_REPOSITORY "${git_protocol}://git.mitk.org/MITK.git" + GIT_TAG "origin/master" + INSTALL_COMMAND "" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + ${ep_common_args} + ${mitk_boolean_args} + ${additional_mitk_cmakevars} + -DBUILD_SHARED_LIBS:BOOL=ON + DEPENDS + ${proj_DEPENDENCIES} + ) + + if(MITK_USE_SUPERBUILD) + set(MITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/${MITK_BINARY_DIR}/MITK-build") + else() + set(MITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/${MITK_BINARY_DIR}") + endif() + +else() + + # The project is provided using MITK_DIR, nevertheless since other + # projects may depend on MITK, let's add an 'empty' one + MacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") + +endif() + diff --git a/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt b/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt new file mode 100644 index 0000000000..1177f382ad --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt @@ -0,0 +1,364 @@ +cmake_minimum_required(VERSION 2.8.4) + +# Change project and application name to your own +set(MY_PROJECT_NAME $(project-name)) +set(MY_APP_NAME $(project-app-name)) + +#----------------------------------------------------------------------------- +# 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) + + # 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(${MY_PROJECT_NAME}_USE_SUPERBUILD "Build ${MY_PROJECT_NAME} and the projects it depends on via SuperBuild.cmake." ON) + +if(${MY_PROJECT_NAME}_USE_SUPERBUILD) + project(${MY_PROJECT_NAME}-superbuild) + set(${MY_PROJECT_NAME}_SOURCE_DIR ${PROJECT_SOURCE_DIR}) + set(${MY_PROJECT_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR}) +else() + project(${MY_PROJECT_NAME}) +endif() + +#----------------------------------------------------------------------------- +# 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() + +#----------------------------------------------------------------------------- +# Update CMake module path +#------------------------------------------------------------------------------ + +set(CMAKE_MODULE_PATH + ${${MY_PROJECT_NAME}_SOURCE_DIR}/CMake + ${CMAKE_MODULE_PATH} + ) + +#----------------------------------------------------------------------------- +# CMake Function(s) and Macro(s) +#----------------------------------------------------------------------------- + +include(MacroEmptyExternalProject) + +#----------------------------------------------------------------------------- +# Output directories. +#----------------------------------------------------------------------------- + +foreach(type LIBRARY RUNTIME ARCHIVE) + set(output_dir ${${MY_PROJECT_NAME}_BINARY_DIR}/bin) + set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.") + mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) +endforeach() + +#----------------------------------------------------------------------------- +# Additional Options (also shown during superbuild) +#----------------------------------------------------------------------------- + +option(BUILD_SHARED_LIBS "Build ${MY_PROJECT_NAME} with shared libraries" ON) +option(WITH_COVERAGE "Enable/Disable coverage" OFF) +option(BUILD_TESTING "Test the project" ON) + +option(${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS "Build all ${MY_PROJECT_NAME} plugins" OFF) + +mark_as_advanced(${MY_PROJECT_NAME}_INSTALL_RPATH_RELATIVE + ${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS + ) + +#----------------------------------------------------------------------------- +# 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) + +#----------------------------------------------------------------------------- +# Superbuild script +#----------------------------------------------------------------------------- + +if(${MY_PROJECT_NAME}_USE_SUPERBUILD) + include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") + return() +endif() + +#***************************************************************************** +#**************************** END OF SUPERBUILD **************************** +#***************************************************************************** + +#----------------------------------------------------------------------------- +# Prerequesites +#----------------------------------------------------------------------------- + +find_package(MITK REQUIRED) +link_directories(${MITK_LINK_DIRECTORIES}) + +#----------------------------------------------------------------------------- +# CMake Function(s) and Macro(s) +#----------------------------------------------------------------------------- + +set(CMAKE_MODULE_PATH + ${MITK_SOURCE_DIR}/CMake + ${CMAKE_MODULE_PATH} + ) + +include(mitkFunctionCheckCompilerFlags) +include(mitkFunctionGetGccVersion) +include(mitkFunctionGetVersion) + +#----------------------------------------------------------------------------- +# Set project specific options and variables (NOT available during superbuild) +#----------------------------------------------------------------------------- + +set(${PROJECT_NAME}_VERSION_MAJOR "0") +set(${PROJECT_NAME}_VERSION_MINOR "1") +set(${PROJECT_NAME}_VERSION_PATCH "1") +set(${PROJECT_NAME}_VERSION_STRING "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}") + +# Ask the user if a console window should be shown with the applications +option(${PROJECT_NAME}_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting GUI Applications" ON) +mark_as_advanced(${PROJECT_NAME}_SHOW_CONSOLE_WINDOW) + +if(NOT UNIX AND NOT MINGW) + set(MITK_WIN32_FORCE_STATIC "STATIC") +endif() + +set(${PROJECT_NAME}_MODULES_PACKAGE_DEPENDS_DIR "${PROJECT_SOURCE_DIR}/CMake/PackageDepends") +list(APPEND MODULES_PACKAGE_DEPENDS_DIRS ${${PROJECT_NAME}_MODULES_PACKAGE_DEPENDS_DIR}) + +#----------------------------------------------------------------------------- +# Get project version info +#----------------------------------------------------------------------------- + +mitkFunctionGetVersion(${PROJECT_SOURCE_DIR} ${PROJECT_NAME}) + +#----------------------------------------------------------------------------- +# Installation preparation +# +# These should be set before any MITK install macros are used +#----------------------------------------------------------------------------- + +# on Mac OSX all CTK plugins get copied into every +# application bundle (.app directory) specified here +set(MACOSX_BUNDLE_NAMES) +if(APPLE) + list(APPEND MACOSX_BUNDLE_NAMES ${MY_APP_NAME}) +endif(APPLE) + +#----------------------------------------------------------------------------- +# Set symbol visibility Flags +#----------------------------------------------------------------------------- + +# MinGW does not export all symbols automatically, so no need to set flags +if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) + # The MITK module build system does not yet support default hidden visibility + set(VISIBILITY_CXX_FLAGS ) # "-fvisibility=hidden -fvisibility-inlines-hidden") +endif() + +#----------------------------------------------------------------------------- +# Set coverage Flags +#----------------------------------------------------------------------------- + +if(WITH_COVERAGE) + if(CMAKE_COMPILER_IS_GNUCXX) + set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") + set(COVERAGE_CXX_FLAGS ${coverage_flags}) + set(COVERAGE_C_FLAGS ${coverage_flags}) + endif() +endif() + +#----------------------------------------------------------------------------- +# Project C/CXX Flags +#----------------------------------------------------------------------------- + +set(${PROJECT_NAME}_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}") +set(${PROJECT_NAME}_CXX_FLAGS "${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") + + mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) + mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) + + mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) + # 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")) + mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) + endif() + if(MINGW) + # suppress warnings about auto imported symbols + set(${PROJECT_NAME}_CXX_FLAGS "-Wl,--enable-auto-import ${${PROJECT_NAME}_CXX_FLAGS}") + # we need to define a Windows version + set(${PROJECT_NAME}_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${${PROJECT_NAME}_CXX_FLAGS}") + endif() + + set(${PROJECT_NAME}_C_FLAGS "${cflags} ${${PROJECT_NAME}_C_FLAGS}") + set(${PROJECT_NAME}_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel -Wsign-promo ${${PROJECT_NAME}_CXX_FLAGS}") + # The following line produces a lot of warnings in MITK header files... + #set(${PROJECT_NAME}_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${${PROJECT_NAME}_CXX_FLAGS}") +endif() + +#----------------------------------------------------------------------------- +# Set C/CXX Flags +#----------------------------------------------------------------------------- + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS}") + +#----------------------------------------------------------------------------- +# Testing +#----------------------------------------------------------------------------- + +if(BUILD_TESTING) + enable_testing() + include(CTest) + mark_as_advanced(TCL_TCLSH DART_ROOT) + + # Setup file for setting custom ctest vars + configure_file( + CMake/CTestCustom.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake + @ONLY + ) + + # Configuration for the CMake-generated test driver + set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") + 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() + +#----------------------------------------------------------------------------- +# ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR +#----------------------------------------------------------------------------- + +# If ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR isn't defined, it means this project is +# *NOT* build using Superbuild. In that specific case, ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR +# should default to PROJECT_BINARY_DIR +if(NOT DEFINED ${PROJECT_NAME}_SUPERBUILD_BINARY_DIR) + set(${PROJECT_NAME}_SUPERBUILD_BINARY_DIR ${PROJECT_BINARY_DIR}) +endif() + +#----------------------------------------------------------------------------- +# Qt support +#----------------------------------------------------------------------------- + +if(MITK_USE_QT) + set(QT_QMAKE_EXECUTABLE ${MITK_QMAKE_EXECUTABLE}) + add_definitions(-DQWT_DLL) +endif() + +#----------------------------------------------------------------------------- +# MITK modules +#----------------------------------------------------------------------------- + +#add_subdirectory(Modules) + +#----------------------------------------------------------------------------- +# CTK plugins +#----------------------------------------------------------------------------- + +# The CMake code in this section *must* be in the top-level CMakeLists.txt file + +macro(GetMyTargetLibraries all_target_libraries varname) + set(re_ctkplugin "^$(project-plugin-base)_[a-zA-Z0-9_]+$") + set(_tmp_list) + list(APPEND _tmp_list ${all_target_libraries}) + ctkMacroListFilter(_tmp_list re_ctkplugin OUTPUT_VARIABLE ${varname}) +endmacro() + +include(${CMAKE_CURRENT_SOURCE_DIR}/Plugins/Plugins.cmake) +ctkMacroSetupExternalPlugins(${PROJECT_PLUGINS} + BUILD_OPTION_PREFIX ${MY_PROJECT_NAME}_ + BUILD_ALL ${${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS}) + +#----------------------------------------------------------------------------- +# Add subdirectories +#----------------------------------------------------------------------------- + +add_subdirectory(Apps/$(project-app-name)) + +#----------------------------------------------------------------------------- +# Installation +#----------------------------------------------------------------------------- + +# set MITK cpack variables +include(mitkSetupCPack) + +# Customize CPack variables for this project +include(CPackSetup) + +list(APPEND CPACK_CREATE_DESKTOP_LINKS "${MY_APP_NAME}") + +configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in + ${PROJECT_BINARY_DIR}/${PROJECT_NAME}CPackOptions.cmake @ONLY) +set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}CPackOptions.cmake") + +# include CPack model once all variables are set +include(CPack) + +# Additional installation rules +include(mitkInstallRules) + +#----------------------------------------------------------------------------- +# Last configuration steps +#----------------------------------------------------------------------------- + +# If we are under Windows, create two batch files which correctly +# set up the environment for the application and for Visual Studio +if(WIN32) + include(mitkFunctionCreateWindowsBatchScript) + + set(VS_SOLUTION_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln") + foreach(VS_BUILD_TYPE debug release) + mitkFunctionCreateWindowsBatchScript("${PROJECT_SOURCE_DIR}/CMake/StartVS.bat.in" + ${PROJECT_BINARY_DIR}/StartVS_${VS_BUILD_TYPE}.bat + ${VS_BUILD_TYPE}) + endforeach() +endif(WIN32) diff --git a/Applications/PluginGenerator/ProjectTemplate/Copyright.txt b/Applications/PluginGenerator/ProjectTemplate/Copyright.txt new file mode 100644 index 0000000000..adf2b2d3e7 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Copyright.txt @@ -0,0 +1 @@ +$(copyright) diff --git a/Applications/PluginGenerator/ProjectTemplate/Plugins/Plugins.cmake b/Applications/PluginGenerator/ProjectTemplate/Plugins/Plugins.cmake new file mode 100644 index 0000000000..b5b5fc1943 --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/Plugins/Plugins.cmake @@ -0,0 +1,3 @@ +set(PROJECT_PLUGINS + $(project-plugins) +) diff --git a/Applications/PluginGenerator/ProjectTemplate/SuperBuild.cmake b/Applications/PluginGenerator/ProjectTemplate/SuperBuild.cmake new file mode 100644 index 0000000000..68d0b6869f --- /dev/null +++ b/Applications/PluginGenerator/ProjectTemplate/SuperBuild.cmake @@ -0,0 +1,198 @@ + +#-------------------------- ITK/VTK ------------------------- +# Provide an option to supply pre-built versions of ITK and VTK. +# If not found, MITK will build them itself during superbuild +set(VTK_DIR "" CACHE PATH "Use the supplied VTK installation/binary dir instead of superbuilding it") +set(ITK_DIR "" CACHE PATH "Use the supplied ITK installation/binary dir instead of superbuilding it") +mark_as_advanced(VTK_DIR ITK_DIR) + +#---------------------------- MITK -------------------------- + +if(MITK_DIR) + + # sanity checks in the case of a pre-built MITK + set(my_itk_dir ${ITK_DIR}) + set(my_vtk_dir ${VTK_DIR}) + set(my_qmake_executable ${QT_QMAKE_EXECUTABLE}) + + find_package(MITK REQUIRED) + + if(my_itk_dir AND NOT my_itk_dir STREQUAL ${ITK_DIR}) + message(FATAL_ERROR "ITK packages do not match:\n ${MY_PROJECT_NAME}: ${my_itk_dir}\n MITK: ${ITK_DIR}") + endif() + + if(my_vtk_dir AND NOT my_vtk_dir STREQUAL ${VTK_DIR}) + message(FATAL_ERROR "VTK packages do not match:\n ${MY_PROJECT_NAME}: ${my_vtk_dir}\n MITK: ${VTK_DIR}") + endif() + + if(my_qmake_executable AND NOT my_qmake_executable STREQUAL ${MITK_QMAKE_EXECUTABLE}) + message(FATAL_ERROR "Qt qmake does not match:\n ${MY_PROJECT_NAME}: ${my_qmake_executable}\n MITK: ${MITK_QMAKE_EXECUTABLE}") + endif() + +endif() + + +#----------------------------------------------------------------------------- +# External project settings +#----------------------------------------------------------------------------- + +include(ExternalProject) + +set(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals") +set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) + +set(ep_install_dir "${CMAKE_BINARY_DIR}/CMakeExternals/Install") +set(ep_suffix "-cmake") +set(ep_build_shared_libs ON) +set(ep_build_testing OFF) + +# Compute -G arg for configuring external projects with the same CMake generator: +if(CMAKE_EXTRA_GENERATOR) + set(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") +else() + set(gen "${CMAKE_GENERATOR}") +endif() + +# Use this value where semi-colons are needed in ep_add args: +set(sep "^^") + +## + +if(MSVC90 OR MSVC10) + set(ep_common_C_FLAGS "${CMAKE_C_FLAGS} /bigobj /MP") + set(ep_common_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /MP") +else() + set(ep_common_C_FLAGS "${CMAKE_C_FLAGS} -DLINUX_EXTRA") + set(ep_common_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX_EXTRA") +endif() + +set(ep_common_args + -DBUILD_TESTING:BOOL=${ep_build_testing} + -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir} + -DBUILD_SHARED_LIBS:BOOL=${ep_build_shared_libs} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + "-DCMAKE_C_FLAGS:STRING=${ep_common_C_FLAGS}" + "-DCMAKE_CXX_FLAGS:STRING=${ep_common_CXX_FLAGS}" +) + +#----------------------------------------------------------------------------- +# Git protocol option +#----------------------------------------------------------------------------- + +option(${MY_PROJECT_NAME}_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." OFF) +mark_as_advanced(${MY_PROJECT_NAME}_USE_GIT_PROTOCOL) + +set(git_protocol "git") +if(NOT ${MY_PROJECT_NAME}_USE_GIT_PROTOCOL) + set(git_protocol "http") +endif() + +#----------------------------------------------------------------------------- +# ExternalProjects +#----------------------------------------------------------------------------- + +set(external_projects + MITK + ) + +# Include external projects +foreach(p ${external_projects}) + include(CMakeExternals/${p}.cmake) +endforeach() + +#----------------------------------------------------------------------------- +# Set superbuild boolean args +#----------------------------------------------------------------------------- + +set(my_cmake_boolean_args + WITH_COVERAGE + BUILD_TESTING + ${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS + ) + +#----------------------------------------------------------------------------- +# Create the final variable containing superbuild boolean args +#----------------------------------------------------------------------------- + +set(my_superbuild_boolean_args) +foreach(my_cmake_arg ${my_cmake_boolean_args}) + list(APPEND my_superbuild_boolean_args -D${my_cmake_arg}:BOOL=${${my_cmake_arg}}) +endforeach() + +#----------------------------------------------------------------------------- +# Project Utilities +#----------------------------------------------------------------------------- + +set(proj ${MY_PROJECT_NAME}-Utilities) +ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS + # Mandatory dependencies + ${MITK_DEPENDS} + # Optional dependencies +) + +#----------------------------------------------------------------------------- +# Project Configure +#----------------------------------------------------------------------------- + +set(proj ${MY_PROJECT_NAME}-Configure) + +ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "" + CMAKE_GENERATOR ${gen} + CMAKE_ARGS + ${ep_common_args} + ${my_superbuild_boolean_args} + -D${MY_PROJECT_NAME}_USE_SUPERBUILD:BOOL=OFF + -D${MY_PROJECT_NAME}_CONFIGURED_VIA_SUPERBUILD:BOOL=ON + -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} + -D${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR:PATH=${PROJECT_BINARY_DIR} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DMITK_DIR:PATH=${MITK_DIR} + -DITK_DIR:PATH=${ITK_DIR} + -DVTK_DIR:PATH=${VTK_DIR} + + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} + BINARY_DIR ${CMAKE_BINARY_DIR}/${MY_PROJECT_NAME}-build + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS + ${MY_PROJECT_NAME}-Utilities + ) + + +#----------------------------------------------------------------------------- +# Project +#----------------------------------------------------------------------------- + +# The variable SUPERBUILD_EXCLUDE_${MY_PROJECT_NAME}BUILD_TARGET should be set when submitting to a dashboard +if(NOT DEFINED SUPERBUILD_EXCLUDE_${MY_PROJECT_NAME}BUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_${MY_PROJECT_NAME}BUILD_TARGET) + set(proj ${MY_PROJECT_NAME}-build) + ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + CMAKE_GENERATOR ${gen} + BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${MY_PROJECT_NAME}-build --config ${CMAKE_CFG_INTDIR} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} + BINARY_DIR ${MY_PROJECT_NAME}-build + INSTALL_COMMAND "" + DEPENDS + "${MY_PROJECT_NAME}-Configure" + ) +endif() + +#----------------------------------------------------------------------------- +# Custom target allowing to drive the build of the project itself +#----------------------------------------------------------------------------- + +add_custom_target(${MY_PROJECT_NAME} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${MY_PROJECT_NAME}-build --config ${CMAKE_CFG_INTDIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MY_PROJECT_NAME}-build +) + diff --git a/Applications/PluginGenerator/project_template.qrc b/Applications/PluginGenerator/project_template.qrc new file mode 100644 index 0000000000..20a2c11b5a --- /dev/null +++ b/Applications/PluginGenerator/project_template.qrc @@ -0,0 +1,18 @@ + + + ProjectTemplate/CMakeLists.txt + ProjectTemplate/Copyright.txt + ProjectTemplate/SuperBuild.cmake + ProjectTemplate/Apps/TemplateApp/CMakeLists.txt + ProjectTemplate/Apps/TemplateApp/startTemplateApp.bat.in + ProjectTemplate/Apps/TemplateApp/TemplateApp.cpp + ProjectTemplate/Apps/TemplateApp/TemplateApp.ini + ProjectTemplate/CMake/CPackSetup.cmake + ProjectTemplate/CMake/CTestCustom.cmake.in + ProjectTemplate/CMake/MacroEmptyExternalProject.cmake + ProjectTemplate/CMake/StartVS.bat.in + ProjectTemplate/CMakeExternals/MITK.cmake + ProjectTemplate/Plugins/Plugins.cmake + MITKCopyright.txt + +