project(@CUSTOM_PROJECT_NAME@)
cmake_minimum_required(VERSION 2.6)

set(BUILD_SHARED_LIBS 1)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" CACHE INTERNAL "Single output directory for building all libraries.")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" CACHE INTERNAL "Single output directory for building all executables.")

# This variable will contain a list of directories
# which contain your binary plug-ins
set(@CUSTOM_PROJECT_NAME@_PLUGIN_OUTPUT_DIRS "" CACHE INTERNAL "@CUSTOM_PROJECT_NAME@ base plugin directories." FORCE)

@FIND_PACKAGE_QT4@
include(${QT_USE_FILE})

set(MITK_USE_BLUEBERRY 1)
# Set the variable below to 0 if you do not want to
# use the extended MITK functionality
set(MITK_USE_EXT 1)
find_package(MITK REQUIRED)

add_subdirectory(Bundles)

# Now build a custom executable to start the
# BlueBerry Workbench with our plug-ins
include_directories(
  ${org_blueberry_osgi_INCLUDE_DIRS}
  ${Poco_INCLUDE_DIRS}
  ${mbilog_INCLUDE_DIRS}
)

link_directories("${org.blueberry.osgi_OUT_DIR}/bin" ${Poco_LIBRARY_DIR})
add_executable(@CUSTOM_PROJECT_EXECUTABLE@ @CUSTOM_PROJECT_EXECUTABLE@.cpp)
target_link_libraries(@CUSTOM_PROJECT_EXECUTABLE@ org_blueberry_osgi)

if(@CUSTOM_PROJECT_NAME@_ENABLED_PLUGINS)
  add_dependencies(@CUSTOM_PROJECT_EXECUTABLE@ ${@CUSTOM_PROJECT_NAME@_ENABLED_PLUGINS})
endif()

# Configure the application's .ini file
set(PLUGIN_CACHE_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugin_cache")
set(PLUGIN_OUTPUT_DIRS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Bundles")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/@CUSTOM_PROJECT_EXECUTABLE@.ini"
               "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/@CUSTOM_PROJECT_EXECUTABLE@.ini" @ONLY)
              

# If we are under Windows, create two batch files which correctly
# set up the environment for the application and for VS 2008
if(WIN32)
  include(mitkFunctionCreateWindowsBatchScript)
  
  foreach(APP_BUILD_TYPE debug release)
    mitkFunctionCreateWindowsBatchScript(start@CUSTOM_PROJECT_EXECUTABLE@.bat.in
      ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start@CUSTOM_PROJECT_EXECUTABLE@_${APP_BUILD_TYPE}.bat
      ${APP_BUILD_TYPE})
      
    # Configure VS batch file
    mitkFunctionCreateWindowsBatchScript("${CMAKE_CURRENT_SOURCE_DIR}/startVS2008.bat.in"
      "${PROJECT_BINARY_DIR}/startVS2008_${APP_BUILD_TYPE}.bat"
      ${APP_BUILD_TYPE})
  endforeach()
endif(WIN32)
